glutKeyboard()

Does somebody know how to call glutKeyboard()function? Many thanks!

Here is a example code:
// put in main routine before glutMainLoop()
glutKeyboardFunc( keyboard );

// My keyboard routine from one of my programs.
void keyboard (unsigned char key, int x, int y)
{
// key variable has the key pressed

switch (key)
{
case ‘W’:
wire_cube_rotate = abs( wire_cube_rotate - 1); // Toggle rotate on off.
break;
case ‘S’:
solid_cube_rotate = abs( solid_cube_rotate - 1); // Toggle rotate on off.
object_move = 1;
move_x = solid_cube_x;
move_y = solid_cube_y;
break;
case ‘C’:
solid_cone_rotate = abs( solid_cone_rotate - 1); // Toggle rotate on off.
object_move = 2;
move_x = solid_cone_x;
move_y = solid_cone_y;
break;
case ‘L’:
light_state = abs(light_state - 1);
break;
case ‘E’:
cylinder_state = abs(cylinder_state - 1);
break;
case ‘V’:
view_state = abs(view_state - 1);
break;
case 27:
exit(0); // exit program when [ESC] key presseed
break;
default:
break;
}

}

Originally posted by huizhang:
Does somebody know how to call glutKeyboard()function? Many thanks!