How Do You Display FPS?

Started by
3 comments, last by a2k 24 years ago
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
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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?
For the output inside the opengl window I think you should use an ortho view and glBindTexture()

Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA
is that a link to some useful fps code or just a free plug? i couldn''t find anything.

a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
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
------------------General Equation, this is Private Function reporting for duty, sir!a2k

This topic is closed to new replies.

Advertisement