Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sanity

Can someone give me a FPS algorithm?

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

Sup, I have been looking for a while now for a decent FPS algorithm for the project I am working on at the moment, and I thought that seeing how I never have anything to post about I might aswell ask. So can someone tell me or point me towards a decent FPS algorithm. Cheers, Toby.

Share this post


Link to post
Share on other sites
Advertisement
FPS...?

Have a variable i, add 1 to it every frame rendered, every second update something else that contains the fps...

Calculate the duration between one frame and the next and divide 1 second by that number...

Share this post


Link to post
Share on other sites
static float FPS;
static float nextSecond;
static float prevSecond;

FPS++;
nextSecond = GetTickCount() * 0.001f;
if(nextSecond - prevSecond > 1.0f)
{
prevSecond = nextSecond;
sprintf(szFPS, "FPS: %d ", (int)FPS);
FPS = 0;
}

Share this post


Link to post
Share on other sites
Thanks a lot guys I have FPS working (a 2D DD application) and it seems to be peaking out at 75 FPS.

Once again thanks a lot guys .

Toby.

Share this post


Link to post
Share on other sites

  • 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!