Next: Miscellaneous Display Control Functions:
Up: OpenGL Quick Reference Guide
Previous: Initializations:
Callbacks
After calling glutMainLoop, control only returns to your program
only if some event occurs. The following routines specify the
events that you wish to listen for, and which procedure of yours to
call for each.
Warning: Unlike all OpenGL functions, in which (x,y) coordinates
are made relative to an idealized window, the (x,y) mouse coordinates
are given in viewport coordinates (i.e., pixels). Furthermore, the
origin is in the upper left corner, so y values increase as you go
down the window.
- glutDisplayFunc(void (*)(void)):
-
Call the given function to redisplay everything (required).
- glutReshapeFunc(void (*)(int width, int height)):
-
Call the given function when window is resized (and originally
created). See the function glViewport(), which typically
should be called after each resizing.
- glutIdleFunc(void (*)(void)):
-
Call the given function with each refresh cycle of the display.
- glutMouseFunc(void (*)(int button, int state, int x, int y)):
-
Call the given function when a mouse button is clicked. The
button argument is any of GLUT_LEFT_BUTTON,
GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON, and the
state is either GLUT_DOWN or GLUT_UP. The
(x,y) coordinates give the current mouse position, relative
to the upper left corner.
- glutMotionFunc(void (*)(int x, int y)):
-
Call the given function when the mouse is dragged (with button
held down). The arguments (x,y) give the mouse coordinates
relative to the upper left corner.
- glutPassiveMotionFunc(void (*)(int x, int y)):
-
Call the given function when the mouse is moved.
- glutKeyboardFunc(void (*)(unsigned char key, int x, int y)):
-
Call the given function when a keyboard key is hit. (This only
handles ASCII characters. There is a different callback for
function and arrow keys.)
Please report any errors or send comments to
Dave Mount
Last updated: Sat, Feb 8, 2003.