Game Development Reference
In-Depth Information
glutReshapeFunc
The glutReshapeFunc function is called when FreeGLUT detects that the applic-
ation window has changed its shape. This is necessary for the graphics system (and
sometimes game logic) to know the new screen size and it's up to us to make im-
portant changes to the scene to handle all possibilities.
glutDisplayFunc
If FreeGLUT determines that the current window needs to be redrawn, the
glutDisplayFunc function is called. Sometimes Windows detects that an applica-
tion window is in a damaged state, such as when another window has been partially
obscuring it, and this is where this function might be called. We would typically just
re-render the scene here.
glutIdleFunc
The glutIdleFunc function fills the role of the typical update of game applications.
It is called when FreeGLUT is not busy processing its own events, giving us time to
perform our own game logic instructions.
More information about these functions can be found in the FreeGLUT documenta-
tion at: http://freeglut.sourceforge.net/docs/api.php
Initializing FreeGLUT
Finally, we need to configure our application window before FreeGLUT can launch it
for us. This is done through the following function calls:
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA |
GLUT_DEPTH);
glutInitWindowPosition(0, 0);
glutInitWindowSize(width, height);
glutCreateWindow(title);
glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE,
GLUT_ACTION_GLUTMAINLOOP_RETURNS);
Search WWH ::




Custom Search