Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: program crashes when rendering  (Read 5536 times)

0 Members and 1 Guest are viewing this topic.

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
program crashes when rendering
« on: May 06, 2015, 08:21:33 pm »
#include "SFML/Graphics.hpp"
int main()
{
    sf::RenderWindow w(sf::VideoMode(500,500),"test");

    sf::CircleShape player(10.0f);

    while( w.isOpen() )
    {
        sf::Event event;
        while ( w.pollEvent(event) ){
            if ( event.type == sf::Event::Closed )
                w.close();
        }
    w.clear();
    w.draw(player);
    w.display();

    }

}

hello, good morning.

can i ask why the program above crash when executing w.draw(player); ?
Im using SFML 2.2
thanks.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #1 on: May 06, 2015, 08:30:49 pm »
There could be many reasons.
Step 1. Use a debugger to find out.

Some things that often trip up people that you should check:

 - are your graphics drivers up-to-date? (SFML needs a OpenGL context v. 1.2 as a minimum and Windows default drivers don't provide that).
 - are you certain that the library (SFML) and your application is built with the same compiler (yes, even minor version differences matter)?
 - are you sure you are not mixing release and debug builds of the library and your application?

There can be other things wrong, but let's start with the above...
« Last Edit: May 06, 2015, 08:32:42 pm by Jesper Juhl »

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #2 on: May 06, 2015, 08:39:06 pm »
thanks.
 - are your graphics drivers up-to-date? (SFML needs a OpenGL context v. 1.2 as a minimum and Windows default drivers don't provide that).
no, im going to update.

 - are you certain that the library (SFML) and your application is built with the same compiler (yes, even minor version differences matter)?
i didnt built sfml, i use the binary release with code blocks.



Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #3 on: May 06, 2015, 08:43:56 pm »
You didn't build SFML - that's ok. But then you have to make sure that the compiler you use to build your app is the exact same that was used to build the SFML binaries you downloaded. If not, you are going to have problems. (the easy way to dodge this problem is to just build SFML yourself - it's easy).

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #4 on: May 06, 2015, 09:42:20 pm »
i tried to build it in VSE successfully, is there any tutorial for codeblocks?

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: program crashes when rendering
« Reply #5 on: May 06, 2015, 09:53:55 pm »
yes, look in the tutorials (in the learn section of the main website) section, it has both a codeblocks with minGW tutorial as well as the CMake one which has been recommended so many times because you need to build the library yourself for many reasons.
« Last Edit: May 06, 2015, 10:49:21 pm by shadowmouse »

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #7 on: May 07, 2015, 11:05:35 am »
Hello guys, thanks for commenting.
I already build SFML for debug mode, but still crashing when rendering. what do i do now?

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #8 on: May 07, 2015, 11:29:44 am »
Can you guys tell me if im using the correct binary?

GCC 4.7.1 TDM (SJLJ) - 32-bit for my codeblocks 13.12 mingw with gnu gcc compiler.

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #9 on: May 07, 2015, 12:07:12 pm »
im getting a segmentation fault when i use the debugger of codeblocks ( see the picture below )


hope that helps
« Last Edit: May 07, 2015, 12:09:35 pm by lorence30 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: program crashes when rendering
« Reply #10 on: May 07, 2015, 12:16:18 pm »
Did you update your driver by now?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #11 on: May 07, 2015, 01:08:32 pm »
Did you update your driver by now?
Youre the one who helped me last time.

Yes i already updated my driver to the latest.


I havent programmed in SFML 2.2 in my life, when i was using VS community, im force to use 2.1 of nightly builds  to avoid this issue.
But now even 2.1 isnt working.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: program crashes when rendering
« Reply #12 on: May 07, 2015, 01:12:40 pm »
Ah if you're using SFML 2.1 then the issue is, that you're using the wrong headers.
Delete your current headers and copy the 2.2 headers.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: program crashes when rendering
« Reply #13 on: May 07, 2015, 01:45:15 pm »
Ah if you're using SFML 2.1 then the issue is, that you're using the wrong headers.
Delete your current headers and copy the 2.2 headers.

You're the man bro!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

but i am still using 2.1 right?
SFML 2.2 isnt fix?
« Last Edit: May 07, 2015, 01:47:00 pm by lorence30 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: program crashes when rendering
« Reply #14 on: May 07, 2015, 01:57:28 pm »
Btw this forum has dedicated quoting features by using the [quote][/quote] tags. Would make it easier to understand your posts if you used them.

but i am still using 2.1 right?
SFML 2.2 isnt fix?
I don't know what you use. And SFML 2.2 isn't broken, so I don't know what the issue was/is?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/