19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Copyright (c) Mark J. Kilgard, 1994. */ 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/** 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * (c) Copyright 1993, 1994, Silicon Graphics, Inc. 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * ALL RIGHTS RESERVED 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Permission to use, copy, modify, and distribute this software for 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * any purpose and without fee is hereby granted, provided that the above 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * copyright notice appear in all copies and that both the copyright notice 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * and this permission notice appear in supporting documentation, and that 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * the name of Silicon Graphics, Inc. not be used in advertising 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * or publicity pertaining to distribution of the software without specific, 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * written prior permission. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * US Government Users Restricted Rights 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Use, duplication, or disclosure by the Government is subject to 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * (c)(1)(ii) of the Rights in Technical Data and Computer Software 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * clause at DFARS 252.227-7013 and/or in similar or successor 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * clauses in the FAR or the DOD or NASA FAR Supplement. 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Unpublished-- rights reserved under the copyright laws of the 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * United States. Contractor/manufacturer is Silicon Graphics, 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * OpenGL(TM) is a trademark of Silicon Graphics, Inc. 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdio.h> 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h> 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <string.h> 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <math.h> 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <sys/time.h> 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <GLUT/glut.h> 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "atlantis.h" 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallfishRec sharks[NUM_SHARKS]; 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallfishRec momWhale; 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallfishRec babyWhale; 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallfishRec dolph; 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallGLboolean Timing = GL_TRUE; 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint w_win = 640; 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint h_win = 480; 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallGLint count = 0; 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallGLenum StrMode = GL_VENDOR; 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallGLboolean moving; 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic double mtime(void) 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall struct timeval tk_time; 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall struct timezone tz; 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall gettimeofday(&tk_time, &tz); 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec; 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic double filter(double in, double *save) 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static double k1 = 0.9; 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static double k2 = 0.05; 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall save[3] = in; 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall save[1] = save[0]*k1 + k2*(save[3] + save[2]); 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall save[0]=save[1]; 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall save[2]=save[3]; 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(save[1]); 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DrawStr(const char *str) 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLint i = 0; 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(!str) return; 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while(str[i]) 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall i++; 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallInitFishs(void) 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i = 0; i < NUM_SHARKS; i++) { 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sharks[i].x = 70000.0 + rand() % 6000; 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sharks[i].y = rand() % 6000; 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sharks[i].z = rand() % 6000; 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sharks[i].psi = rand() % 360 - 180.0; 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sharks[i].v = 1.0; 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dolph.x = 30000.0; 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dolph.y = 0.0; 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dolph.z = 6000.0; 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dolph.psi = 90.0; 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dolph.theta = 0.0; 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dolph.v = 3.0; 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall momWhale.x = 70000.0; 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall momWhale.y = 0.0; 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall momWhale.z = 0.0; 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall momWhale.psi = 90.0; 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall momWhale.theta = 0.0; 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall momWhale.v = 3.0; 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall babyWhale.x = 60000.0; 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall babyWhale.y = -2000.0; 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall babyWhale.z = -2000.0; 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall babyWhale.psi = 90.0; 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall babyWhale.theta = 0.0; 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall babyWhale.v = 3.0; 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallAtlantis_Init(void) 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float ambient[] = {0.2, 0.2, 0.2, 1.0}; 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float diffuse[] = {1.0, 1.0, 1.0, 1.0}; 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float position[] = {0.0, 1.0, 0.0, 0.0}; 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float mat_shininess[] = {90.0}; 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float mat_specular[] = {0.8, 0.8, 0.8, 1.0}; 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0}; 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float mat_ambient[] = {0.3, 0.4, 0.5, 1.0}; 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0}; 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float lmodel_localviewer[] = {0.0}; 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0}; 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0}; 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float fog_color[] = {0.0, 0.5, 0.9, 1.0}; 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glFrontFace(GL_CCW); 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glDepthFunc(GL_LESS); 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnable(GL_DEPTH_TEST); 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLightfv(GL_LIGHT0, GL_POSITION, position); 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer); 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnable(GL_LIGHTING); 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnable(GL_LIGHT0); 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall InitFishs(); 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnable(GL_FOG); 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glFogi(GL_FOG_MODE, GL_EXP); 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glFogf(GL_FOG_DENSITY, 0.0000025); 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glFogfv(GL_FOG_COLOR, fog_color); 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glClearColor(0.0, 0.5, 0.9, 1.0); 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallAtlantis_Reshape(int width, int height) 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w_win = width; 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h_win = height; 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glViewport(0, 0, width, height); 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode(GL_PROJECTION); 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLoadIdentity(); 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0, 300000.0); 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode(GL_MODELVIEW); 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallAtlantis_Animate(void) 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i = 0; i < NUM_SHARKS; i++) { 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SharkPilot(&sharks[i]); 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SharkMiss(i); 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WhalePilot(&dolph); 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dolph.phi++; 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //glutPostRedisplay(); 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WhalePilot(&momWhale); 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall momWhale.phi++; 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall WhalePilot(&babyWhale); 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall babyWhale.phi++; 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallAtlantis_Key(unsigned char key, int x, int y) 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (key) { 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 't': 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Timing = !Timing; 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case ' ': 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(StrMode) 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case GL_EXTENSIONS: 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall StrMode = GL_VENDOR; 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case GL_VENDOR: 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall StrMode = GL_RENDERER; 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case GL_RENDERER: 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall StrMode = GL_VERSION; 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case GL_VERSION: 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall StrMode = GL_EXTENSIONS; 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 27: /* Esc will quit */ 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall exit(1); 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 's': /* "s" start animation */ 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall moving = GL_TRUE; 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //glutIdleFunc(Animate); 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 'a': /* "a" stop animation */ 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall moving = GL_FALSE; 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //glutIdleFunc(NULL); 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case '.': /* "." will advance frame */ 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!moving) { 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Atlantis_Animate(); 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid Display(void) 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float P123[3] = {-448.94, -203.14, 9499.60}; 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float P124[3] = {-442.64, -185.20, 9528.07}; 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float P125[3] = {-441.07, -148.05, 9528.07}; 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float P126[3] = {-443.43, -128.84, 9499.60}; 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float P127[3] = {-456.87, -146.78, 9466.67}; 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static float P128[3] = {-453.68, -183.93, 9466.67}; 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushMatrix(); 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FishTransform(&dolph); 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawDolphin(&dolph); 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopMatrix(); 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutSwapBuffers(); 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallAtlantis_Display(void) 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static double th[4] = {0.0, 0.0, 0.0, 0.0}; 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static double t1 = 0.0, t2 = 0.0, t; 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall char num_str[128]; 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall t1 = t2; 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i = 0; i < NUM_SHARKS; i++) { 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushMatrix(); 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FishTransform(&sharks[i]); 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawShark(&sharks[i]); 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopMatrix(); 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushMatrix(); 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FishTransform(&dolph); 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawDolphin(&dolph); 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopMatrix(); 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushMatrix(); 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FishTransform(&momWhale); 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawWhale(&momWhale); 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopMatrix(); 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushMatrix(); 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FishTransform(&babyWhale); 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glScalef(0.45, 0.45, 0.3); 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawWhale(&babyWhale); 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopMatrix(); 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(Timing) 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall t2 = mtime(); 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall t = t2 - t1; 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(t > 0.0001) t = 1.0 / t; 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glDisable(GL_LIGHTING); 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //glDisable(GL_DEPTH_TEST); 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3f(1.0, 0.0, 0.0); 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode (GL_PROJECTION); 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushMatrix(); 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLoadIdentity(); 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glOrtho(0, w_win, 0, h_win, -10.0, 10.0); 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glRasterPos2f(5.0, 5.0); 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(StrMode) 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case GL_VENDOR: 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win); 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawStr(num_str); 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawStr(glGetString(GL_VENDOR)); 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case GL_RENDERER: 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win); 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawStr(num_str); 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawStr(glGetString(GL_RENDERER)); 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case GL_VERSION: 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win); 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawStr(num_str); 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawStr(glGetString(GL_VERSION)); 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case GL_EXTENSIONS: 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win); 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawStr(num_str); 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawStr(glGetString(GL_EXTENSIONS)); 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopMatrix(); 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode(GL_MODELVIEW); 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnable(GL_LIGHTING); 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //glEnable(GL_DEPTH_TEST); 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall count++; 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutSwapBuffers(); 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallVisible(int state) 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (state == GLUT_VISIBLE) { 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (moving) 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutIdleFunc(Animate); 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (moving) 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutIdleFunc(NULL); 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HalltimingSelect(int value) 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(value) 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 1: 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall StrMode = GL_VENDOR; 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 2: 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall StrMode = GL_RENDERER; 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 3: 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall StrMode = GL_VERSION; 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 4: 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall StrMode = GL_EXTENSIONS; 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallmenuSelect(int value) 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (value) { 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 1: 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall moving = GL_TRUE; 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutIdleFunc(Animate); 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 2: 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall moving = GL_FALSE; 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutIdleFunc(NULL); 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 4: 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall exit(0); 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmain(int argc, char **argv) 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLboolean fullscreen = GL_FALSE; 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLint time_menu; 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall srand(0); 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutInit(&argc, argv); 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (argc > 1 && !strcmp(argv[1], "-w")) 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fullscreen = GL_FALSE; 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutInitDisplayString("rgba double depth=24"); 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (fullscreen) { 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutGameModeString("1024x768:32"); 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutEnterGameMode(); 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutInitWindowSize(320, 240); 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutCreateWindow("Atlantis Timing"); 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Init(); 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutDisplayFunc(Display); 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutReshapeFunc(Reshape); 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutKeyboardFunc(Key); 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall moving = GL_TRUE; 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallglutIdleFunc(Animate); 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutVisibilityFunc(Visible); 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall time_menu = glutCreateMenu(timingSelect); 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAddMenuEntry("GL_VENDOR", 1); 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAddMenuEntry("GL_RENDERER", 2); 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAddMenuEntry("GL_VERSION", 3); 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAddMenuEntry("GL_EXTENSIONS", 4); 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutCreateMenu(menuSelect); 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAddMenuEntry("Start motion", 1); 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAddMenuEntry("Stop motion", 2); 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAddSubMenu("Timing Mode", time_menu); 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAddMenuEntry("Quit", 4); 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //glutAttachMenu(GLUT_RIGHT_BUTTON); 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutAttachMenu(GLUT_RIGHT_BUTTON); 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glutMainLoop(); 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; // ANSI C requires main to return int. 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/