Skip to main content
GameDev.net gamedev.net
🔒 Locked

fps counting

Started by jverkoey Feb 15, 2003 at 4:28 PM 0 replies 350+ views
Original Post
jverkoey
jverkoey
what''s the easiest way to count fps''s? I know there''s been many posts here before, but the search is disabled......and I can''t remember what the code is for it bloodright.150m.com //For the latest on all of the IVGDA projects!
Brian Jones
Brian Jones

    

void CalculateFPS()
{
float fCurrentCount = (float)(clock() / CLOCKS_PER_SEC); // Get the current time


static float fFrameCounter = 0.0f;

fFrameCounter++; // Increment the frame counter


if((fCurrentCount - GetCounter()->fLastCount) >= 1.0f) // Check to see if more than a second has elapsed

{
// One second has elapsed

GetCounter()->fLastCount = fCurrentCount; // Set lastCount to the currentcount


GetCounter()->fFramesPerSecond = fFrameCounter; // Initialize fFramesPerSecond to the current frame count


// Reset the frame counter

fFrameCounter = 0.0f;

}
}



I don't have a signature

[edited by - Brian Jones on February 15, 2003 6:16:22 PM]
I don't have a signature

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.