In addition to registering with GLUT display and reshape handlers, we can also register callback functions to handle mouse clicks, mouse drags and key presses created by our users. We do this here through GLUT functions for registering handlers for specific types of events.

The mouse callback handles mouse button events, both presses and releases. When the user drags the mouse, the sequence of mouse positions created by the motion is passed to a registered motion callback function. The normal keys on a keyboard are handled by a keyboard callback function while the special keys such as function keys and arrow keys are handled by a special function.