OpenGLUT 0.6.3 development - OpenGLUT: Input Callbacks
Keywords: OpenGLUT, FreeGLUT, OpenGL, GLUT, X11, Windows, Programming, Documentation, Download, Development, Sourceforge

OpenGLUT Documentation
Introduction | Documentation | Examples | Proposals | Authors | Copying | Todo | Bugs | Links

# Input Callbacks
[OpenGLUT API Reference]

## Functions
void | glutButtonBoxFunc (void(*callback)(int button, int state))
void | glutDialsFunc (void(*callback)(int dial, int value))
void | glutEntryFunc (void(*callback)(int state))
void | glutForceJoystickFunc (void)
void | glutJoystickFunc (void(*callback)(unsigned int buttons, int xaxis, int yaxis, int zaxis), int pollInterval)
void | glutKeyboardFunc (void(*callback)(unsigned char key, int x, int y))
void | glutKeyboardUpFunc (void(*callback)(unsigned char key, int x, int y))
void | glutMotionFunc (void(*callback)(int x, int y))
void | glutMouseFunc (void(*callback)(int button, int state, int x, int y))
void | glutMouseWheelFunc (void(*callback)(int wheel, int direction, int x, int y))
void | glutPassiveMotionFunc (void(*callback)(int x, int y))
void | glutSpaceballButtonFunc (void(*callback)(int button, int state))
void | glutSpaceballMotionFunc (void(*callback)(int x, int y, int z))
void | glutSpaceballRotateFunc (void(*callback)(int x, int y, int z))
void | glutSpecialFunc (void(*callback)(int key, int x, int y))
void | glutSpecialUpFunc (void(*callback)(int key, int x, int y))
void | glutTabletButtonFunc (void(*callback)(int button, int state, int x, int y))
void | glutTabletMotionFunc (void(*callback)(int x, int y))

## Function Documentation

void glutButtonBoxFunc | ( | void(* | callback)(int button, int state) | ) |

  | Sets a button-box button callback. Parameters:
  | callback | Client buttonbox button hook.
A dials-and-buttons box has buttons numbered from 1 to glutDeviceGet(GLUT_NUM_BUTTON_BOX_BUTTONS), inclusive. The parameters callback are the button and its state as either GLUT_UP or GLUT_DOWN . The callback is bound to the current window. Note: OpenGLUT does not implement button-box support. Also in contrast, mouse buttons are numbered from 0 in the GLUT API. This is a wrinkle. See also: glutDialsFunc()

void glutDialsFunc | ( | void(* | callback)(int dial, int value) | ) |

  | Sets a dials-box button callback. Parameters:
  | callback | Client dials-box dial hook.
A dials-and-buttons box has dials numbered from 1 to glutDeviceGet(GLUT_NUM_BUTTON_BOX_DIALS), inclusive. The parameters to callback are the dial and its value the latter being an absolute rotation in degrees. The callback is bound to the current window. Note: OpenGLUT does not implement dials-box support. See also: glutButtonBoxFunc()

void glutEntryFunc | ( | void(* | callback)(int state) | ) |

  | Window mouse entry/leave callback. Parameters:
  | callback | Client window-entry hook.
When the mouse enters or exits a window (or sub-window), OpenGLUT can report this transition via the Entry callback. state is one of GLUT_LEFT or GLUT_ENTERED respective of whether the mouse left or entered the window. This callback is bound to the current window. See also: glutPassiveMotionFunc()

void glutForceJoystickFunc | ( | void |  | ) |

| Forces a joystick poll and callback. Forces the OpenGLUT joystick code to poll your joystick(s) and to call your joystick callbacks with the result. The operation completes, including callbacks, before glutForceJoystickFunc() returns. Bug: The original WINCE import used a #if to turn this function off. That is wrong. The proper way to handle the joystick code is to generate "null" events. The WINCE code needs to be fixed in og_joystick.c, not here. See also: glutJoystickFunc()

void glutJoystickFunc | ( | void(* | callback)(unsigned int buttons, int xaxis, int yaxis, int zaxis),
|  | int | pollInterval
| ) |

  | Reports joystick state for the current window. Parameters:
  | callback | Client function for joystick events
  | pollInterval | Approximate (minimum) millisecond interval
The callback is called roughly every pollinterval milliseconds, and will give the joystick status. The buttons bitmask is a bit-wise OR of: GLUT_JOYSTICK_BUTTON_A GLUT_JOYSTICK_BUTTON_B GLUT_JOYSTICK_BUTTON_C GLUT_JOYSTICK_BUTTON_D The axis values are in the range [-1000,1000].

void glutKeyboardFunc | ( | void(* | callback)(unsigned char key, int x, int y) | ) |

  | Sets the Keyboard callback for the current window. Parameters:
  | callback | Client function for keyboard event.
This callback registration allows you to handle traditional ASCII keyboard input. A general rule of thumb is that if a key has a common ASCII code, then OpenGLUT assigns that code to the key and calls the Keyboard callback with the ASCII code in the key parameter. For other keys, you must use glutSpecialFunc(). Not all keys can be reported by OpenGLUT. As a convenience, the mouse coordinates, relative to your window, are also returned. This callback is bound to the current window. Note: This function is not very international-friendly. Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. See also: glutKeyboardUpFunc(), glutSpecialFunc()

void glutKeyboardUpFunc | ( | void(* | callback)(unsigned char key, int x, int y) | ) |

  | Sets the keyboard key release callback for the current window. Parameters:
  | callback | Client hook for ASCII key releases.
This function provides a way to detect the release of a keyboard key. The keys are reported exactly as with glutKeyboardFunc(), save that the callback registered via this function is used to report the event. This callback is bound to the current window. Note: Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. See also: glutKeyboardFunc(), glutSpecialUpFunc()

void glutMotionFunc | ( | void(* | callback)(int x, int y) | ) |

  | Reports mouse-motion while a button is held. Parameters:
  | callback | Client hook for dragging mouse.
This function reports the mouse position when the mouse is dragged starting from within your window. (``Dragging'' occurs when you press one or more mouse buttons in one of your OpenGLUT windows, and then move the mouse around.) This callback is bound to the current window. Note: Events are reported until the mouse button is released, even if the mouse leaves the window. Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. See also: glutMouseFunc(), glutPassiveMotion()

void glutMouseFunc | ( | void(* | callback)(int button, int state, int x, int y) | ) |

  | Sets the mouse-button callback for the current window. Parameters:
  | callback | Client hook for mouse-buttons.
Whenever a mouse button is pressed or released in an OpenGLUT window, OpenGLUT checks if that window has a mouse-button (Mouse) callback registered. If so, OpenGLUT gives the event to the handler. button is the button number, starting from 0. state is GLUT_UP or GLUT_DOWN to indicate the button's new state. The other parameters are the mouse coordinates. Mouse wheel motion can be reported as buttons. If you do not request otherwise, a wheel spun forward will act like a button clicking down, immediately followed by clicking up. Spinning the same wheel backward will act like a different button clicking. Mouse wheel pseudo-buttons are added after all real buttons. While the button is held and the mouse is dragged, you receive mouse-motion events (glutMotionFunc()), even if the mouse is dragged out of the window. This callback is bound to the current window. Note: Reporting the wheel as buttons is actually inherited from X. freeglut added code to support this on WIN32. OpenGLUT inherited that support from freeglut. Old GLUT defines the symbols GLUT_LEFT_BUTTON, GLUT_RIGHT_BUTTON, and GLUT_MIDDLE_BUTTON. However, mice can have more than 3 buttons, so these symbols are deprecated. Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. See also: glutMotionFunc(), glutPassiveMotionFunc(), glutMouseWheelFunc()

void glutMouseWheelFunc | ( | void(* | callback)(int wheel, int direction, int x, int y) | ) |

  | Sets the mouse wheel callback for the current window. Parameters:
  | callback | Client hook for mouse wheel events.
If the mouse wheel is spun over your (sub)window, OpenGLUT will, in theory, report this via the MouseWheel callback. wheel is the wheel number, direction is +/- 1, and x and y are the mouse coordinates. If you do not register a wheel callback, wheel events will be reported as mouse buttons. This callback is bound to the current window. Note: Due to lack of information about the mouse, it is impossible to implement this correctly on X at this time. Use of this function limits the portability of your application. (This feature does work on X, just not reliably.) You are encouraged to use the standard, reliable mouse-button reporting, rather than wheel events. Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. See also: glutMouseFunc()

void glutPassiveMotionFunc | ( | void(* | callback)(int x, int y) | ) |

  | Sets the non-dragging (gliding?) mouse-motion callback. Parameters:
  | callback | Client mouse-glide hook.
If you set this callback on a window, then every time that OpenGLUT detects a change in the mouse position inside that window, with no buttons pressed on that mouse, OpenGLUT will invoke callback with the window coordinates of the mouse. This callback is bound to the current window. Note: Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. See also: glutMotionFunc(), glutMouseFunc(), glutEntryFunc()

void glutSpaceballButtonFunc | ( | void(* | callback)(int button, int state) | ) |

  | Sets a spaceball button callback. Parameters:
  | callback | Client spaceball button hook.
This function registers a callback for a spaceball to report buttons. A spaceball has six axes of freedom (three of motion and three of orientation), plus buttons. The spaceball has glutDeviceGet(GLUT_NUM_SPACEBALL_BUTTONS) and numbers them from 1. Button state is either GLUT_UP or GLUT_DOWN. The callback is bound to the current window. Note: OpenGLUT does not implement spaceball support. In contrast, mouse buttons are numbered from 0 in the GLUT API. This is a wrinkle. See also: glutSpaceballRotateFunc(), glutSpaceballMotiononFunc(),

void glutSpaceballMotionFunc | ( | void(* | callback)(int x, int y, int z) | ) |

  | Sets a spaceball motion callback. Parameters:
  | callback | Client spaceball motion hook.
This function registers a callback for a spaceball to report position. A spaceball has six axes of freedom (three of motion and three of orientation), plus buttons. The spaceball allows you to move a control point in 3D space with a resolution of +/- 1000 units along each of 3 axes. The callback is bound to the current window. Note: OpenGLUT does not implement spaceball support. See also: glutSpaceballRotateFunc(), glutSpaceballButtonFunc(),

void glutSpaceballRotateFunc | ( | void(* | callback)(int x, int y, int z) | ) |

  | Sets a spaceball rotation callback. Parameters:
  | callback | Client spaceball rotation hook.
This function registers a callback for a spaceball to report rotation. A spaceball has six axes of freedom (three of motion and three of orientation), plus buttons. The spaceball allows you to rotate a control orientation +/- 1800 units about each of 3 axes. The callback is bound to the current window. Note: OpenGLUT does not implement spaceball support. See also: glutSpaceballMotionFunc(), glutSpaceballButtonFunc(),

void glutSpecialFunc | ( | void(* | callback)(int key, int x, int y) | ) |

  | Sets the Special callback for the current window. Parameters:
  | callback | Client function for keyboard event.
Registers a callback for OpenGLUT to call when the user presses "special" keys on the keyboard. The special callback handles some additional keys that are not covered under plain "keyboard" events. The key that is passed to the callback is one of an enumerated set. The association to keys on your keyboard should be obvious. Their GLUT symbol names are: GLUT_KEY_F1 GLUT_KEY_F2 GLUT_KEY_F3 GLUT_KEY_F4 GLUT_KEY_F5 GLUT_KEY_F6 GLUT_KEY_F7 GLUT_KEY_F8 GLUT_KEY_F9 GLUT_KEY_F10 GLUT_KEY_F11 GLUT_KEY_F12 GLUT_KEY_LEFT GLUT_KEY_UP GLUT_KEY_RIGHT GLUT_KEY_DOWN GLUT_KEY_PAGE_UP GLUT_KEY_PAGE_DOWN GLUT_KEY_HOME GLUT_KEY_END GLUT_KEY_INSERT To receive other keys, see glutKeyboardFunc(). This callback is bound to the current window. Note: Many keys are not included; nor is it possible to apply qualifiers such as the Shift or Ctrl key to these keys. Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. See also: glutSpecialUpFunc(), glutKeyboardFunc()

void glutSpecialUpFunc | ( | void(* | callback)(int key, int x, int y) | ) |

  | Sets the special key release callback for the current window. Parameters:
  | callback | Client hook for special key releases.
This function provides a way to detect the release of a keyboard key. The keys are reported exactly as with glutSpecialFunc(), save that the callback registered via this function is used to report the event. This callback is bound to the current window. Note: Windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. See also: glutSpecialFunc(), glutKeyboardUpFunc()

void glutTabletButtonFunc | ( | void(* | callback)(int button, int state, int x, int y) | ) |

  | Sets a tablet button callback. Parameters:
  | callback | Client tablet button hook.
This function registers a callback by which you receive reports a tablet button status feature. Buttons are reported with button in the range 1 to glutDeviceGet(GLUT_NUM_TABLET_BUTTONS). state is either GLUT_UP or GLUT_DOWN and x and y are the tablet coordinate (see glutTabletMotionFunc() for the bounds of x and y). The callback is bound to the current window. Note: OpenGLUT does not implement tablet support. Todo: We might want to add support for this sooner or later. Although a tablet could also be generalized as a mouse. There are relatively cheap AipTek HyperPen tablets, and slightly less cheap Wacom tablets on many store shelves. Note: Buttons are not pressure-sensitive. See also: glutTabletButtonFunc(), glutMouseFunc()

void glutTabletMotionFunc | ( | void(* | callback)(int x, int y) | ) |

  | Sets a tablet motion callback. Parameters:
  | callback | Client tablet motion hook.
This function registers a callback by which OpenGLUT reports a puck or stylus position in the range of [0, 2000] along the x and y axes. The callback is bound to the current window. Note: OpenGLUT does not implement tablet support. Todo: We might want to add support for this sooner or later. Although a tablet could also be generalized as a mouse. There are relatively cheap AipTek HyperPen tablets, and slightly less cheap Wacom tablets on many store shelves. Note: This API does not include tilt information. See also: glutTabletButtonFunc(), glutMouseFunc()

OpenGLUT Development @ Sourceforge
Homepage | Summary | Files | CVS | Forums | Lists | Bugs | RFE
Generated on Tue Oct 5 18:44:33 2004 for OpenGLUT by doxygen 1.3.8
The OpenGLUT project is hosted by sourceforge.net.