'glutspecialFunc'에 해당되는 글 2건

  1. 2011.10.02 GLUT 키보드 콜백 함수 총정....리? 2
  2. 2011.09.27 GLUT keyboard callback function
Programming/openGL2011. 10. 2. 21:12
void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y));
void glutSpecialFunc(void (*func)(int key, int x, int y));

int x, int y 에는 윈도우의 마우스 좌표가 출력되며
glutSpecialFunc는 F1~F12 / 화살표 / PgUp / PgDn / Home / End / Insert 에 대한 입력을 받고
glutKeyboardFunc 는 그 외에 모든 키보드 입력을 받는다.

glutSpecialFunc 관련해서는 아래의 파일에 정의가 되어있고, 샘플용 콜백함수도 같이 투척!
$ vi /usr/include/GL/freeglut_std.h
124  * GLUT API macro definitions -- the special key codes:
125  */
126 #define  GLUT_KEY_F1                        0x0001
127 #define  GLUT_KEY_F2                        0x0002
128 #define  GLUT_KEY_F3                        0x0003
129 #define  GLUT_KEY_F4                        0x0004
130 #define  GLUT_KEY_F5                        0x0005
131 #define  GLUT_KEY_F6                        0x0006
132 #define  GLUT_KEY_F7                        0x0007
133 #define  GLUT_KEY_F8                        0x0008
134 #define  GLUT_KEY_F9                        0x0009
135 #define  GLUT_KEY_F10                       0x000A
136 #define  GLUT_KEY_F11                       0x000B
137 #define  GLUT_KEY_F12                       0x000C
138 #define  GLUT_KEY_LEFT                      0x0064
139 #define  GLUT_KEY_UP                        0x0065
140 #define  GLUT_KEY_RIGHT                     0x0066
141 #define  GLUT_KEY_DOWN                      0x0067
142 #define  GLUT_KEY_PAGE_UP                   0x0068
143 #define  GLUT_KEY_PAGE_DOWN                 0x0069
144 #define  GLUT_KEY_HOME                      0x006A
145 #define  GLUT_KEY_END                       0x006B
146 #define  GLUT_KEY_INSERT                    0x006C 

void keyboard_spe(int key, int x, int y)
{
    switch (key)
    {
        case GLUT_KEY_F1:
        case GLUT_KEY_F2:
        case GLUT_KEY_F3:
        case GLUT_KEY_F4:
        case GLUT_KEY_F5:
        case GLUT_KEY_F6:
        case GLUT_KEY_F7:
        case GLUT_KEY_F8:
        case GLUT_KEY_F9:
        case GLUT_KEY_F10:
        case GLUT_KEY_F11:
        case GLUT_KEY_F12:
            break;
        case GLUT_KEY_LEFT:
        case GLUT_KEY_RIGHT:
        case GLUT_KEY_UP:
        case GLUT_KEY_DOWN:
            break;
        case GLUT_KEY_PAGE_UP:
        case GLUT_KEY_PAGE_DOWN:
            break;
        case GLUT_KEY_HOME:
        case GLUT_KEY_END:
        case GLUT_KEY_INSERT:
            break;

        default:
           break;
    }
}

void keyboard(unsigned char key, int x, int y)
{
    switch (key)
    {
      default:
          break;
    }
}

void main()
{
  // ...
  glutKeyboardFunc(keyboard);
  glutSpecialFunc(keyboard_spe);
  // ...
}

연유는 모르겠으나,
glutSpecialFunc()와 glutKeyboardFunc() 의 key는 char와 int 형으로 크기가 다르게 정의되어 있으니 주의요망!

2011/09/27 - [Programming/openGL] - GLUT keyboard callback function
2011/03/28 - [Programming/openGL] - openGL callback function - GLUT 키보드 / 마우스 입력

'Programming > openGL' 카테고리의 다른 글

glutTimerFunc()  (0) 2011.10.05
gluLookAt() 의 기본값  (0) 2011.10.02
GLUI  (0) 2011.09.30
glEnable() / glDisable()  (0) 2011.09.30
glGet()  (0) 2011.09.30
Posted by 구차니
Programming/openGL2011. 9. 27. 22:58
GLUT의 키보드 관련 콜백함수는 두가지가 존재한다.
glutkeyboardFunc()
glutspecialFunc()

glutkeyboardFunc()는 일반적인 아스키 값들을 받아 들인다면
glutspecialFunc()는 F1~F12 / PgUp / PgDn / Home / End / Insert 를 받아들인다.


[링크 : http://www.opengl.org/resources/libraries/glut/spec3/node49.htmlglutkeyboardFunc() 
[링크 : http://www.opengl.org/resources/libraries/glut/spec3/node54.htmlglutspecialFunc()
[링크 : http://freeglut.sourceforge.net/docs/api.php]

2011/03/28 - [Programming/openGL] - openGL callback function - GLUT 키보드 / 마우스 입력

'Programming > openGL' 카테고리의 다른 글

glGet()  (0) 2011.09.30
glGet() 함수 이용하기  (0) 2011.09.28
openGL로 싸인곡선 그리기(sin wave)  (5) 2011.09.25
webGL  (0) 2011.09.24
depth buffer  (0) 2011.09.02
Posted by 구차니