Archived

This topic is now archived and is closed to further replies.

Kyo

ending a program with GLUT and glutTimerFunc?

Recommended Posts

Kyo    154
i'm using glut and i want the program to exit when the escape key is pressed, but how do I tell glut to go past the glutMainLoop() so main can return 0; ? And I set up glutTimerFunc to trigger the timerEvent function every 1000ms but it only triggers it once when the program starts and that's it.. Any idea why? (where TIMERINTERVAL is a const unsigned int, but putting the value directly makes no difference): glutTimerFunc(TIMERINTERVAL, timerEvent, 1); static void timerEvent(int value) { MessageBox(NULL,"ASDSA","DSFDS",MB_OK); } [edited by - Kyo on October 1, 2002 5:20:18 PM]

Share this post


Link to post
Share on other sites
zedzeek    529
this is the major problem with glut, there is a ''hacked'' version lying around search for freeglut (IIRC steve baker''s taken this over)

http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
zedzeek    529
this is the major problem with glut, there is a ''hacked'' version lying around search for freeglut (IIRC steve baker''s taken this over)

http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
Kyo    154
I''ve tried everything for this timerFunc it really is annoying what can the problem be?? It calls it at TIMERINTERVAL milliseconds after the program starts then never again after that..

Share this post


Link to post
Share on other sites
Mr Grinch    318
When you register a timer function, it sets it to only run once. To get it to go constantly, you need to have the timer function that you write re-register itself as a timer function. It seems kind of silly, but that''s the way it works.

I believe you can end a glut program just find with an "exit(0);" call. You may want to do a few things before you do that (like destroy the glut window), but that should work. In my keyboard function, I just have if do this:
if (key == 27) {
//Cleanup & destroy window
exit(0);
}

That seems to work fine for me. It exits nicely when I hit escape.

Share this post


Link to post
Share on other sites
Kyo    154
Thanks very much that''s the first time my questions been answered correctly, directly, simply and to the point :D

Share this post


Link to post
Share on other sites
zedzeek    529
sorry i missed the timer question.
the problem with the exit(0) call though is it does do what u want it
>>ut how do I tell glut to go past the glutMainLoop() so main can return 0<<

it just exits straight away

http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites