What would be the best way to measure the frame rate of my OpenGL program?
5
votes
4 Answers
5
votes
Stick a timer at the start of your main loop and test how long it takes to get back there.
Under windows you would do something like:
double oldTime = 0.0.
while( !exit )
{
__int64 counter;
QueryPerformanceCounter( (LARGE_INTEGER*)&counter );
__int64 frequency;
QueryPerformanceFrequency( (LARGE_INTEGER*)&frequency );
double newTime = (double)counter / (double)frequency;
double frameRate = 1.0 / (newTime - oldTime);
oldTime = newTime;
// Rest of your game loop goes here.
}
3
votes
1
votes
0
votes