Additionally, freeglut provides some mechanisms to twiddle the freeglut state machine behavior so that when a window is closed, we can exit or continue operating.
This proposal is for deprecating both of the old functions, deprecating the GLUT_ACTION_ON_CLOSE option to glutSetOption(), and adding a new function:
glutDestroyWindowFunc( int ( *callback )( int source ) );
Where source is defined as either GLUT_FUNCTION or GLUT_USER, according to whether the window is closed by user action or by the program calling glutDestroyWindow(). This allows program control over continuation of the program, using the following convention:
int callback( int source )
return GLUT_FUNCTION == source;
This has the following merits:
Variation: Change the default behavior to continue processing, rather than exiting, regardless of the close-event's source. The rationale for this is that the close-box (by which most GLUT_USER window-closes are likely to occur) is not guaranteed to exist on any particular platform. By changing the default to continuation, the user is encouraged to address a portable way to terminate their program. The downside is that beginners may have more important things to worry about than program termination.