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

Author Topic: window only updating when moving mouse...  (Read 1767 times)

0 Members and 1 Guest are viewing this topic.

og_the_trog

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
window only updating when moving mouse...
« on: February 14, 2014, 11:01:53 pm »
Okay so here's my problem...
previously I had my game loop like this:

        sf::RenderWindow window(sf::VideoMode(600, 800), "sfml game");
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        /* update */
                }
        }
 

and this didn't work because my sprites would only be updated when I was moving the mouse, I figured this was beause it was not polling events and thus wasn't updating, so then I added this "|| true" to the loop, so it will be updating and checking events:

while (window.pollEvent(event) || true)
 

and this worked perfectly... until I moved to linux mint.
when I dont have the
|| true
it has the same problem as I did on windows, but when I do have it, I compile it on code::blocks and it compiles, but when I try to run it, it shows up like the terminal where all the
std::cout <<
commands go, but not the actual game window.

information:

window 7 home premium:
microsoft visual studio 2010 express edition

linux mint 16:
code::blocks, compiled with GNU GCC compiler

thankyou very much.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
AW: window only updating when moving mouse...
« Reply #1 on: February 14, 2014, 11:22:20 pm »
Have you ever read the tutorials on event handling and the general game loop? It doesn't sound like it and you definitely should do so.

The updating & drawing belongs outside of the event loop. If you wite while(x || true) the boolean equation can be reduced to while(true) which as we all know is the well-known infinite loop.

Again read the tutorials.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

og_the_trog

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: window only updating when moving mouse...
« Reply #2 on: February 14, 2014, 11:37:01 pm »
oh wow, I feel so dumb, you're right!
anyway, so I just moved the all he update function out of the where the events are handled and it works fine

thankyou

 

anything