PDA

View Full Version : how to control the mainloop interval?



Suvcon
01-16-2001, 09:11 PM
I used to set a timer in MFC and make my render step with the TIMER Message,so I can control the interval of my app to swapbuffers,and it do well.

but I am now lost in glut.*&%^$^$%$#^%%$#$@#$
I only know the func glutMainLoop(void),but how can i control the loop interval by myself?

thank for your help or your notice me. http://www.opengl.org/discussion_boards/ubb/wink.gif

01-16-2001, 09:33 PM
In glut you can't. You must use winbloze code for that. (since glut is shell to winbloze)

Bob
01-16-2001, 11:21 PM
You can use the glutIdleFunc to control the framerate. The following pseudocode will lock the applicaiton at 50 FPS using GLUT.



int main()
{
...
glutIdleFunc(Idle);
...
glutMainLoop();
}
void Idle(void)
{
while((GetCurrentTime - lastTime) < 20 milliseconds) {do nothing}
lastTime = GetCurrentTime();
glutPostRedisplay();
}

Deiussum
01-17-2001, 09:09 AM
There's also a glutTimerFunc. I haven't used it much, but my guess is that it's accuracy is comparable to the Win32/MFC timer events.