OpenGLUT 0.6.3 development - OpenGLUT: OpenGLUT 1.0 Window Close API Proposal
Keywords: OpenGLUT, FreeGLUT, OpenGL, GLUT, X11, Windows, Programming, Documentation, Download, Development, Sourceforge

OpenGLUT Documentation
Introduction | Documentation | Examples | Proposals | Authors | Copying | Todo | Bugs | Links

# OpenGLUT 1.0 Window Close API Proposal

Note:
  This is a proposal for the purpose of discussion and discussion. This API is not currently implemented in OpenGLUT.

## Description

OpenGLUT inherits two close-window callback restration methods from freeglut. One is called glutWMCloseFunc(), the other glutCloseFunc(). Neither name is actually ideal. The two functions are identical.

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:

- If the callback has been registered, then invoke it. If the callback returns 0, OpenGLUT will exit; else OpenGLUT will continue processing.
- If no callback has been registered by the user (or has been de-registered) for the current window, then behavior is as if the user had registered this function:

``

           int callback( int source )
           {
               return GLUT_FUNCTION == source;
           }

This has the following merits:

- It is just one function.
- The name is more consistant with other OpenGLUT callbacks. You can Reshape a window and there is a Reshape callback, for example.
- It is explicitly associated with windows by its name.
- It removes the state machine tweaking.
- It allows the application to decide, at window-close time, whether to exit when the window closes, on a per-window basis. Windows that may be freely closed at any time can be bound to a constant function that returns 1.

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.

## Feedback

Feedback, comments or suggestions can be directed either to the mail list or discussion forum.
OpenGLUT Development @ Sourceforge
Homepage | Summary | Files | CVS | Forums | Lists | Bugs | RFE
Generated on Tue Oct 5 18:44:32 2004 for OpenGLUT by doxygen 1.3.8
The OpenGLUT project is hosted by sourceforge.net.