shapeare
07-24-2012, 09:33 AM
I tried calculating the framerate of my program by placing the following code in the Idle function, but never can it exceed 60 fps. And I am sure that the draw call in the rendering loop takes less than 0.01s, so theoretical the framerate should be bigger than 100fps.
void CalculateFrameRate()
{
static float framesPerSecond = 0.0f; // This will store our fps
static float lastTimeFPS = 0.0f; // This will hold the time from the last frame
float currentTimeFPS = GetTickCount() * 0.001f;
++framesPerSecond;
if( currentTimeFPS - lastTimeFPS > 1.0f )
{
lastTimeFPS = currentTimeFPS;
framesPerSecond = 0;
}
}
static void Idle(void)
{
glutPostRedisplay();
CalculateFrameRate();
}
How to correctly measure the frame rate?
void CalculateFrameRate()
{
static float framesPerSecond = 0.0f; // This will store our fps
static float lastTimeFPS = 0.0f; // This will hold the time from the last frame
float currentTimeFPS = GetTickCount() * 0.001f;
++framesPerSecond;
if( currentTimeFPS - lastTimeFPS > 1.0f )
{
lastTimeFPS = currentTimeFPS;
framesPerSecond = 0;
}
}
static void Idle(void)
{
glutPostRedisplay();
CalculateFrameRate();
}
How to correctly measure the frame rate?