Jump to content
  • Advertisement
Sign in to follow this  
dudedbz1

FPS control

This topic is 4643 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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-

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!