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

Author Topic: Not working  (Read 837 times)

0 Members and 1 Guest are viewing this topic.

lukaius

  • Guest
Not working
« 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;
}
   

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10818
    • View Profile
    • development blog
    • Email
Re: Not working
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lukaius

  • Guest
Re: Not working
« Reply #2 on: November 28, 2017, 08:26:37 pm »
OH! I made such a n00b mistake!





thanks for the quick response time ;)

 

anything