SFML community forums

Help => Window => Topic started by: calccrypto on January 15, 2012, 11:58:24 pm

Title: sf::RenderWindow::Clear() causing crazy flashes
Post by: calccrypto on January 15, 2012, 11:58:24 pm
Im getting a weird problem that I dont believe that i should be getting, and yet the program is so simple that I dont know where it could have gone wrong. this code:

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

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
    App.Clear(sf::Color(200, 0, 0));
    // 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();
        }

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

    return EXIT_SUCCESS;
}


which i got off of the tutorials, with a minor change (App.Clear(sf::Color(200, 0, 0)); ) causes the screen to flash like crazy (from black to the input color: in this case, red). why is that? how can i fix this? im simply trying to set the background to some color besides black
Title: sf::RenderWindow::Clear() causing crazy flashes
Post by: thePyro_13 on January 16, 2012, 01:30:10 am
Your "Clear()" should be inside your while loop.

Usually your game loop would look like this:
Code: [Select]
While(playing)
{
 // Process events

 //collect and act upon user input?

 Clear();
 ///Draw stuff
 Display();
}
 
Title: sf::RenderWindow::Clear() causing crazy flashes
Post by: calccrypto on January 16, 2012, 02:19:57 am
thanks!