출처: http://www.lighthouse3d.com/opengl/glut/
...(중략)
OK, ready to move on? Lets tackle the special keys now. GLUT provides the function glutSpecialFunc so that you can register your function for special key events processing. The syntax for this function is as follows:
void glutSpecialFunc(void (*func) (int key, int x, int y));
Parameters:
We're going to write a function that changes the color of our triangle when some of the special keys are pressed. This function will paint the triangle using red if F1 is pressed, green if F2 is pressed, and blue if F3 is pressed.
The GLUT_KEY_* are predefined constants in glut.h. The full set of constants is presented next:
...(중략)
OK, ready to move on? Lets tackle the special keys now. GLUT provides the function glutSpecialFunc so that you can register your function for special key events processing. The syntax for this function is as follows:
void glutSpecialFunc(void (*func) (int key, int x, int y));
Parameters:
- func - The name of the function that will process the special keyboard events. Passing NULL as an argument causes GLUT to ignore the special keys.
We're going to write a function that changes the color of our triangle when some of the special keys are pressed. This function will paint the triangle using red if F1 is pressed, green if F2 is pressed, and blue if F3 is pressed.
void processSpecialKeys(int key, int x, int y) {
switch(key) {
case GLUT_KEY_F1 :
red = 1.0;
green = 0.0;
blue = 0.0; break;
case GLUT_KEY_F2 :
red = 0.0;
green = 1.0;
blue = 0.0; break;
case GLUT_KEY_F3 :
red = 0.0;
green = 0.0;
blue = 1.0; break;
}
}
The GLUT_KEY_* are predefined constants in glut.h. The full set of constants is presented next:
GLUT_KEY_F1 F1 function key
GLUT_KEY_F2 F2 function key
GLUT_KEY_F3 F3 function key
GLUT_KEY_F4 F4 function key
GLUT_KEY_F5 F5 function key
GLUT_KEY_F6 F6 function key
GLUT_KEY_F7 F7 function key
GLUT_KEY_F8 F8 function key
GLUT_KEY_F9 F9 function key
GLUT_KEY_F10 F10 function key
GLUT_KEY_F11 F11 function key
GLUT_KEY_F12 F12 function key
GLUT_KEY_LEFT Left function key
GLUT_KEY_RIGHT Up function key
GLUT_KEY_UP Right function key
GLUT_KEY_DOWN Down function key
GLUT_KEY_PAGE_UP Page Up function key
GLUT_KEY_PAGE_DOWN Page Down function key
GLUT_KEY_HOME Home function key
GLUT_KEY_END End function key
GLUT_KEY_INSERT Insert function key
...
'그래픽스 관련' 카테고리의 다른 글
기초상식. NTSC와 PAL. (네이버지식IN) (0) | 2009.10.30 |
---|---|
(GLUT)마우스모션처리 함수에서 파라미터로 받아온 좌표 변환하기. (0) | 2009.10.15 |
Shear matrix (0) | 2009.09.19 |
(OpenGL) 간단한 코드(일부만 제시)와 부연 설명 (0) | 2009.09.11 |
Image plane 이란? (0) | 2009.09.10 |