Archived

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

Calculating FPS

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

I''d like to display the framerate as frames per seconds while my program is running. However, I can''t really figure out how to calculate the FPS. Is there some DirectX function that can do this for me? If anyone has suggestions or sample code, I''d appreciate it. Thanks!

Share this post


Link to post
Share on other sites
easy problem, psuedo code:

StartTime=Timer;

Do GameLoop
{
DrawScene;
Fps++;
if (Timer-StartTime>1.0f)
{
DisplayFps Fps; //DrawText or whatever
Fps=0
StartTime=Timer;
}
}

Second way:
Do GameLoop
{
StartTime=Timer;
DrawScene;
DisplayFps 1.0f/(Timer-StartTime)
}

I don't do c/c++ much, you'll have to ask someone else what the
function to get the current time is.

Hope this helps,
-Michael

Edited by - thr33d on August 12, 2001 7:57:35 PM

Share this post


Link to post
Share on other sites