FPS control

Started by
1 comment, last by Kalasjniekof 18 years, 6 months ago
Hi all! Ok, I know I asked this before, but I looked and looked but the post is deleted. Ok, my question is, how do I control the framerate? I DONT want the built in one with SDL. Before someone told me how to do it with GetTicks() or something and it worked. I want that. Thanks. -DBZ-
-----------------------------....::::DRAGON BALL Z::::....C<<"+"<<"+"; // Go C++ !!!-----------------------------
Advertisement
Something like this?

WaitTime = (1000/desired_fps); loop{    time = GetTickCount();    render();    while(GetTickCount() < time + WaitTime);}


You could throw in a Sleep(1) or something instead of the empty while-loop.
His solutions should work. Notice however, that limiting the fps is literally a waste of time. Try timebased movement instead. It works something like this:

1 get time since last frame (say, in milliseconds)
2 move objects by: constant * time since last frame (constant could be how much an object should move per millisecond)
3 render

This topic is closed to new replies.

Advertisement