Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * GL_ARB_texture_cube_map demo |
| 3 | * |
| 4 | * Brian Paul |
| 5 | * May 2000 |
| 6 | * |
| 7 | * |
| 8 | * Copyright (C) 2000 Brian Paul All Rights Reserved. |
| 9 | * |
| 10 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 11 | * copy of this software and associated documentation files (the "Software"), |
| 12 | * to deal in the Software without restriction, including without limitation |
| 13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 14 | * and/or sell copies of the Software, and to permit persons to whom the |
| 15 | * Software is furnished to do so, subject to the following conditions: |
| 16 | * |
| 17 | * The above copyright notice and this permission notice shall be included |
| 18 | * in all copies or substantial portions of the Software. |
| 19 | * |
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 23 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 24 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 25 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | /* |
| 30 | * This is a pretty minimalistic demo for now. Eventually, use some |
| 31 | * interesting cube map textures and 3D objects. |
| 32 | * For now, we use 6 checkerboard "walls" and a sphere (good for |
| 33 | * verification purposes). |
| 34 | */ |
| 35 | |
| 36 | |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 37 | #include <assert.h> |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 38 | #include <math.h> |
Brian Paul | 02e8a03 | 2000-06-27 17:04:43 +0000 | [diff] [blame] | 39 | #include <stdio.h> |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 40 | #include <stdlib.h> |
| 41 | #include <string.h> |
| 42 | #include "GL/glut.h" |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 43 | #include "../util/readtex.c" /* a hack */ |
| 44 | |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 45 | |
| 46 | static GLfloat Xrot = 0, Yrot = 0; |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 47 | static GLfloat EyeDist = 10; |
| 48 | |
| 49 | |
| 50 | static void draw_skybox( void ) |
| 51 | { |
| 52 | const GLfloat eps1 = 0.99; |
| 53 | const GLfloat br = 20.0; /* box radius */ |
| 54 | |
| 55 | glBegin(GL_QUADS); |
| 56 | |
| 57 | /* +X side */ |
| 58 | glTexCoord3f(1.0, -eps1, -eps1); glVertex3f(br, -br, -br); |
| 59 | glTexCoord3f(1.0, -eps1, eps1); glVertex3f(br, -br, br); |
| 60 | glTexCoord3f(1.0, eps1, eps1); glVertex3f(br, br, br); |
| 61 | glTexCoord3f(1.0, eps1, -eps1); glVertex3f(br, br, -br); |
| 62 | |
| 63 | /* -X side */ |
| 64 | glTexCoord3f(-1.0, eps1, -eps1); glVertex3f(-br, br, -br); |
| 65 | glTexCoord3f(-1.0, eps1, eps1); glVertex3f(-br, br, br); |
| 66 | glTexCoord3f(-1.0, -eps1, eps1); glVertex3f(-br, -br, br); |
| 67 | glTexCoord3f(-1.0, -eps1, -eps1); glVertex3f(-br, -br, -br); |
| 68 | |
| 69 | /* +Y side */ |
| 70 | glTexCoord3f(-eps1, 1.0, -eps1); glVertex3f(-br, br, -br); |
| 71 | glTexCoord3f(-eps1, 1.0, eps1); glVertex3f(-br, br, br); |
| 72 | glTexCoord3f( eps1, 1.0, eps1); glVertex3f( br, br, br); |
| 73 | glTexCoord3f( eps1, 1.0, -eps1); glVertex3f( br, br, -br); |
| 74 | |
| 75 | /* -Y side */ |
| 76 | glTexCoord3f(-eps1, -1.0, -eps1); glVertex3f(-br, -br, -br); |
| 77 | glTexCoord3f(-eps1, -1.0, eps1); glVertex3f(-br, -br, br); |
| 78 | glTexCoord3f( eps1, -1.0, eps1); glVertex3f( br, -br, br); |
| 79 | glTexCoord3f( eps1, -1.0, -eps1); glVertex3f( br, -br, -br); |
| 80 | |
| 81 | /* +Z side */ |
| 82 | glTexCoord3f( eps1, -eps1, 1.0); glVertex3f( br, -br, br); |
| 83 | glTexCoord3f(-eps1, -eps1, 1.0); glVertex3f(-br, -br, br); |
| 84 | glTexCoord3f(-eps1, eps1, 1.0); glVertex3f(-br, br, br); |
| 85 | glTexCoord3f( eps1, eps1, 1.0); glVertex3f( br, br, br); |
| 86 | |
| 87 | /* -Z side */ |
| 88 | glTexCoord3f( eps1, eps1, -1.0); glVertex3f( br, br, -br); |
| 89 | glTexCoord3f(-eps1, eps1, -1.0); glVertex3f(-br, br, -br); |
| 90 | glTexCoord3f(-eps1, -eps1, -1.0); glVertex3f(-br, -br, -br); |
| 91 | glTexCoord3f( eps1, -eps1, -1.0); glVertex3f( br, -br, -br); |
| 92 | |
| 93 | glEnd(); |
| 94 | } |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 95 | |
| 96 | |
| 97 | static void draw( void ) |
| 98 | { |
| 99 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 100 | |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 101 | glPushMatrix(); /*MODELVIEW*/ |
| 102 | glTranslatef( 0.0, 0.0, -EyeDist ); |
| 103 | |
| 104 | /* skybox */ |
| 105 | glDisable(GL_TEXTURE_GEN_S); |
| 106 | glDisable(GL_TEXTURE_GEN_T); |
| 107 | glDisable(GL_TEXTURE_GEN_R); |
| 108 | |
| 109 | glMatrixMode(GL_MODELVIEW); |
| 110 | glPushMatrix(); |
| 111 | glRotatef(Xrot, 1, 0, 0); |
| 112 | glRotatef(Yrot, 0, 1, 0); |
| 113 | draw_skybox(); |
| 114 | glPopMatrix(); |
| 115 | |
| 116 | /* sphere */ |
| 117 | glMatrixMode(GL_TEXTURE); |
| 118 | glLoadIdentity(); |
| 119 | glRotatef(-Yrot, 0, 1, 0); |
| 120 | glRotatef(-Xrot, 1, 0, 0); |
| 121 | |
| 122 | glEnable(GL_TEXTURE_GEN_S); |
| 123 | glEnable(GL_TEXTURE_GEN_T); |
| 124 | glEnable(GL_TEXTURE_GEN_R); |
| 125 | glutSolidSphere(2.0, 20, 20); |
| 126 | |
| 127 | glLoadIdentity(); /* texture */ |
| 128 | |
| 129 | glMatrixMode(GL_MODELVIEW); |
| 130 | glPopMatrix(); |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 131 | |
| 132 | glutSwapBuffers(); |
| 133 | } |
| 134 | |
| 135 | |
| 136 | static void idle(void) |
| 137 | { |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 138 | GLfloat t = 0.05 * glutGet(GLUT_ELAPSED_TIME); |
| 139 | Yrot = t; |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 140 | glutPostRedisplay(); |
| 141 | } |
| 142 | |
| 143 | |
| 144 | static void set_mode(GLuint mode) |
| 145 | { |
| 146 | if (mode == 0) { |
| 147 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB); |
| 148 | glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB); |
| 149 | glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB); |
| 150 | printf("GL_REFLECTION_MAP_ARB mode\n"); |
| 151 | } |
| 152 | else if (mode == 1) { |
| 153 | glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB); |
| 154 | glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB); |
| 155 | glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB); |
| 156 | printf("GL_NORMAL_MAP_ARB mode\n"); |
| 157 | } |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | |
| 161 | static void key(unsigned char k, int x, int y) |
| 162 | { |
| 163 | static GLboolean anim = GL_TRUE; |
| 164 | static GLuint mode = 0; |
| 165 | (void) x; |
| 166 | (void) y; |
| 167 | switch (k) { |
| 168 | case ' ': |
| 169 | anim = !anim; |
| 170 | if (anim) |
| 171 | glutIdleFunc(idle); |
| 172 | else |
| 173 | glutIdleFunc(NULL); |
| 174 | break; |
| 175 | case 'm': |
| 176 | mode = !mode; |
| 177 | set_mode(mode); |
| 178 | break; |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 179 | case 'z': |
| 180 | EyeDist -= 0.5; |
| 181 | if (EyeDist < 6.0) |
| 182 | EyeDist = 6.0; |
| 183 | break; |
| 184 | case 'Z': |
| 185 | EyeDist += 0.5; |
| 186 | if (EyeDist > 90.0) |
| 187 | EyeDist = 90; |
| 188 | break; |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 189 | case 27: |
| 190 | exit(0); |
| 191 | } |
| 192 | glutPostRedisplay(); |
| 193 | } |
| 194 | |
| 195 | |
| 196 | static void specialkey(int key, int x, int y) |
| 197 | { |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 198 | GLfloat step = 5; |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 199 | (void) x; |
| 200 | (void) y; |
| 201 | switch (key) { |
| 202 | case GLUT_KEY_UP: |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 203 | Xrot += step; |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 204 | break; |
| 205 | case GLUT_KEY_DOWN: |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 206 | Xrot -= step; |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 207 | break; |
| 208 | case GLUT_KEY_LEFT: |
| 209 | Yrot -= step; |
| 210 | break; |
| 211 | case GLUT_KEY_RIGHT: |
| 212 | Yrot += step; |
| 213 | break; |
| 214 | } |
| 215 | glutPostRedisplay(); |
| 216 | } |
| 217 | |
| 218 | |
| 219 | /* new window size or exposure */ |
| 220 | static void reshape(int width, int height) |
| 221 | { |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 222 | GLfloat ar = (float) width / (float) height; |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 223 | glViewport(0, 0, (GLint)width, (GLint)height); |
| 224 | glMatrixMode(GL_PROJECTION); |
| 225 | glLoadIdentity(); |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 226 | glFrustum( -2.0*ar, 2.0*ar, -2.0, 2.0, 4.0, 100.0 ); |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 227 | glMatrixMode(GL_MODELVIEW); |
| 228 | glLoadIdentity(); |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 232 | static void init_checkers( void ) |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 233 | { |
| 234 | #define CUBE_TEX_SIZE 64 |
| 235 | GLubyte image[CUBE_TEX_SIZE][CUBE_TEX_SIZE][3]; |
| 236 | static const GLubyte colors[6][3] = { |
| 237 | { 255, 0, 0 }, |
| 238 | { 0, 255, 255 }, |
| 239 | { 0, 255, 0 }, |
| 240 | { 255, 0, 255 }, |
| 241 | { 0, 0, 255 }, |
| 242 | { 255, 255, 0 } |
| 243 | }; |
| 244 | static const GLenum targets[6] = { |
| 245 | GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, |
| 246 | GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, |
| 247 | GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, |
| 248 | GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, |
| 249 | GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, |
| 250 | GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB |
| 251 | }; |
| 252 | |
| 253 | GLint i, j, f; |
| 254 | |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 255 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 256 | |
| 257 | /* make colored checkerboard cube faces */ |
| 258 | for (f = 0; f < 6; f++) { |
| 259 | for (i = 0; i < CUBE_TEX_SIZE; i++) { |
| 260 | for (j = 0; j < CUBE_TEX_SIZE; j++) { |
| 261 | if ((i/4 + j/4) & 1) { |
| 262 | image[i][j][0] = colors[f][0]; |
| 263 | image[i][j][1] = colors[f][1]; |
| 264 | image[i][j][2] = colors[f][2]; |
| 265 | } |
| 266 | else { |
| 267 | image[i][j][0] = 255; |
| 268 | image[i][j][1] = 255; |
| 269 | image[i][j][2] = 255; |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | glTexImage2D(targets[f], 0, GL_RGB, CUBE_TEX_SIZE, CUBE_TEX_SIZE, 0, |
| 275 | GL_RGB, GL_UNSIGNED_BYTE, image); |
| 276 | } |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 277 | } |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 278 | |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 279 | |
| 280 | static void load(GLenum target, const char *filename, |
| 281 | GLboolean flipTB, GLboolean flipLR) |
| 282 | { |
| 283 | GLint w, h; |
| 284 | GLenum format; |
| 285 | GLubyte *img = LoadRGBImage( filename, &w, &h, &format ); |
| 286 | if (!img) { |
| 287 | printf("Error: couldn't load texture image %s\n", filename); |
| 288 | exit(1); |
| 289 | } |
| 290 | assert(format == GL_RGB); |
| 291 | |
| 292 | /* <sigh> the way the texture cube mapping works, we have to flip |
| 293 | * images to make things look right. |
| 294 | */ |
| 295 | if (flipTB) { |
| 296 | const int stride = 3 * w; |
| 297 | GLubyte temp[3*1024]; |
| 298 | int i; |
| 299 | for (i = 0; i < h / 2; i++) { |
| 300 | memcpy(temp, img + i * stride, stride); |
| 301 | memcpy(img + i * stride, img + (h - i - 1) * stride, stride); |
| 302 | memcpy(img + (h - i - 1) * stride, temp, stride); |
| 303 | } |
| 304 | } |
| 305 | if (flipLR) { |
| 306 | const int stride = 3 * w; |
| 307 | GLubyte temp[3]; |
| 308 | GLubyte *row; |
| 309 | int i, j; |
| 310 | for (i = 0; i < h; i++) { |
| 311 | row = img + i * stride; |
| 312 | for (j = 0; j < w / 2; j++) { |
| 313 | int k = w - j - 1; |
| 314 | temp[0] = row[j*3+0]; |
| 315 | temp[1] = row[j*3+1]; |
| 316 | temp[2] = row[j*3+2]; |
| 317 | row[j*3+0] = row[k*3+0]; |
| 318 | row[j*3+1] = row[k*3+1]; |
| 319 | row[j*3+2] = row[k*3+2]; |
| 320 | row[k*3+0] = temp[0]; |
| 321 | row[k*3+1] = temp[1]; |
| 322 | row[k*3+2] = temp[2]; |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | gluBuild2DMipmaps(target, GL_RGB, w, h, format, GL_UNSIGNED_BYTE, img); |
| 328 | free(img); |
| 329 | } |
| 330 | |
| 331 | |
| 332 | static void load_envmaps(void) |
| 333 | { |
| 334 | load(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, "right.rgb", GL_TRUE, GL_FALSE); |
| 335 | load(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, "left.rgb", GL_TRUE, GL_FALSE); |
| 336 | load(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, "top.rgb", GL_FALSE, GL_TRUE); |
| 337 | load(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, "bottom.rgb", GL_FALSE, GL_TRUE); |
| 338 | load(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, "front.rgb", GL_TRUE, GL_FALSE); |
| 339 | load(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, "back.rgb", GL_TRUE, GL_FALSE); |
| 340 | } |
| 341 | |
| 342 | |
| 343 | static void init( GLboolean useImageFiles ) |
| 344 | { |
| 345 | GLenum filter; |
| 346 | |
| 347 | /* check for extension */ |
| 348 | { |
| 349 | char *exten = (char *) glGetString(GL_EXTENSIONS); |
| 350 | if (!strstr(exten, "GL_ARB_texture_cube_map")) { |
| 351 | printf("Sorry, this demo requires GL_ARB_texture_cube_map\n"); |
| 352 | exit(0); |
| 353 | } |
| 354 | } |
| 355 | printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); |
| 356 | |
| 357 | if (useImageFiles) { |
| 358 | load_envmaps(); |
| 359 | filter = GL_LINEAR; |
| 360 | } |
| 361 | else { |
| 362 | init_checkers(); |
| 363 | filter = GL_NEAREST; |
| 364 | } |
| 365 | |
| 366 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, filter); |
| 367 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, filter); |
Brian Paul | d27e256 | 2000-06-13 18:45:54 +0000 | [diff] [blame] | 368 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 369 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 370 | |
| 371 | glEnable(GL_TEXTURE_CUBE_MAP_ARB); |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 372 | glEnable(GL_DEPTH_TEST); |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 373 | |
| 374 | glClearColor(.3, .3, .3, 0); |
| 375 | glColor3f( 1.0, 1.0, 1.0 ); |
| 376 | |
| 377 | set_mode(0); |
| 378 | } |
| 379 | |
| 380 | |
| 381 | static void usage(void) |
| 382 | { |
| 383 | printf("keys:\n"); |
| 384 | printf(" SPACE - toggle animation\n"); |
| 385 | printf(" CURSOR KEYS - rotation\n"); |
| 386 | printf(" m - toggle texgen reflection mode\n"); |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 387 | printf(" z/Z - change viewing distance\n"); |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | |
| 391 | int main( int argc, char *argv[] ) |
| 392 | { |
| 393 | glutInitWindowPosition(0, 0); |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 394 | glutInitWindowSize(600, 500); |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 395 | glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); |
Brian Paul | 0b77a1c | 2003-04-09 21:50:08 +0000 | [diff] [blame] | 396 | glutCreateWindow("Texture Cube Mapping"); |
Brian Paul | a4f0b68 | 2002-10-25 17:20:26 +0000 | [diff] [blame] | 397 | |
| 398 | if (argc > 1 && strcmp(argv[1] , "-i") == 0) |
| 399 | init( 1 ); |
| 400 | else |
| 401 | init( 0 ); |
Brian Paul | d04d209 | 2000-05-30 01:18:29 +0000 | [diff] [blame] | 402 | glutReshapeFunc( reshape ); |
| 403 | glutKeyboardFunc( key ); |
| 404 | glutSpecialFunc( specialkey ); |
| 405 | glutIdleFunc( idle ); |
| 406 | glutDisplayFunc( draw ); |
| 407 | usage(); |
| 408 | glutMainLoop(); |
| 409 | return 0; |
| 410 | } |