sjeng
11-02-2000, 10:06 PM
Hi,
I am trying to get a constant framerate from an openGL application that uses GLUT for its windows. The program is to run on both Win32
and SGI, although the latter is the most important platform (where I really
need the constant framerate).
I thought it would be a good idea
to use glutTimerFunc to tell the frame-loop to wait with executing
glutSwapBuffers() until some particular time has passed.
// THe loop advancing the frames (registered with glutIdleFunc() does:
if (wait){
sleep(0);
return;
}
glutSwapBuffers();
wait = true;
glutTimerFunc(40,allowFrame,1)
// And the allowFrame callback does:
void allowFrame(int value){
wait = false;
}
I expected this to give me frames of 40ms (or nearest video refresh).
Instead, I get really long frames. The timer seems to expire at almost
random times?
How can I get an accurate timer in Glut? Or does anyone know a better way to
get a constant framerate?
Thanks,
Bart
I am trying to get a constant framerate from an openGL application that uses GLUT for its windows. The program is to run on both Win32
and SGI, although the latter is the most important platform (where I really
need the constant framerate).
I thought it would be a good idea
to use glutTimerFunc to tell the frame-loop to wait with executing
glutSwapBuffers() until some particular time has passed.
// THe loop advancing the frames (registered with glutIdleFunc() does:
if (wait){
sleep(0);
return;
}
glutSwapBuffers();
wait = true;
glutTimerFunc(40,allowFrame,1)
// And the allowFrame callback does:
void allowFrame(int value){
wait = false;
}
I expected this to give me frames of 40ms (or nearest video refresh).
Instead, I get really long frames. The timer seems to expire at almost
random times?
How can I get an accurate timer in Glut? Or does anyone know a better way to
get a constant framerate?
Thanks,
Bart