annotate Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/atlantis.c @ 3486:c87dbbde2bc2

Fixed bug #891 Mason Wheeler 2009-11-23 06:59:48 PST There's code in SDL_RecreateWindow specifically to handle SDL_WINDOW_FOREIGN, but it appears to have been overlooked in the allowed_flags constant. This causes the line window->flags = (flags & allowed_flags); to strip SDL_WINDOW_FOREIGN from the window's flags, which breaks some code in WIN_WindowProc in SDL_win32Events.c that treats foreign windows differently. This can be trivially fixed by defining allowed_flags as const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FOREIGN);
author Sam Lantinga <slouken@libsdl.org>
date Tue, 24 Nov 2009 04:59:50 +0000
parents 232e5e00e398
children
rev   line source
3329
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 /* Copyright (c) Mark J. Kilgard, 1994. */
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 /**
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 * ALL RIGHTS RESERVED
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 * Permission to use, copy, modify, and distribute this software for
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 * any purpose and without fee is hereby granted, provided that the above
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 * copyright notice appear in all copies and that both the copyright notice
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 * and this permission notice appear in supporting documentation, and that
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 * the name of Silicon Graphics, Inc. not be used in advertising
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 * or publicity pertaining to distribution of the software without specific,
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 * written prior permission.
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 *
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 *
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 * US Government Users Restricted Rights
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 * Use, duplication, or disclosure by the Government is subject to
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 * (c)(1)(ii) of the Rights in Technical Data and Computer Software
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 * clause at DFARS 252.227-7013 and/or in similar or successor
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 * clauses in the FAR or the DOD or NASA FAR Supplement.
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 * Unpublished-- rights reserved under the copyright laws of the
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 * United States. Contractor/manufacturer is Silicon Graphics,
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 *
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 */
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #include <stdio.h>
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #include <stdlib.h>
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #include <string.h>
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #include <math.h>
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 #include <sys/time.h>
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #include <GLUT/glut.h>
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #include "atlantis.h"
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 fishRec sharks[NUM_SHARKS];
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 fishRec momWhale;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 fishRec babyWhale;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 fishRec dolph;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 GLboolean Timing = GL_TRUE;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 int w_win = 640;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 int h_win = 480;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 GLint count = 0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 GLenum StrMode = GL_VENDOR;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 GLboolean moving;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 static double mtime(void)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 struct timeval tk_time;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 struct timezone tz;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 gettimeofday(&tk_time, &tz);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 static double filter(double in, double *save)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 static double k1 = 0.9;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 static double k2 = 0.05;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 save[3] = in;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 save[1] = save[0]*k1 + k2*(save[3] + save[2]);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 save[0]=save[1];
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 save[2]=save[3];
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 return(save[1]);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 void DrawStr(const char *str)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 GLint i = 0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 if(!str) return;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 while(str[i])
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 i++;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 InitFishs(void)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 int i;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 for (i = 0; i < NUM_SHARKS; i++) {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 sharks[i].x = 70000.0 + rand() % 6000;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 sharks[i].y = rand() % 6000;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 sharks[i].z = rand() % 6000;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 sharks[i].psi = rand() % 360 - 180.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 sharks[i].v = 1.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 dolph.x = 30000.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 dolph.y = 0.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 dolph.z = 6000.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 dolph.psi = 90.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 dolph.theta = 0.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 dolph.v = 3.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 momWhale.x = 70000.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 momWhale.y = 0.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 momWhale.z = 0.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 momWhale.psi = 90.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 momWhale.theta = 0.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 momWhale.v = 3.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 babyWhale.x = 60000.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 babyWhale.y = -2000.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 babyWhale.z = -2000.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 babyWhale.psi = 90.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 babyWhale.theta = 0.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 babyWhale.v = 3.0;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 Atlantis_Init(void)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 static float ambient[] = {0.2, 0.2, 0.2, 1.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 static float diffuse[] = {1.0, 1.0, 1.0, 1.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 static float position[] = {0.0, 1.0, 0.0, 0.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 static float mat_shininess[] = {90.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 static float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 static float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 static float mat_ambient[] = {0.3, 0.4, 0.5, 1.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 static float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 static float lmodel_localviewer[] = {0.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 //GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 //GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 static float fog_color[] = {0.0, 0.5, 0.9, 1.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 glFrontFace(GL_CCW);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 glDepthFunc(GL_LESS);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 glEnable(GL_DEPTH_TEST);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 glLightfv(GL_LIGHT0, GL_POSITION, position);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 glEnable(GL_LIGHTING);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 glEnable(GL_LIGHT0);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 InitFishs();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 glEnable(GL_FOG);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 glFogi(GL_FOG_MODE, GL_EXP);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 glFogf(GL_FOG_DENSITY, 0.0000025);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 glFogfv(GL_FOG_COLOR, fog_color);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 glClearColor(0.0, 0.5, 0.9, 1.0);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 Atlantis_Reshape(int width, int height)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 w_win = width;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 h_win = height;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 glViewport(0, 0, width, height);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 glMatrixMode(GL_PROJECTION);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 glLoadIdentity();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0, 300000.0);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 glMatrixMode(GL_MODELVIEW);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 Atlantis_Animate(void)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 int i;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 for (i = 0; i < NUM_SHARKS; i++) {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 SharkPilot(&sharks[i]);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 SharkMiss(i);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 WhalePilot(&dolph);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 dolph.phi++;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 //glutPostRedisplay();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 WhalePilot(&momWhale);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 momWhale.phi++;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 WhalePilot(&babyWhale);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 babyWhale.phi++;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 Atlantis_Key(unsigned char key, int x, int y)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 switch (key) {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 case 't':
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 Timing = !Timing;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 case ' ':
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 switch(StrMode)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 case GL_EXTENSIONS:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 StrMode = GL_VENDOR;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 case GL_VENDOR:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 StrMode = GL_RENDERER;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 case GL_RENDERER:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 StrMode = GL_VERSION;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 case GL_VERSION:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 StrMode = GL_EXTENSIONS;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 case 27: /* Esc will quit */
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 exit(1);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 case 's': /* "s" start animation */
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 moving = GL_TRUE;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 //glutIdleFunc(Animate);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 case 'a': /* "a" stop animation */
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 moving = GL_FALSE;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 //glutIdleFunc(NULL);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 case '.': /* "." will advance frame */
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 if (!moving) {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 Atlantis_Animate();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 /*
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 void Display(void)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 static float P123[3] = {-448.94, -203.14, 9499.60};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 static float P124[3] = {-442.64, -185.20, 9528.07};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 static float P125[3] = {-441.07, -148.05, 9528.07};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 static float P126[3] = {-443.43, -128.84, 9499.60};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 static float P127[3] = {-456.87, -146.78, 9466.67};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 static float P128[3] = {-453.68, -183.93, 9466.67};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 glPushMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 FishTransform(&dolph);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 DrawDolphin(&dolph);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 glPopMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 glutSwapBuffers();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 */
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 Atlantis_Display(void)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 int i;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 static double th[4] = {0.0, 0.0, 0.0, 0.0};
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 static double t1 = 0.0, t2 = 0.0, t;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 char num_str[128];
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 t1 = t2;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 for (i = 0; i < NUM_SHARKS; i++) {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 glPushMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 FishTransform(&sharks[i]);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 DrawShark(&sharks[i]);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 glPopMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 glPushMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 FishTransform(&dolph);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 DrawDolphin(&dolph);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 glPopMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 glPushMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 FishTransform(&momWhale);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 DrawWhale(&momWhale);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 glPopMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 glPushMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 FishTransform(&babyWhale);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 glScalef(0.45, 0.45, 0.3);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 DrawWhale(&babyWhale);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 glPopMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 if(Timing)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 t2 = mtime();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 t = t2 - t1;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 if(t > 0.0001) t = 1.0 / t;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 glDisable(GL_LIGHTING);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 //glDisable(GL_DEPTH_TEST);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 glColor3f(1.0, 0.0, 0.0);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 glMatrixMode (GL_PROJECTION);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 glPushMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 glLoadIdentity();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 glRasterPos2f(5.0, 5.0);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 switch(StrMode)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 case GL_VENDOR:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 DrawStr(num_str);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 DrawStr(glGetString(GL_VENDOR));
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 case GL_RENDERER:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 DrawStr(num_str);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 DrawStr(glGetString(GL_RENDERER));
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 case GL_VERSION:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 DrawStr(num_str);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 DrawStr(glGetString(GL_VERSION));
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 case GL_EXTENSIONS:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 DrawStr(num_str);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 DrawStr(glGetString(GL_EXTENSIONS));
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 glPopMatrix();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 glMatrixMode(GL_MODELVIEW);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 glEnable(GL_LIGHTING);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 //glEnable(GL_DEPTH_TEST);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 count++;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 glutSwapBuffers();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 /*
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 Visible(int state)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 if (state == GLUT_VISIBLE) {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 if (moving)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 glutIdleFunc(Animate);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 } else {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 if (moving)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 glutIdleFunc(NULL);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 timingSelect(int value)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 switch(value)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 case 1:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 StrMode = GL_VENDOR;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 case 2:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 StrMode = GL_RENDERER;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 case 3:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 StrMode = GL_VERSION;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 case 4:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 StrMode = GL_EXTENSIONS;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 void
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 menuSelect(int value)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 switch (value) {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 case 1:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 moving = GL_TRUE;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 glutIdleFunc(Animate);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 case 2:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 moving = GL_FALSE;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 glutIdleFunc(NULL);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 case 4:
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 exit(0);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 break;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 int
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 main(int argc, char **argv)
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 GLboolean fullscreen = GL_FALSE;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 GLint time_menu;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 srand(0);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 glutInit(&argc, argv);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 if (argc > 1 && !strcmp(argv[1], "-w"))
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 fullscreen = GL_FALSE;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 glutInitDisplayString("rgba double depth=24");
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 if (fullscreen) {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 glutGameModeString("1024x768:32");
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 glutEnterGameMode();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 } else {
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 glutInitWindowSize(320, 240);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 glutCreateWindow("Atlantis Timing");
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 Init();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 glutDisplayFunc(Display);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 glutReshapeFunc(Reshape);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 glutKeyboardFunc(Key);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 moving = GL_TRUE;
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 glutIdleFunc(Animate);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 glutVisibilityFunc(Visible);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 time_menu = glutCreateMenu(timingSelect);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 glutAddMenuEntry("GL_VENDOR", 1);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 glutAddMenuEntry("GL_RENDERER", 2);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 glutAddMenuEntry("GL_VERSION", 3);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 glutAddMenuEntry("GL_EXTENSIONS", 4);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 glutCreateMenu(menuSelect);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 glutAddMenuEntry("Start motion", 1);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 glutAddMenuEntry("Stop motion", 2);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 glutAddSubMenu("Timing Mode", time_menu);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 glutAddMenuEntry("Quit", 4);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 //glutAttachMenu(GLUT_RIGHT_BUTTON);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 glutAttachMenu(GLUT_RIGHT_BUTTON);
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 glutMainLoop();
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 return 0; // ANSI C requires main to return int.
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 }
232e5e00e398 Added missing templates
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 */