Buttons and keys of OpenGL / Glut

I myself study the book Pearson, Computer Graphics with OpenGL .

I'm currently trying to make a simple square, but before I get ahead of myself, I have to be sure that I understand which keys are built into Glut.

I know the following keys:

  • GLUT_KEY_F1, GLUT_KEY_F2, ..., GLUT_KEY_F12 - keys F1 - F12
  • GLUT_KEY_PAGE_UP, GLUT_KEY_PAGE_DOWN - up and down keys
  • GLUT_KEY_HOME, GLUT_KEY_END - Start and end keys
  • GLUT_KEY_LEFT, GLUT_KEY_RIGHT, GLUT_KEY_UP, GLUT_KEY_DOWN - Arrow Keys
  • GLUT_KEY_INSERT - Insert key

I either found them in my book, or here in Stackoverflow in another post.

But is there more? for example, for all the keys on the keyboard and mouse?

Thanks.

+4
source share
2 answers

glut divides the key on the keyboard into glutSpecialFunc w / c accepts special keys such as F1, F2 ..., NUMPADS, etc., and glutKeyboardFunc accepts all keys that can be represented by a character similar to the alphabet, numbers, ESC (27 in "ASCII"), ENTER (32 in "ASCII"), etc.

glutKeyboardFunc take char parameters that can be represented without using any '\' (backslash, for example '\ t', '\ n') before any character the rest are processed by glutSpecialFunc

+4
source

The keyboard has two sets of buttons: those that can be represented using ASCII code, and those that could not. those that can be represented in ASCII return 1 byte when pressed, those that cannot return two bytes, the first of which is NULL

glut abstractly is this, providing you with two sets of functions for handling keyboard events: one for handling standard standard ASCII buttons glutKeyboardFunc , the other for handling special double-byte buttons glutSpecialFunc

a special function has constants for regular keyboard buttons:

GLUT_KEY_F1 : 0x0001, GLUT_KEY_F2 : 0x0002, GLUT_KEY_F3 : 0x0003, GLUT_KEY_F4 : 0x0004, GLUT_KEY_F5 : 0x0005, GLUT_KEY_F6 : 0x0006, GLUT_KEY_F7 : 0x0007, GLUT_KEY_F8 : 0x0008, GLUT_KEY_F9 : 0x0009, GLUT_KEY_F10 : 0x000A, GLUT_KEY_F11 : 0x000B, GLUT_KEY_F12 : 0x000C, GLUT_KEY_LEFT : 0x0064, GLUT_KEY_UP : 0x0065, GLUT_KEY_RIGHT : 0x0066, GLUT_KEY_DOWN : 0x0067, GLUT_KEY_PAGE_UP : 0x0068, GLUT_KEY_PAGE_DOWN : 0x0069, GLUT_KEY_HOME : 0x006A, GLUT_KEY_END : 0x006B, GLUT_KEY_INSERT : 0x006C, GLUT_KEY_REPEAT_OFF : 0x0000, GLUT_KEY_REPEAT_ON : 0x0001, GLUT_KEY_REPEAT_DEFAULT : 0x0002.

mouse clicks can be handled with glutMouseFunc , and mouse button constants: GLUT_LEFT_BUTTON : 0x0000, GLUT_MIDDLE_BUTTON : 0x0001, GLUT_RIGHT_BUTTON : 0x0002

glut can also handle joysticks via glutJoystickFunc , which has the following constants: GLUT_HAS_JOYSTICK : 0x0264, GLUT_OWNS_JOYSTICK : 0x0265, GLUT_JOYSTICK_BUTTONS : 0x0266, GLUT_JOYSTICK_AXES : 0x0267, GLUT_JOYSTICK_POLL_RATE : 0x0268, GLUT_JOYSTICK_BUTTON_A : 0x0001, GLUT_JOYSTICK_BUTTON_B : 0x0002, GLUT_JOYSTICK_BUTTON_C : 0x0004, GLUT_JOYSTICK_BUTTON_D :. 0x0008

if you use a gaming mouse or keyboard / joystick with a large number of buttons, you can check what each button returns by calling a button on the console, and then directly use this value in your code to see if one of these buttons is pressed

+5
source

Source: https://habr.com/ru/post/1469542/


All Articles