SFML community forums

Help => Graphics => Topic started by: lorence30 on May 06, 2015, 08:21:33 pm

Title: program crashes when rendering
Post by: lorence30 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.
Title: Re: program crashes when rendering
Post by: Jesper Juhl 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...
Title: Re: program crashes when rendering
Post by: lorence30 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.


Title: Re: program crashes when rendering
Post by: Jesper Juhl 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).
Title: Re: program crashes when rendering
Post by: lorence30 on May 06, 2015, 09:42:20 pm
i tried to build it in VSE successfully, is there any tutorial for codeblocks?
Title: Re: program crashes when rendering
Post by: shadowmouse 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.
Title: Re: program crashes when rendering
Post by: dabbertorres on May 06, 2015, 10:11:22 pm
http://www.sfml-dev.org/tutorials/2.2/compile-with-cmake.php
Title: Re: program crashes when rendering
Post by: lorence30 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?
Title: Re: program crashes when rendering
Post by: lorence30 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.
Title: Re: program crashes when rendering
Post by: lorence30 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
Title: AW: program crashes when rendering
Post by: eXpl0it3r on May 07, 2015, 12:16:18 pm
Did you update your driver by now?
Title: Re: program crashes when rendering
Post by: lorence30 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.
Title: AW: program crashes when rendering
Post by: eXpl0it3r 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.
Title: Re: program crashes when rendering
Post by: lorence30 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?
Title: Re: program crashes when rendering
Post by: eXpl0it3r 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?
Title: Re: program crashes when rendering
Post by: lorence30 on May 07, 2015, 02:05:52 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.

Just figured it out.



by the way, can you take a look at the picture below.
It always show up in my console window when rendering in sfml window
Title: Re: program crashes when rendering
Post by: eXpl0it3r on May 07, 2015, 02:31:14 pm
What's your OS, your GPU and your GPU driver version?
Title: Re: program crashes when rendering
Post by: lorence30 on May 07, 2015, 02:44:00 pm

Windows 7 ultimate
Mobile Intel (R) 965 Express Chipset Family  15.12.75.4.64.1930
Title: Re: program crashes when rendering
Post by: binary1248 on May 09, 2015, 08:15:43 pm
Just use SFML 2.3. Your graphics chip is so old that you probably don't have a driver that provides proper OpenGL hardware acceleration on Windows. SFML 2.3 will work even without full hardware accelerated OpenGL without crashing. It will be slow, but at least it will work.