OpenGLUT 0.6.3 development - OpenGLUT: Window Callbacks
Keywords: OpenGLUT, FreeGLUT, OpenGL, GLUT, X11, Windows, Programming, Documentation, Download, Development, Sourceforge

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

# Window Callbacks
[OpenGLUT API Reference]

## Functions
void | glutCloseFunc (void(*callback)(void))
void | glutDisplayFunc (void(*callback)(void))
void | glutOverlayDisplayFunc (void(*callback)(void))
void | glutReshapeFunc (void(*callback)(int w, int h))
void | glutWindowStatusFunc (void(*callback)(int state))

## Detailed Description

OpenGLUT's event processing centers around the concept of callbacks. A callback is a function to be invoked by OpenGLUT when OpenGLUT processes a suitable event. Many callbacks are associated with windows because most OpenGLUT events come from user-interaction. If a callback is associated with a window, then you can register different callbacks for different windows, and OpenGLUT will set the current window to the appropriate window before invoking the callback.

If you do not set a callback, OpenGLUT will ignore the corresponding event. If you have registered a callback and later wish to restore OpenGLUT's default behavior, you can set the callback to NULL. Exceptions to these rules are noted on a case-by-case basis.

If an event is not bound to a window, the status of the current window setting is undefined. If such a callback needs to access an OpenGLUT window, it must first use glutSetWindow() to set the current window. Analogous concerns hold for the current menu.

## Function Documentation

void glutCloseFunc | ( | void(* | callback)(void) | ) |

  | Window destruction callback. Parameters:
  | callback | Client window destruction hook.
When a window is destroyed by user-action in traditional GLUT, the application terminates. In freeglut and OpenGLUT, the application can choose to persist and treat the window close event as a normal event. This callback is how that event is transmitted to the application. This callback is bound to the current window. Note: This function is exactly the same as glutWMCloseFunc(), which has been deprecated. This function should be used instead. Todo: There needs to be some work to rationalize the behavior when a window is closed. See also: glutDestroyWindow()

void glutDisplayFunc | ( | void(* | callback)(void) | ) |

  | Sets the Display callback for the current window. Parameters:
  | callback | Client function for normal redisplay event.
Sets the display callback for the current window. All windows, including subwindows, must have a display callback registered. OpenGLUT will call the callback function whenever it thinks that the window may require updating. This callback is bound to the current window. Note: Unlike most callbacks, it is illegal to try to disable the display callback by setting it to NULL . Multiple redisplays may be coalesced into a single event for invoking the callback only once. See also: glutPostRedisplay(), glutOverlayDisplayFunc()

void glutOverlayDisplayFunc | ( | void(* | callback)(void) | ) |

  | Defines the display hook for an overlay. Parameters:
  | callback | Client hook for overlay redisplay.
callback is invoked by OpenGLUT to refresh an overlay, if OpenGLUT thinks that this is necessary. Generally, very similar to glutDisplayFunc(), save that: The redisplay is triggered differently. OpenGLUT sets the layer for you. You do not need to have, and can deregister, this callback. This callback is bound to both the current window and the layer. Bug: OpenGLUT does not implement layers at this time. See also: glutDisplayFunc(), glutPostOverlayRedisplay(), glutEstablishOverlay(), glutUseLayer()

void glutReshapeFunc | ( | void(* | callback)(int w, int h) | ) |

  | Sets the Reshape callback for the current window. Parameters:
  | callback | Client function for reshape-window event.
This registers a function with OpenGLUT, which OpenGLUT will invoke whenever the window is reshaped or resized. Your callback is only invoked when the host window system has actually changed the window size. The parameters to your callback are the new width and height for your window. If you do not provide a reshape callback, OpenGLUT will simply call glViewport(0,0,w,h). This callback is bound to the current window. To ask OpenGLUT about the present dimensions of the current window, you can use glutGet(). Note: Unlike other callbacks, GLUT has an active default behavior if you do not set this. (Most event types passively do nothing if you do not specify a callback to handle them.) The reshape callback should always be called, if registered, when your window is first created. See also: glutGet(), glutReshapeWindow()

void glutWindowStatusFunc | ( | void(* | callback)(int state) | ) |

  | Sets the window status callback. Parameters:
  | callback | Client window status hook.
When the visibility status of your window changes, OpenGLUT either invokes the callback registered by this function or the Visibility callback---or neither, if you have not registered either callback. This differs from glutVisbilityFunc() in that the callback has three states, rather than two, that it may receive. These states are: GLUT_VISIBLE (every pixel visible) GLUT_FULLY_COVERED (every pixel obscured) GLUT_HIDDEN (intermediate) The callback is bound to the current window. Note: Makes glutVisibilityFunc() obsolete. See also: glutVisibilityFunc()

OpenGLUT Development @ Sourceforge
Homepage | Summary | Files | CVS | Forums | Lists | Bugs | RFE
Generated on Tue Oct 5 18:44:33 2004 for OpenGLUT by doxygen 1.3.8
The OpenGLUT project is hosted by sourceforge.net.