The registration callback function of OpenGL
void Glutdisplayfunc (void (*func) (void));
Displays the callback function for the current window setting
void Glutoverlaydisplayfunc (void (*func) (void));
Registers the display callback function of the overlapping layer of the current window
void Glutreshapefunc (void (*func) (int width, int height));
Specifies the function that is called when the size of the window changes
void Glutkeyboardfunc (void (*func) (unsigned char key, int x, int y));
Registers the keyboard callback function for the current window
void Glutmousefunc (void (*func) (int button, int state, int x, int y));
Registers the mouse callback function for the current window
Func is a registered mouse callback function that completes the handling of mouse events
button is the button for the mouse, the constant defined for the following
Glut_left_button |
Left mouse button |
Glut_middle_button |
Middle mouse button |
Glut_right_button |
right mouse button |
State is the action of the mouse button, the constants defined below
Glut_up |
Mouse Release |
Glut_down |
mouse button down |
X, y is the mouse down, and the cursor is positioned relative to the upper-left corner of the window
void Glutmotionfunc (void (*func) (int x, int y));
void Glutpassivemotionfunc (void (*func) (int x, int y));
Set the move callback function, set the current mouse movement function
Func is a registered mouse move function
X, y is the mouse down, and the cursor is positioned relative to the upper-left corner of the window
Call the Glutmotionfunc registered callback function when the mouse is pressed and moved in the window
Call the Glutpassivemotionfunc registered callback function when the mouse moves through the window
void Glutvisibilityfunc (void (*func) (int state));
Sets the visual callback function for the current window
Func for the specified visual callback function
State represents the visibility of the window for the following constants:
Glut_not_visible |
Window is completely invisible |
Glut_visible |
window visible or partially visible |
This function sets the visual callback function of the current window, and when the window's visibility changes, the window's visual callback function is called. As long as any one of the pixels in the window is visible, or any one of his child windows is visible, glut thinks the window is visible.
void Glutentryfunc (void (*func) (int state));
Set a callback function for the mouse to enter and exit the window
Func is a registered mouse in and out of the callback function
State is in and out of the mouse, and is one of the following constants:
Glut_left |
Mouse Out of window |
Glut_right |
Mouse into the window |
This function is called when the window gets focus or loses focus, when the mouse enters the window area and clicks, the state is Glut_right, and the state is glut_left when the mouse leaves the window area and clicks another window.
void Glutspecialfunc (void (*func) (int key, int x, int y))
Sets the callback function for the specific key of the current window
Func is a callback function that registers a specific key
Key is a specific key that is pressed, as defined by the following constants:
Key constant |
Describe |
Glut_key_f1 |
F1 function keys |
Glut_key_f2 |
F2 function keys |
Glut_key_f3 |
F3 function keys |
Glut_key_f4 |
F4 function keys |
Glut_key_f5 |
F5 function keys |
Glut_key_f6 |
F6 function keys |
Glut_key_f7 |
F7 function keys |
Glut_key_f8 |
F8 function keys |
Glut_key_f9 |
F9 function keys |
Glut_key_f10 |
F10 function keys |
Glut_key_f11 |
F11 function keys |
Glut_key_f12 |
F12 function keys |
Glut_key_left |
Left ARROW key |
Glut_key_up |
Up ARROW key |
Glut_key_right |
Right ARROW key |
Glut_key_down |
Down ARROW key |
Glut_key_page_up |
PageUp Key |
Glut_key_page_down |
PageDown key |
Glut_key_home |
Home key |
Glut_key_end |
End key |
Glut_key_insert |
Insert key |
X, y is the coordinates of the mouse when the key is pressed, relative to the upper-left corner of the window, in pixels
Note: The ESC, enter, and delete keys are generated by the ASCII code.
void Glutmenustatusfunc (void (*func) (int status, int x, int y));
Set menu State callback function
Func is a registered menu-state callback function
Status is whether the menu is currently used, the constants defined for the following
Glut_menu_in_use |
menu is in use |
Glut_menu_not_in_use |
Menu not being used |
X, y is the mouse-down style, where the cursor is relative to the upper-left corner of the window
This function when the GLUT program determines whether the menu is being used, when the popup menu, call the Registered menu state callback function, while the status is set to constant Glut_menu_in_use, when the menu is finished, also call the menu state callback function, the status variable becomes glut _menu_not_in_use. Menus that pop up from the popup menu do not produce a menu-state callback procedure. Each GLUT program has only one menu-state callback function.
Glutspaceballrotatefunc
Glutspaceballbuttonfunc
Glutbuttonboxfunc
Glutdialsfunc
Gluttabletmotionfunc
Gluttabletbuttonfunc
void Glutmenustatusfunc (void (*func) (int status, int x, int y));
Set menu State callback function
Func is a registered menu-state callback function
Status indicates whether menus are currently used, constants defined for the following
Glut_menu_in_use |
menu is in use |
Glut_menu_not_in_use |
Menu not being used |
X, y indicates the mouse is pressed and the cursor is positioned relative to the upper-left corner of the window
This function when the GLUT program determines whether the menu is being used, when the popup menu, call the Registered menu state callback function, while the status is set to constant Glut_menu_in_use, when the menu is finished, also call the menu state callback function, the status variable becomes glut _menu_not_in_use. Menus that pop up from the popup menu do not produce a menu-state callback procedure. Each GLUT program has only one menu-state callback function.
void Glutidlefunc (void (*func) (void));
Set the idle callback function
Func represents a function that is called when the system is idle, in the form of void func (void)
void Gluttimerfunc (unsigned int msecs, void (*func) (int value), int value);
Registers a callback function that is called by glut once the specified time value arrives
Msecs is the time to wait
Func is a registered function
Value is a specified numeric value that is used to pass into the callback function func
This function registers a callback function that invokes the registered function when the specified number of milliseconds arrives, and the value parameter is used to pass parameters to the registered function.
Go to: http://blog.csdn.net/augusdi/article/details/7076760
OpenGL GLUT Registration callback function [GO]