Archived

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

Oddball

Calculating FPS

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