Jump to content
  • Advertisement

Archived

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

a2k

How Do You Display FPS?

This topic is 6698 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''m using opengl and would like to know how to display frames per second to either the full screen, or the title bar in the window. and also, what is most appropriate for a real time game? frame based or time based animation? a2k

Share this post


Link to post
Share on other sites
Advertisement
I was about to ask the same thing.
I was thinking you keep a timer and keep track of how many times the display loop gets called.. Is there a better way?

what''s the best way to output the numbers on screen?

Share this post


Link to post
Share on other sites
is that a link to some useful fps code or just a free plug? i couldn''t find anything.

a2k

Share this post


Link to post
Share on other sites
okay, nevermind, answered my own question:
static LARGE_INTEGER timerFrequency;
static LARGE_INTEGER startTime;
static int nFrames = 0;
static int count = 0;

nFrames++;
if (nFrames > 100)
{
//char cOutBuffer[32];
LARGE_INTEGER currentTime;
float fps;
float frequency;
QueryPerformanceFrequency(&timerFrequency);
QueryPerformanceCounter(¤tTime);

fps = (float) nFrames/((float)(currentTime.QuadPart - startTime.QuadPart)/
(float) timerFrequency.QuadPart);

//sprintf(cOutBuffer, "%0.1f frames per second", fps);
//sprintf(cOutBuffer, "%d", nFrames);
//SetWindowText(hWnd, cOutBuffer);
cout << fps << endl;
nFrames=0;
QueryPerformanceCounter(&startTime);
}


a2k



Edited by - a2k on 4/14/00 12:22:59 PM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!