• Advertisement
Sign in to follow this  

calculating game FPS

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

Hello guys, i've been looking for a method to calculate the FPS of my game, and regulate it, e.g. limit the FPS to 60, or something like that, i've seen such things in some directX wrappers ( engines, such as DarkGDK )

Share this post


Link to post
Share on other sites
Advertisement
There are other forms of examples here as well, check out how SDL does it,

Lazyfoo Tutorials

and here is how SFML does it, I hope these examples help you figure it out.

SFML Tutorials

If you want to take a look at what is in Clock in SFML you could look at the source files for that object.

Share this post


Link to post
Share on other sites
that's confusing, do we stop the program after 60 frames until the second is over? wouldnt that make the game look "glitchy" if the computer renders the 60 frames in half a second, so you get half a second delay in every loop?

@ SDL example
//If we want to cap the frame rate
if( ( cap == true ) && ( fps.get_ticks() < 1000 / FRAMES_PER_SECOND ) )
{
//Sleep the remaining frame time
SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
}

EDIT: nevermind, i think i got the point wrong, thanks for the links, mate.

Share this post


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

  • Advertisement