== Anti aliasing ===
glEnable(GL_LINE_SMOOTH) 은 anti-aliasing을 설정하고
glDisable(GL_LINE_SMOOTH)은 anti-aliasing을 해제한다.
glGetBooleanv(GL_LINE_SMOOTH)로 값을 얻어낼수 있음
기본값으로 출력한 화면
glEnable(GL_LINE_SMOOTH)를 적용하고 출력한 화면
GL_LINE_SMOOTH
If enabled, draw lines with correct filtering. Otherwise, draw aliased lines. See glLineWidth.
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 형으로 크기가 다르게 정의되어 있으니 주의요망!
GLUT의 키보드 관련 콜백함수는 두가지가 존재한다.
glutkeyboardFunc()
glutspecialFunc()
glutkeyboardFunc()는 일반적인 아스키 값들을 받아 들인다면
glutspecialFunc()는 F1~F12 / PgUp / PgDn / Home / End / Insert 를 받아들인다.
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;
}
}