The problem I was having was that I couldn't get any code to execute
after glutMainLoop() after setting the option
and exiting using either "glutLeaveMainLoop" or the 'X'
This was with the freeglut 2.2.0 stable release, and the Nightly CVS
Tarball (both from the links on the homepage).
I checked out the CVS version and it works as expected. I guess the
Nightly CVS Tarball hasn't been updated for a while.
Fay John F Contr AAC/WMG wrote:
> I'm not sure that this is a bug. You're talking about two
> different things here: "GLUT_ACTION_ON_WINDOW_CLOSE", which defines
> what happens when the user clicks on the "X" at the upper right-hand
> corner of a window to close it; and "glutLeaveMainLoop", which causes
> execution to drop out of the main loop. The "fgDeinitialize" function
> does indeed reset the value of "fgState.ActionOnWindowClose" but the
> program (freeglut_main.c, line 1177 in the CVS version) saves the
> current value and uses it in deciding whether to call "exit" or to
> return control to the calling program. In other places where it is
> called ("freeglut_main.c", lines 381, 572, and 1086) either there is
> an error condition (in the first case) or else the
> "ActionOnWindowClose" flag has just been checked and is indeed set to
> Please let me know what behavior you expected (and what the
> documentation says--I haven't looked at it lately) and what actually
> John F. Fay
> -----Original Message-----
> From: freeglut-bugs-admin@...
> [mailto:freeglut-bugs-admin@...]On Behalf Of Marc
> Sent: Saturday, April 24, 2004 6:01 AM
> To: freeglut-bugs@...
> Subject: [Freeglut-bugs] glutLeaveMainLoop still calling exit(0) when
> GLUT_ACTION_CONTINUE_EXECUTION is set.
> I was trying to get some code to execute after glutMainLoop() by using
> I found it did not work as the documentation describes, I delved a
> little deeper and I think I found a fix:
> When glutLeaveMainLoop is called fgState.ActionOnWindow is reset to its
> default GLUT_ACTION_EXIT by fgDeinitialize
> Thus exit(0) is always called regardless of whether
> was called.
> The fix is, remove line 282 from freeglut_init.c
> ie this line:
> fgState.ActionOnWindowClose = GLUT_ACTION_EXIT;
> I checked the cvs tarball and the offending line is there too.
> I've tested it and it seems to work ok, though I'm not 100% sure if
> nothing else will be affected. Please let me know if its not a bug and
> I've just missed something obvoius.
> And thank you to all the developers, I'm using freeglut with plib/pui to
> create a new user interface around Celestia (
> http://shatters.net/celestia ) and it works just great.
> This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
> For a limited time only, get FREE Ground shipping on all orders of $35
> or more. Hurry up and shop folks, this offer expires April 30th!
> Freeglut-bugs mailing list