SFML community forums

Help => Graphics => Topic started by: lukaius on November 28, 2017, 08:17:09 pm

Title: Not working
Post by: lukaius on November 28, 2017, 08:17:09 pm
the window will not change any thing on it. i'm using a render window of course! at first I thought i made the window wrong so i went to the learn page on the SFML website  and got the render window code from it. then tried to just change the color of the window
but would not change the code is below. im using code::Blocks ide with sfml 2.4.2

#include <SFML/Graphics.hpp>

int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear();
        window.display();
    }window.clear(sf::Color::White);
window.display();

    return 0;
}
   
Title: Re: Not working
Post by: eXpl0it3r on November 28, 2017, 08:22:50 pm
Your second clear and display is placed outside of the main loop, so it will only get called on time once the window has already been closed.
Title: Re: Not working
Post by: lukaius on November 28, 2017, 08:26:37 pm
OH! I made such a n00b mistake!





thanks for the quick response time ;)