SFML community forums

Help => General => Topic started by: Zauren on August 06, 2009, 02:59:43 am

Title: Tutorial Issue: Using Render Windows
Post by: Zauren on August 06, 2009, 02:59:43 am
I'm an aspiring coder, and integrating SFML has been a new experience for me. I've managed to wrestle out all the speedbumps through searching and experimenting, but this one is a bit odd. I'm sure it's something simple but have little clue what the culprit is.

I took this code and slapped it in...

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
   
    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear the screen (fill it with black color)
        App.Clear();

        // Display window contents on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


And when I run it, it opens the new window as expected, but then immediately goes white and crashes. But the debug window says it worked normally.

 My eyes are presently ?_? I'm using Visual Studio 2008, if that matters.
Title: Tutorial Issue: Using Render Windows
Post by: Laurent on August 06, 2009, 07:56:44 am
Make sure that you're not mixing debug and release configurations.
Title: Tutorial Issue: Using Render Windows
Post by: Zauren on August 07, 2009, 01:20:48 am
All I have is sfml-window.lib sfml-graphics.lib in my additional dependences, unless that means something beyond just using the linker...
Title: Tutorial Issue: Using Render Windows
Post by: OniLinkPlus on August 07, 2009, 06:03:20 am
Quote from: "Zauren"
All I have is sfml-window.lib sfml-graphics.lib in my additional dependences, unless that means something beyond just using the linker...
Here's your problem: You aren't linking to sfml-system.lib.
Title: Tutorial Issue: Using Render Windows
Post by: Laurent on August 07, 2009, 07:48:36 am
Quote
All I have is sfml-window.lib sfml-graphics.lib in my additional dependences, unless that means something beyond just using the linker...

And you compile in debug configuration or release?
Title: Tutorial Issue: Using Render Windows
Post by: forrestcupp on August 07, 2009, 09:21:33 pm
If it's debug, you have to put a -d at the end of the lib names.

Also, don't you have to define SFML_DYNAMIC in the preprocessor definitions?
Title: Tutorial Issue: Using Render Windows
Post by: Zauren on August 08, 2009, 03:15:59 am
system wasn't in since it wasn't needed, but I stuck it in anyway to be sure. Same error. Dynamic is also set, that was the first thing I tried.

Oh god, I see what the issue was. I WAS compiling in debug without the -d libraries using 'start without debugging', because for all my time with Visual Studio that's how I tested the program instead of building it.

...I toldja it was something stupid! Many thanks!
Title: Tutorial Issue: Using Render Windows
Post by: OniLinkPlus on August 08, 2009, 08:12:41 am
Quote from: "Zauren"
system wasn't in since it wasn't needed, but I stuck it in anyway to be sure. Same error. Dynamic is also set, that was the first thing I tried.

Oh god, I see what the issue was. I WAS compiling in debug without the -d libraries using 'start without debugging', because for all my time with Visual Studio that's how I tested the program instead of building it.

...I toldja it was something stupid! Many thanks!
I'm sorry, but reading the tutorials for setting up, it says that the Window Library depends on the System Library, meaning you cannot use the Window Library without the System Library. So how is it that you are able to run it without System?