PDA

View Full Version : Event loop



jefs
2nd January 2011, 17:32
What is the best way to get a message for each loop? I want to use the loop to update my game engine.

d_stranz
2nd January 2011, 17:59
What if you used a QTimer, with a short timeout? Use a connection to the timeout signal as the trigger to update your engine.

wysota
2nd January 2011, 18:51
What is the best way to get a message for each loop? I want to use the loop to update my game engine.

That would probably not be a good idea. The game loop should be executed at constant intervals of time and event loop doesn't guarantee anything like that. Better calculate how many iterations per second you need and use an adaptive timer to trigger the game loop (you can use QTimer::singleShot() for that if you calculate corrections to the time in each interation or you can use QObject::startTimer() if you don't want your timer to be adaptive).