Archived

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

sanity

Can someone give me a FPS algorithm?

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