Sign in to follow this  

FPS control

This topic is 4483 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
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

This topic is 4483 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this