Input
GLUT supports mouse callbacks associated with three different type of events.
This event is triggered whenever a mouse button is pressed or released.
glutMouseFunc(mouseCB); /* register mouse button callback */ void mouseCB(int button, int state, int x, int y);
where button indicates the button that produced the event: GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, or GLUT_RIGHT_BUTTON, all of which are macros defined in glut.h; state provides the button state: pressed (GLUT_DOWN) or released (GLUT_UP); and x, y are the coordinates of the mouse cursor at the time of the event.
This event is triggered whenever the mouse is moved while any button is pressed.
glutMotionFunc(motionCB); /* register motion callback */ void motionCB(int x, int y); /* motion callback function */
where x, y are the coordinates of the mouse cursor at the time of the event.
This event is triggered whenever the mouse is moved while no buttons are pressed.
glutPassiveMotionFunc(passiveCB); /* register passive callback */ void passiveCB(int x, int y); /* passive callback function */
where x, y are the coordinates of the mouse cursor at the time of the event.
The following function can be used to determine the state of the keyboard modifier keys Shift, Ctrl, and Alt.
int modifier; modifier = glutGetModifiers(); /* get keyboard modifier state */ if (modifier & GLUT_ACTIVE_SHIFT) ... /* Shift key pressed */ if (modifier & GLUT_ACTIVE_CTRL) ... /* Ctrl key pressed */ if (modifier & GLUT_ACTIVE_ALT) ... /* Alt key pressed */
On to input (keyboard)...
Back to animation...
Back to the 13.016 overview...