0
votes

So I'm trying to get SFML to work with Visual C++ 2010, and it will open the window now, but it looks like this when it does.

The window also doesn't respond when you try and move it or close it. Here's my code:

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");

    while (true)
    {
        App.Clear();


        App.Display();
    }

    return EXIT_SUCCESS;
}
1

1 Answers

2
votes

You have to poll events every frame to let the window respond to the operating system. If you don't, you won't move or close it.

#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");
    while (App.IsOpened())
    {
        App.Clear();
        sf::Event event;
        while (App.PollEvent(event))
        {
            if (event.Type == sf::Event::Closed)
                App.Close();
        }
        App.Display();
    }
    return EXIT_SUCCESS;
}

If you use SFML 1.6, change PollEvent to GetEvent. Read the documentation.