Relative Content

Tag Archive for c++cwinapitiminggame-loop

WIN32 game loop is slow even on modern computer, can’t handle 60HZ or 30HZ. What to do?

I’m just trying to learn to program a few things, and a game loop is one of those.

This game loop only process Windows messages, but it can not even handle 30 fps.
This is true also if the message processing is done only once per loop, replacing WHILE with IF.
I use QueryPerformanceCounter() function to get number of 100ns ticks before work is done and after, subtracting them to get time used. Loop time is 100ns * 166666 * 2 = 0.0333332s.
The boolean ‘timeExceeded’ is set if the the wait time is positive, indicating that time used is more than the intended loop time.
What to do?