How Do You Display FPS?
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
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?
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.st
GA
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement