Functions | |
void | glutInit (int *pargc, char **argv) |
void | glutLeaveMainLoop (void) |
void | glutMainLoop (void) |
void | glutMainLoopEvent (void) |
OpenGLUT's event model is based on callbacks (see the callbacks module). This is inherited from old GLUT in design, and from freeglut in implementation. The model works simply by letting you tell OpenGLUT which function of yours to call when certain events happen. Certain events, such as the redisplay event for updating your window graphics, can be postponed and coalesced so that one redisplay may occur in response to multiple hints to OpenGLUT that you require a a redisplay. Some events are manufactured by OpenGLUT, such as timers. Others may be caused by your own request, such as redisplays. Still others may only be caused by external stimulus.
You have two ways to enter OpenGLUT's event processing model. One is via glutMainLoop(), and the other is via glutMainLoopEvent().
When OpenGLUT has dispatched all pending events, it will do one of three things:
Old GLUT did not offer glutMainLoopEvent() nor glutLeaveMainLoop(), and would only exit glutMainLoop() if the user closed one of your windows or if you called exit(). In no case would old GLUT return control to your code by simply returning from glutMainLoop().
freeglut added some mechanisms to control this. One is an explicit glutLeaveMainLoop(). Another is a mode of execution that tells OpenGLUT what to do if a user closes one of your windows.
OpenGLUT inherited freeglut's variations.
---
|
Initialize OpenGLUT data structures.
You should take note of the interaction between glutInit() and the related functions such as glutInitWindowPosition(). OpenGLUT always uses the most recent configuration information, so if you call glutInit(), then glutInitWindowPosition(), you prevent the user from controlling the initial window position via a command-line parameter. glutInit() will remove from pargc, argv any parameters that it recognizes in the command line. The following command-line parameters are suported:
Additionally, this function checks whether the environment variable GLUT_FPS is defined (only on UNIX_X11); if so, OpenGLUT will periodically print the average number of times per second that your program calls glutSwapBuffers().
|
|
Breaks out of OpenGLUT's glutMainLoop(). This function allows you to unilaterally tell OpenGLUT that you are done and wish to exit. This is useful if you have also told OpenGLUT to return to you rather than to call exit() directly. |
|
The standard GLUT event loop entry point. This is the main driving force for an event-driven OpenGLUT program. It alternates between calling glutMainLoopEvent() to process pending events and then either sleeping or calling your idle function (see glutIdleFunc()). This function can return, but GLUT's version of this function never returned. And you must do special things to OpenGLUT to cause OpenGLUT's version to return. The cross-reference section for this function's documentation should ideally contain every callback, but the list would be tediously long and prone to omissions.
|
|
Dispatches all pending events. The general outline of this function is to first drain the queue of windowsystem events, in most cases dispatching each as it is found. After the queue is empty, we check for timer-based events, coalesced window events (e.g., redisplays), and windows that need to be closed. The cross-reference section for this function's documentation should ideally contain every callback, but the list would be tediously long and prone to omissions.
|