#### Archived

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

# Can someone give me a FPS algorithm?

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

## 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 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 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 on other sites
Here''s a nice little stand-alone class for you:

http://www.drunkenhyena.com/docs/dhFPSTimer.phtml

Stay Casual,

Ken
Drunken Hyena

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

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 23
• 9
• 49
• ### Forum Statistics

• Total Topics
632639
• Total Posts
3007587
• ### Who's Online (See full list)

There are no registered users currently online

×