returning from glutMainLoop is possible?

In most FAQs about glutMainLoop, one commonly sees statements such as

If you insist on returning to your program from glutMainLoop(), there is only one way to do so. You need to download the GLUT source and hack gluMainLoop() [sic] to do what you want it to.
Is that really true? I have had success in spawning a thread specifically to run an un-hacked glutMainLoop(). I’ve not had any particular trouble re-starting glut once I’ve killed the thread, except for a warning that glutInit() has been called twice.

So my question for the forum: how dangerous is this approach? In particular, what Bad Things happen if glutMainLoop never really exits (since its thread gets killed), and glutMainLoop is subsequently re-entered?

Although using a thread to quit glutMainLoop appears to work, is there someone there familiar with the initialization and cleanup routines who can tell me what parts of the glut system are left in an inconsistent state by this approach?


  • ff

If you don’t get a reply here then you could try since they must know the GLUT internals pretty well.