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

Author Topic: sf::RenderWindow::Clear() causing crazy flashes  (Read 1922 times)

0 Members and 1 Guest are viewing this topic.

calccrypto

  • Guest
sf::RenderWindow::Clear() causing crazy flashes
« 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

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
sf::RenderWindow::Clear() causing crazy flashes
« Reply #1 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();
}
 

calccrypto

  • Guest
sf::RenderWindow::Clear() causing crazy flashes
« Reply #2 on: January 16, 2012, 02:19:57 am »
thanks!

 

anything