[4] | 1 | |
---|
| 2 | /* Copyright (c) Mark J. Kilgard, 1994. */ |
---|
| 3 | |
---|
| 4 | /** |
---|
| 5 | * (c) Copyright 1993, 1994, Silicon Graphics, Inc. |
---|
| 6 | * ALL RIGHTS RESERVED |
---|
| 7 | * Permission to use, copy, modify, and distribute this software for |
---|
| 8 | * any purpose and without fee is hereby granted, provided that the above |
---|
| 9 | * copyright notice appear in all copies and that both the copyright notice |
---|
| 10 | * and this permission notice appear in supporting documentation, and that |
---|
| 11 | * the name of Silicon Graphics, Inc. not be used in advertising |
---|
| 12 | * or publicity pertaining to distribution of the software without specific, |
---|
| 13 | * written prior permission. |
---|
| 14 | * |
---|
| 15 | * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" |
---|
| 16 | * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, |
---|
| 17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR |
---|
| 18 | * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON |
---|
| 19 | * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, |
---|
| 20 | * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY |
---|
| 21 | * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, |
---|
| 22 | * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF |
---|
| 23 | * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN |
---|
| 24 | * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON |
---|
| 25 | * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE |
---|
| 26 | * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. |
---|
| 27 | * |
---|
| 28 | * US Government Users Restricted Rights |
---|
| 29 | * Use, duplication, or disclosure by the Government is subject to |
---|
| 30 | * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph |
---|
| 31 | * (c)(1)(ii) of the Rights in Technical Data and Computer Software |
---|
| 32 | * clause at DFARS 252.227-7013 and/or in similar or successor |
---|
| 33 | * clauses in the FAR or the DOD or NASA FAR Supplement. |
---|
| 34 | * Unpublished-- rights reserved under the copyright laws of the |
---|
| 35 | * United States. Contractor/manufacturer is Silicon Graphics, |
---|
| 36 | * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. |
---|
| 37 | * |
---|
| 38 | * OpenGL(TM) is a trademark of Silicon Graphics, Inc. |
---|
| 39 | */ |
---|
| 40 | |
---|
| 41 | #include "sail.h" |
---|
| 42 | #if defined(__APPLE__) |
---|
| 43 | #include <GLUT/glut.h> |
---|
| 44 | #include <OpenGL/glu.h> |
---|
| 45 | #else |
---|
| 46 | #include <GL/glut.h> |
---|
| 47 | #include <GL/glu.h> |
---|
| 48 | #endif |
---|
| 49 | |
---|
| 50 | #include <stdio.h> |
---|
| 51 | #include <stdlib.h> |
---|
| 52 | #include <string.h> |
---|
| 53 | #include <math.h> |
---|
| 54 | #include <assert.h> |
---|
| 55 | #if defined(WIN32) |
---|
| 56 | //#define WIN32_LEAN_AND_MEAN |
---|
| 57 | //#include <windows.h> |
---|
| 58 | //#include <winsock.h> |
---|
| 59 | #include <sys\timeb.h> |
---|
| 60 | extern int gettimeofday(struct timeval *tp, void *tzp); |
---|
| 61 | #else |
---|
| 62 | #include <sys/time.h> |
---|
| 63 | #endif |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | #include "atlantis.h" |
---|
| 67 | |
---|
| 68 | // headers for SAGE |
---|
| 69 | #include "misc.h" |
---|
| 70 | int winWidth, winHeight; |
---|
| 71 | GLubyte *rgbBuffer = 0; |
---|
| 72 | sail sageInf; // sail object |
---|
| 73 | FILE *ff; |
---|
| 74 | #if defined(WIN32) |
---|
| 75 | /* |
---|
| 76 | int |
---|
| 77 | gettimeofday(struct timeval *tp, void *tzp) |
---|
| 78 | { |
---|
| 79 | struct _timeb t; |
---|
| 80 | |
---|
| 81 | _ftime(&t); |
---|
| 82 | tp->tv_sec = t.time; |
---|
| 83 | tp->tv_usec = t.millitm * 1000; |
---|
| 84 | return 0; |
---|
| 85 | } |
---|
| 86 | */ |
---|
| 87 | #endif |
---|
| 88 | |
---|
| 89 | fishRec sharks[NUM_SHARKS]; |
---|
| 90 | fishRec momWhale; |
---|
| 91 | fishRec babyWhale; |
---|
| 92 | fishRec dolph; |
---|
| 93 | |
---|
| 94 | GLboolean moving; |
---|
| 95 | int screenshot = 0; |
---|
| 96 | float t1,t2; |
---|
| 97 | struct timeval tv_start; |
---|
| 98 | |
---|
| 99 | double getTime() |
---|
| 100 | { |
---|
| 101 | struct timeval tv; |
---|
| 102 | |
---|
| 103 | gettimeofday(&tv,0); |
---|
| 104 | return (double)(tv.tv_sec - tv_start.tv_sec) + (double)(tv.tv_usec - tv_start.tv_usec) / 1000000.0; |
---|
| 105 | } |
---|
| 106 | /* |
---|
| 107 | float abs(float f) |
---|
| 108 | { |
---|
| 109 | if (f >= 0.0f) return f; |
---|
| 110 | else return -f; |
---|
| 111 | } |
---|
| 112 | */ |
---|
| 113 | void |
---|
| 114 | InitFishs(void) |
---|
| 115 | { |
---|
| 116 | int i; |
---|
| 117 | |
---|
| 118 | for (i = 0; i < NUM_SHARKS; i++) { |
---|
| 119 | sharks[i].x = 15000.0 + rand() % 6000; |
---|
| 120 | sharks[i].y = (rand() % 20000) - 10000; |
---|
| 121 | sharks[i].z = (rand() % 6000) - 5000; |
---|
| 122 | sharks[i].psi = rand() % 360 - 180.0; |
---|
| 123 | sharks[i].v = 1.0; |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | dolph.x = 30000.0; |
---|
| 127 | dolph.y = 0.0; |
---|
| 128 | dolph.z = 6000.0; |
---|
| 129 | dolph.psi = 90.0; |
---|
| 130 | dolph.theta = 0.0; |
---|
| 131 | dolph.v = 3.0; |
---|
| 132 | |
---|
| 133 | momWhale.x = 70000.0; |
---|
| 134 | momWhale.y = 0.0; |
---|
| 135 | momWhale.z = 0.0; |
---|
| 136 | momWhale.psi = 90.0; |
---|
| 137 | momWhale.theta = 0.0; |
---|
| 138 | momWhale.v = 3.0; |
---|
| 139 | |
---|
| 140 | babyWhale.x = 60000.0; |
---|
| 141 | babyWhale.y = -2000.0; |
---|
| 142 | babyWhale.z = -2000.0; |
---|
| 143 | babyWhale.psi = 90.0; |
---|
| 144 | babyWhale.theta = 0.0; |
---|
| 145 | babyWhale.v = 3.0; |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | void |
---|
| 149 | Init(void) |
---|
| 150 | { |
---|
| 151 | static float ambient[] = |
---|
| 152 | {0.1, 0.1, 0.1, 1.0}; |
---|
| 153 | static float diffuse[] = |
---|
| 154 | {1.0, 1.0, 1.0, 1.0}; |
---|
| 155 | static float position[] = |
---|
| 156 | {0.0, 1.0, 0.0, 0.0}; |
---|
| 157 | static float mat_shininess[] = |
---|
| 158 | {90.0}; |
---|
| 159 | static float mat_specular[] = |
---|
| 160 | {0.8, 0.8, 0.8, 1.0}; |
---|
| 161 | static float mat_diffuse[] = |
---|
| 162 | {0.46, 0.66, 0.795, 1.0}; |
---|
| 163 | static float mat_ambient[] = |
---|
| 164 | {0.0, 0.1, 0.2, 1.0}; |
---|
| 165 | static float lmodel_ambient[] = |
---|
| 166 | {0.4, 0.4, 0.4, 1.0}; |
---|
| 167 | static float lmodel_localviewer[] = |
---|
| 168 | {1.0}; |
---|
| 169 | |
---|
| 170 | glFrontFace(GL_CW); |
---|
| 171 | |
---|
| 172 | glDepthFunc(GL_LEQUAL); |
---|
| 173 | glEnable(GL_DEPTH_TEST); |
---|
| 174 | |
---|
| 175 | glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); |
---|
| 176 | glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); |
---|
| 177 | glLightfv(GL_LIGHT0, GL_POSITION, position); |
---|
| 178 | glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); |
---|
| 179 | glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer); |
---|
| 180 | glEnable(GL_LIGHTING); |
---|
| 181 | glEnable(GL_LIGHT0); |
---|
| 182 | |
---|
| 183 | glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); |
---|
| 184 | glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); |
---|
| 185 | glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); |
---|
| 186 | glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); |
---|
| 187 | |
---|
| 188 | InitFishs(); |
---|
| 189 | |
---|
| 190 | glClearColor(0.0, 0.5, 0.9, 0.0); |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | void |
---|
| 194 | Reshape(int width, int height) |
---|
| 195 | { |
---|
| 196 | winWidth = width; |
---|
| 197 | winHeight = height; |
---|
| 198 | |
---|
| 199 | glViewport(0, 0, width, height); |
---|
| 200 | |
---|
| 201 | glMatrixMode(GL_PROJECTION); |
---|
| 202 | glLoadIdentity(); |
---|
| 203 | gluPerspective(4.0, 2.0, 10000.0, 400000.0); |
---|
| 204 | glMatrixMode(GL_MODELVIEW); |
---|
| 205 | glLoadIdentity(); |
---|
| 206 | |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | void |
---|
| 210 | Animate(void) |
---|
| 211 | { |
---|
| 212 | int i; |
---|
| 213 | |
---|
| 214 | for (i = 0; i < NUM_SHARKS; i++) { |
---|
| 215 | SharkPilot(&sharks[i]); |
---|
| 216 | SharkMiss(i); |
---|
| 217 | } |
---|
| 218 | WhalePilot(&dolph); |
---|
| 219 | dolph.phi++; |
---|
| 220 | glutPostRedisplay(); |
---|
| 221 | WhalePilot(&momWhale); |
---|
| 222 | momWhale.phi++; |
---|
| 223 | WhalePilot(&babyWhale); |
---|
| 224 | babyWhale.phi++; |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | /* ARGSUSED1 */ |
---|
| 228 | void |
---|
| 229 | Key(unsigned char key, int x, int y) |
---|
| 230 | { |
---|
| 231 | (void) x; |
---|
| 232 | (void) y; |
---|
| 233 | switch (key) |
---|
| 234 | { |
---|
| 235 | case 27: /* Esc will quit */ |
---|
| 236 | sageInf.shutdown(); |
---|
| 237 | exit(1); |
---|
| 238 | break; |
---|
| 239 | case 's': |
---|
| 240 | screenshot++; |
---|
| 241 | glutPostRedisplay( ); |
---|
| 242 | break; |
---|
| 243 | case ' ': /* space will advance frame */ |
---|
| 244 | if (!moving) { |
---|
| 245 | Animate(); |
---|
| 246 | } |
---|
| 247 | } |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | |
---|
| 251 | void |
---|
| 252 | save_frame( void ) |
---|
| 253 | { |
---|
| 254 | /* GLint viewport[4]; |
---|
| 255 | int x, y, width, height; |
---|
| 256 | void *pixels; |
---|
| 257 | FILE *f; |
---|
| 258 | |
---|
| 259 | glGetIntegerv( GL_VIEWPORT, viewport ); |
---|
| 260 | |
---|
| 261 | x = viewport[0]; |
---|
| 262 | y = viewport[1]; |
---|
| 263 | width = viewport[2]; |
---|
| 264 | height = viewport[3]; |
---|
| 265 | |
---|
| 266 | printf( "saving %dx%d screenshot\n", width, height ); |
---|
| 267 | |
---|
| 268 | pixels = malloc( width * height * 3 ); |
---|
| 269 | assert( pixels ); |
---|
| 270 | memset( pixels, 0, width * height * 3 ); |
---|
| 271 | |
---|
| 272 | glReadPixels( x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels ); |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | f = fopen( "screenshot.ppm", "wb" ); |
---|
| 276 | fprintf( f, "P6\n%d %d\n255\n", width, height ); |
---|
| 277 | for ( y = height - 1; y >= 0; y-- ) |
---|
| 278 | fwrite( (char *) pixels + y * width * 3, width, 3, f ); |
---|
| 279 | fclose( f ); |
---|
| 280 | |
---|
| 281 | free( pixels ); |
---|
| 282 | |
---|
| 283 | printf( "done\n" );*/ |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | void |
---|
| 287 | print_performance( void ) |
---|
| 288 | { |
---|
| 289 | /* static int first = 1; |
---|
| 290 | = 0 |
---|
| 291 | static int start, num_frames; |
---|
| 292 | int current; |
---|
| 293 | |
---|
| 294 | if ( first ) |
---|
| 295 | { |
---|
| 296 | start = glutGet( GLUT_ELAPSED_TIME ); |
---|
| 297 | num_frames = 0; |
---|
| 298 | first = 0; |
---|
| 299 | } |
---|
| 300 | |
---|
| 301 | num_frames++; |
---|
| 302 | current = glutGet( GLUT_ELAPSED_TIME ); |
---|
| 303 | |
---|
| 304 | if ( current - start > 1000 ) |
---|
| 305 | { |
---|
| 306 | double elapsed = 1e-3 * (double) ( current - start ); |
---|
| 307 | double rate = (double) num_frames / elapsed; |
---|
| 308 | printf( "%5.1f fps\n", rate ); |
---|
| 309 | |
---|
| 310 | num_frames = 0; |
---|
| 311 | start = current; |
---|
| 312 | }*/ |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | void |
---|
| 316 | Display( void ) |
---|
| 317 | { |
---|
| 318 | float ambient[] = {0.1, 0.1, 0.1, 1.0}; |
---|
| 319 | float diffuse[] = {1.0, 1.0, 1.0, 1.0}; |
---|
| 320 | float position[] = {0.0, 1.0, 0.0, 0.0}; |
---|
| 321 | float mat_shininess[] = {90.0}; |
---|
| 322 | float mat_specular[] = {0.8, 0.8, 0.8, 1.0}; |
---|
| 323 | float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0}; |
---|
| 324 | float mat_ambient[] = {0.0, 0.1, 0.2, 1.0}; |
---|
| 325 | float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0}; |
---|
| 326 | float lmodel_localviewer[] = {0.0}; |
---|
| 327 | |
---|
| 328 | int i; |
---|
| 329 | |
---|
| 330 | #if 0 |
---|
| 331 | /* stupid WireGL */ |
---|
| 332 | glViewport (0, 0, 450*3, 170*3); |
---|
| 333 | #endif |
---|
| 334 | |
---|
| 335 | glFrontFace(GL_CCW); |
---|
| 336 | |
---|
| 337 | |
---|
| 338 | glDepthFunc(GL_LEQUAL); |
---|
| 339 | |
---|
| 340 | glEnable(GL_DEPTH_TEST); |
---|
| 341 | |
---|
| 342 | glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); |
---|
| 343 | |
---|
| 344 | glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); |
---|
| 345 | |
---|
| 346 | glLightfv(GL_LIGHT0, GL_POSITION, position); |
---|
| 347 | |
---|
| 348 | glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); |
---|
| 349 | |
---|
| 350 | glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer); |
---|
| 351 | |
---|
| 352 | glEnable(GL_LIGHTING); |
---|
| 353 | |
---|
| 354 | glEnable(GL_LIGHT0); |
---|
| 355 | |
---|
| 356 | glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); |
---|
| 357 | |
---|
| 358 | glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); |
---|
| 359 | |
---|
| 360 | glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); |
---|
| 361 | |
---|
| 362 | glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); |
---|
| 363 | |
---|
| 364 | glClearColor(0.0, 0.5, 0.9, 0.0); |
---|
| 365 | |
---|
| 366 | glMatrixMode(GL_PROJECTION); |
---|
| 367 | |
---|
| 368 | glLoadIdentity(); |
---|
| 369 | |
---|
| 370 | gluPerspective(40.0, 2.0, 10000.0, 400000.0); |
---|
| 371 | |
---|
| 372 | glMatrixMode(GL_MODELVIEW); |
---|
| 373 | |
---|
| 374 | glLoadIdentity(); |
---|
| 375 | |
---|
| 376 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
---|
| 377 | |
---|
| 378 | for (i = 0; i < NUM_SHARKS; i++) { |
---|
| 379 | glPushMatrix(); |
---|
| 380 | FishTransform(&sharks[i]); |
---|
| 381 | DrawShark(&sharks[i]); |
---|
| 382 | glPopMatrix(); |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | glPushMatrix(); |
---|
| 386 | FishTransform(&dolph); |
---|
| 387 | DrawDolphin(&dolph); |
---|
| 388 | glPopMatrix(); |
---|
| 389 | |
---|
| 390 | glPushMatrix(); |
---|
| 391 | FishTransform(&momWhale); |
---|
| 392 | DrawWhale(&momWhale); |
---|
| 393 | glPopMatrix(); |
---|
| 394 | |
---|
| 395 | glPushMatrix(); |
---|
| 396 | FishTransform(&babyWhale); |
---|
| 397 | glScalef(0.45, 0.45, 0.3); |
---|
| 398 | DrawWhale(&babyWhale); |
---|
| 399 | glPopMatrix(); |
---|
| 400 | glFinish(); |
---|
| 401 | |
---|
| 402 | if (winWidth > 0) { |
---|
| 403 | glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, rgbBuffer); |
---|
| 404 | sageInf.swapBuffer(); |
---|
| 405 | rgbBuffer = (GLubyte *)sageInf.getBuffer(); |
---|
| 406 | //usleep(100000); |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | sageMessage msg; |
---|
| 410 | if (sageInf.checkMsg(msg, false) > 0) { |
---|
| 411 | switch (msg.getCode()) { |
---|
| 412 | case APP_QUIT : { |
---|
| 413 | exit(0); |
---|
| 414 | break; |
---|
| 415 | } |
---|
| 416 | } |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | glutSwapBuffers(); |
---|
| 420 | } |
---|
| 421 | |
---|
| 422 | void |
---|
| 423 | Visible(int state) |
---|
| 424 | { |
---|
| 425 | if (state == GLUT_VISIBLE) { |
---|
| 426 | if (moving) |
---|
| 427 | glutIdleFunc(Animate); |
---|
| 428 | } else { |
---|
| 429 | if (moving) |
---|
| 430 | glutIdleFunc(NULL); |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | void |
---|
| 435 | menuSelect(int value) |
---|
| 436 | { |
---|
| 437 | switch (value) |
---|
| 438 | { |
---|
| 439 | case 1: |
---|
| 440 | moving = GL_TRUE; |
---|
| 441 | glutIdleFunc(Animate); |
---|
| 442 | break; |
---|
| 443 | case 2: |
---|
| 444 | moving = GL_FALSE;; |
---|
| 445 | glutIdleFunc(NULL); |
---|
| 446 | break; |
---|
| 447 | case 3: |
---|
| 448 | exit(0); |
---|
| 449 | break; |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | int |
---|
| 454 | main(int argc, char **argv) |
---|
| 455 | { |
---|
| 456 | int nodeId = 0; |
---|
| 457 | |
---|
| 458 | int resX = 300, resY = 300; |
---|
| 459 | if (argc > 3) { |
---|
| 460 | resX = atoi(argv[2]); |
---|
| 461 | resY = atoi(argv[3]); |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | sageRect atlantisImageMap; |
---|
| 465 | atlantisImageMap.left = 0.0; |
---|
| 466 | atlantisImageMap.right = 1.0; |
---|
| 467 | atlantisImageMap.bottom = 0.0; |
---|
| 468 | atlantisImageMap.top = 1.0; |
---|
| 469 | |
---|
| 470 | sailConfig scfg; |
---|
| 471 | scfg.init("atlantis.conf"); |
---|
| 472 | scfg.setAppName("atlantis"); |
---|
| 473 | scfg.rank = nodeId; |
---|
| 474 | |
---|
| 475 | if (argc >= 2) |
---|
| 476 | scfg.appID = atoi(argv[1]); |
---|
| 477 | |
---|
| 478 | scfg.resX = resX; |
---|
| 479 | scfg.resY = resY; |
---|
| 480 | scfg.imageMap = atlantisImageMap; |
---|
| 481 | scfg.pixFmt = PIXFMT_888; |
---|
| 482 | scfg.rowOrd = BOTTOM_TO_TOP; |
---|
| 483 | scfg.master = true; |
---|
| 484 | scfg.nwID = 1; |
---|
| 485 | |
---|
| 486 | if (argc > 5) |
---|
| 487 | scfg.nwID = atoi(argv[5]); |
---|
| 488 | |
---|
| 489 | sageInf.init(scfg); |
---|
| 490 | |
---|
| 491 | std::cout << "sail initialized " << std::endl; |
---|
| 492 | |
---|
| 493 | //glutInitWindowSize(512, 192); |
---|
| 494 | gettimeofday(&tv_start,0); |
---|
| 495 | |
---|
| 496 | glutInitWindowSize(resX, resY); |
---|
| 497 | glutInitWindowPosition(0,0); |
---|
| 498 | glutInit(&argc, argv); |
---|
| 499 | glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); |
---|
| 500 | glutCreateWindow("GLUT Atlantis Demo"); |
---|
| 501 | printf("sharks: %d\n",NUM_SHARKS); |
---|
| 502 | Init(); |
---|
| 503 | glutDisplayFunc(Display); |
---|
| 504 | glutReshapeFunc(Reshape); |
---|
| 505 | glutKeyboardFunc(Key); |
---|
| 506 | moving = GL_TRUE; |
---|
| 507 | glutIdleFunc(Animate); |
---|
| 508 | glutVisibilityFunc(Visible); |
---|
| 509 | glutCreateMenu(menuSelect); |
---|
| 510 | glutAddMenuEntry("Start motion", 1); |
---|
| 511 | glutAddMenuEntry("Stop motion", 2); |
---|
| 512 | glutAddMenuEntry("Quit", 3); |
---|
| 513 | glutAttachMenu(GLUT_RIGHT_BUTTON); |
---|
| 514 | glPixelStorei(GL_PACK_ALIGNMENT,1); |
---|
| 515 | |
---|
| 516 | //glutFullScreen(); |
---|
| 517 | |
---|
| 518 | if (rgbBuffer) |
---|
| 519 | delete [] rgbBuffer; |
---|
| 520 | rgbBuffer = (GLubyte *)sageInf.getBuffer(); |
---|
| 521 | |
---|
| 522 | t1 = getTime(); |
---|
| 523 | glutMainLoop(); |
---|
| 524 | return 0; /* ANSI C requires main to return int. */ |
---|
| 525 | } |
---|