gluLookAt creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector.
The matrix maps the reference point to the negative z axis and the eye point to the origin. When a typical projection matrix is used, the center of the scene therefore maps to the center of the viewport. Similarly, the direction described by the UP vector projected onto the viewing plane is mapped to the positive y axis so that it points upward in the viewport. The UP vector must not be parallel to the line of sight from the eye point to the reference point.
If gluLookAt() was not called, the camera has a default position and orientation. By default, the camera is situated at the origin, points down the negative z-axis, and has an up-vector of (0, 1, 0). So in Example 3-1, the overall effect is that gluLookAt() moves the camera 5 units along the z-axis. (See "Viewing and Modeling Transformations" for more information about viewing transformations.)
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_F10x0001
127 #define GLUT_KEY_F20x0002
128 #define GLUT_KEY_F30x0003
129 #define GLUT_KEY_F40x0004
130 #define GLUT_KEY_F50x0005
131 #define GLUT_KEY_F60x0006
132 #define GLUT_KEY_F70x0007
133 #define GLUT_KEY_F80x0008
134 #define GLUT_KEY_F90x0009
135 #define GLUT_KEY_F100x000A
136 #define GLUT_KEY_F110x000B
137 #define GLUT_KEY_F120x000C
138 #define GLUT_KEY_LEFT0x0064
139 #define GLUT_KEY_UP0x0065
140 #define GLUT_KEY_RIGHT0x0066
141 #define GLUT_KEY_DOWN0x0067
142 #define GLUT_KEY_PAGE_UP0x0068
143 #define GLUT_KEY_PAGE_DOWN0x0069
144 #define GLUT_KEY_HOME0x006A
145 #define GLUT_KEY_END0x006B
146 #define GLUT_KEY_INSERT0x006C
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 형으로 크기가 다르게 정의되어 있으니 주의요망!
어제 데이트 하고 들어가는데
길동사거리에서 버스가 신호를 기다리고 있었는데
"펑" 혹은 "쾅" 소리가 났는데
건물에서 먼지가 자욱하게 나고 있길래 읭? 건물이 붕괴된건가? 생각
버스가 사거리를 지나가고
그제서야 암사행 길을 보니 하얀색 차가 뒤집어져있고 먼지인지 연기인지가 폴폴폴..
운전자는 괜찮을까? 보다는 도대체 어떻게 사고가 난거지? 라는게 더 궁금한 케이스였는데
오늘 생각이 나서 검색을 해보니
결국에는 운전자는 사망이고, 처음에 났던 먼지(혹은 연기)는 신호등 쳐박은거였다.
아무튼 만약 그 차가 우회전 하다가 신호등을 쳐박은게 아니라 직진하다가 쳐박고
반대편 차선으로 날아왔더라면.. 그 차가 내가 타고 있던 버스로 날아왔더라면
어떻게 되었을까 라는 생각에 문득 섬칫해지는 아침....