Mercurial > sdl-ios-xcode
comparison test/testgl.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children | a51dfda0ff33 |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
24 static GLuint cursor_texture = 0; | 24 static GLuint cursor_texture = 0; |
25 | 25 |
26 /**********************************************************************/ | 26 /**********************************************************************/ |
27 | 27 |
28 void | 28 void |
29 HotKey_ToggleFullScreen (void) | 29 HotKey_ToggleFullScreen(void) |
30 { | 30 { |
31 SDL_Surface *screen; | 31 SDL_Surface *screen; |
32 | 32 |
33 screen = SDL_GetVideoSurface (); | 33 screen = SDL_GetVideoSurface(); |
34 if (SDL_WM_ToggleFullScreen (screen)) { | 34 if (SDL_WM_ToggleFullScreen(screen)) { |
35 printf ("Toggled fullscreen mode - now %s\n", | 35 printf("Toggled fullscreen mode - now %s\n", |
36 (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); | 36 (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); |
37 } else { | 37 } else { |
38 printf ("Unable to toggle fullscreen mode\n"); | 38 printf("Unable to toggle fullscreen mode\n"); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 void | 42 void |
43 HotKey_ToggleGrab (void) | 43 HotKey_ToggleGrab(void) |
44 { | 44 { |
45 SDL_GrabMode mode; | 45 SDL_GrabMode mode; |
46 | 46 |
47 printf ("Ctrl-G: toggling input grab!\n"); | 47 printf("Ctrl-G: toggling input grab!\n"); |
48 mode = SDL_WM_GrabInput (SDL_GRAB_QUERY); | 48 mode = SDL_WM_GrabInput(SDL_GRAB_QUERY); |
49 if (mode == SDL_GRAB_ON) { | 49 if (mode == SDL_GRAB_ON) { |
50 printf ("Grab was on\n"); | 50 printf("Grab was on\n"); |
51 } else { | 51 } else { |
52 printf ("Grab was off\n"); | 52 printf("Grab was off\n"); |
53 } | 53 } |
54 mode = SDL_WM_GrabInput (!mode); | 54 mode = SDL_WM_GrabInput(!mode); |
55 if (mode == SDL_GRAB_ON) { | 55 if (mode == SDL_GRAB_ON) { |
56 printf ("Grab is now on\n"); | 56 printf("Grab is now on\n"); |
57 } else { | 57 } else { |
58 printf ("Grab is now off\n"); | 58 printf("Grab is now off\n"); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 void | 62 void |
63 HotKey_Iconify (void) | 63 HotKey_Iconify(void) |
64 { | 64 { |
65 printf ("Ctrl-Z: iconifying window!\n"); | 65 printf("Ctrl-Z: iconifying window!\n"); |
66 SDL_WM_IconifyWindow (); | 66 SDL_WM_IconifyWindow(); |
67 } | 67 } |
68 | 68 |
69 int | 69 int |
70 HandleEvent (SDL_Event * event) | 70 HandleEvent(SDL_Event * event) |
71 { | 71 { |
72 int done; | 72 int done; |
73 | 73 |
74 done = 0; | 74 done = 0; |
75 switch (event->type) { | 75 switch (event->type) { |
76 case SDL_ACTIVEEVENT: | 76 case SDL_ACTIVEEVENT: |
77 /* See what happened */ | 77 /* See what happened */ |
78 printf ("app %s ", event->active.gain ? "gained" : "lost"); | 78 printf("app %s ", event->active.gain ? "gained" : "lost"); |
79 if (event->active.state & SDL_APPACTIVE) { | 79 if (event->active.state & SDL_APPACTIVE) { |
80 printf ("active "); | 80 printf("active "); |
81 } else if (event->active.state & SDL_APPMOUSEFOCUS) { | 81 } else if (event->active.state & SDL_APPMOUSEFOCUS) { |
82 printf ("mouse "); | 82 printf("mouse "); |
83 } else if (event->active.state & SDL_APPINPUTFOCUS) { | 83 } else if (event->active.state & SDL_APPINPUTFOCUS) { |
84 printf ("input "); | 84 printf("input "); |
85 } | 85 } |
86 printf ("focus\n"); | 86 printf("focus\n"); |
87 break; | 87 break; |
88 | 88 |
89 | 89 |
90 case SDL_KEYDOWN: | 90 case SDL_KEYDOWN: |
91 if (event->key.keysym.sym == SDLK_ESCAPE) { | 91 if (event->key.keysym.sym == SDLK_ESCAPE) { |
92 done = 1; | 92 done = 1; |
93 } | 93 } |
94 if ((event->key.keysym.sym == SDLK_g) && | 94 if ((event->key.keysym.sym == SDLK_g) && |
95 (event->key.keysym.mod & KMOD_CTRL)) { | 95 (event->key.keysym.mod & KMOD_CTRL)) { |
96 HotKey_ToggleGrab (); | 96 HotKey_ToggleGrab(); |
97 } | 97 } |
98 if ((event->key.keysym.sym == SDLK_z) && | 98 if ((event->key.keysym.sym == SDLK_z) && |
99 (event->key.keysym.mod & KMOD_CTRL)) { | 99 (event->key.keysym.mod & KMOD_CTRL)) { |
100 HotKey_Iconify (); | 100 HotKey_Iconify(); |
101 } | 101 } |
102 if ((event->key.keysym.sym == SDLK_RETURN) && | 102 if ((event->key.keysym.sym == SDLK_RETURN) && |
103 (event->key.keysym.mod & KMOD_ALT)) { | 103 (event->key.keysym.mod & KMOD_ALT)) { |
104 HotKey_ToggleFullScreen (); | 104 HotKey_ToggleFullScreen(); |
105 } | 105 } |
106 printf ("key '%s' pressed\n", SDL_GetKeyName (event->key.keysym.sym)); | 106 printf("key '%s' pressed\n", SDL_GetKeyName(event->key.keysym.sym)); |
107 break; | 107 break; |
108 case SDL_QUIT: | 108 case SDL_QUIT: |
109 done = 1; | 109 done = 1; |
110 break; | 110 break; |
111 } | 111 } |
112 return (done); | 112 return (done); |
113 } | 113 } |
114 | 114 |
115 void | 115 void |
116 SDL_GL_Enter2DMode () | 116 SDL_GL_Enter2DMode() |
117 { | 117 { |
118 SDL_Surface *screen = SDL_GetVideoSurface (); | 118 SDL_Surface *screen = SDL_GetVideoSurface(); |
119 | 119 |
120 /* Note, there may be other things you need to change, | 120 /* Note, there may be other things you need to change, |
121 depending on how you have your OpenGL state set up. | 121 depending on how you have your OpenGL state set up. |
122 */ | 122 */ |
123 glPushAttrib (GL_ENABLE_BIT); | 123 glPushAttrib(GL_ENABLE_BIT); |
124 glDisable (GL_DEPTH_TEST); | 124 glDisable(GL_DEPTH_TEST); |
125 glDisable (GL_CULL_FACE); | 125 glDisable(GL_CULL_FACE); |
126 glEnable (GL_TEXTURE_2D); | 126 glEnable(GL_TEXTURE_2D); |
127 | 127 |
128 /* This allows alpha blending of 2D textures with the scene */ | 128 /* This allows alpha blending of 2D textures with the scene */ |
129 glEnable (GL_BLEND); | 129 glEnable(GL_BLEND); |
130 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 130 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
131 | 131 |
132 glViewport (0, 0, screen->w, screen->h); | 132 glViewport(0, 0, screen->w, screen->h); |
133 | 133 |
134 glMatrixMode (GL_PROJECTION); | 134 glMatrixMode(GL_PROJECTION); |
135 glPushMatrix (); | 135 glPushMatrix(); |
136 glLoadIdentity (); | 136 glLoadIdentity(); |
137 | 137 |
138 glOrtho (0.0, (GLdouble) screen->w, (GLdouble) screen->h, 0.0, 0.0, 1.0); | 138 glOrtho(0.0, (GLdouble) screen->w, (GLdouble) screen->h, 0.0, 0.0, 1.0); |
139 | 139 |
140 glMatrixMode (GL_MODELVIEW); | 140 glMatrixMode(GL_MODELVIEW); |
141 glPushMatrix (); | 141 glPushMatrix(); |
142 glLoadIdentity (); | 142 glLoadIdentity(); |
143 | 143 |
144 glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); | 144 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); |
145 } | 145 } |
146 | 146 |
147 void | 147 void |
148 SDL_GL_Leave2DMode () | 148 SDL_GL_Leave2DMode() |
149 { | 149 { |
150 glMatrixMode (GL_MODELVIEW); | 150 glMatrixMode(GL_MODELVIEW); |
151 glPopMatrix (); | 151 glPopMatrix(); |
152 | 152 |
153 glMatrixMode (GL_PROJECTION); | 153 glMatrixMode(GL_PROJECTION); |
154 glPopMatrix (); | 154 glPopMatrix(); |
155 | 155 |
156 glPopAttrib (); | 156 glPopAttrib(); |
157 } | 157 } |
158 | 158 |
159 /* Quick utility function for texture creation */ | 159 /* Quick utility function for texture creation */ |
160 static int | 160 static int |
161 power_of_two (int input) | 161 power_of_two(int input) |
162 { | 162 { |
163 int value = 1; | 163 int value = 1; |
164 | 164 |
165 while (value < input) { | 165 while (value < input) { |
166 value <<= 1; | 166 value <<= 1; |
167 } | 167 } |
168 return value; | 168 return value; |
169 } | 169 } |
170 | 170 |
171 GLuint | 171 GLuint |
172 SDL_GL_LoadTexture (SDL_Surface * surface, GLfloat * texcoord) | 172 SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord) |
173 { | 173 { |
174 GLuint texture; | 174 GLuint texture; |
175 int w, h; | 175 int w, h; |
176 SDL_Surface *image; | 176 SDL_Surface *image; |
177 SDL_Rect area; | 177 SDL_Rect area; |
178 Uint32 saved_flags; | 178 Uint32 saved_flags; |
179 Uint8 saved_alpha; | 179 Uint8 saved_alpha; |
180 | 180 |
181 /* Use the surface width and height expanded to powers of 2 */ | 181 /* Use the surface width and height expanded to powers of 2 */ |
182 w = power_of_two (surface->w); | 182 w = power_of_two(surface->w); |
183 h = power_of_two (surface->h); | 183 h = power_of_two(surface->h); |
184 texcoord[0] = 0.0f; /* Min X */ | 184 texcoord[0] = 0.0f; /* Min X */ |
185 texcoord[1] = 0.0f; /* Min Y */ | 185 texcoord[1] = 0.0f; /* Min Y */ |
186 texcoord[2] = (GLfloat) surface->w / w; /* Max X */ | 186 texcoord[2] = (GLfloat) surface->w / w; /* Max X */ |
187 texcoord[3] = (GLfloat) surface->h / h; /* Max Y */ | 187 texcoord[3] = (GLfloat) surface->h / h; /* Max Y */ |
188 | 188 |
189 image = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 32, | 189 image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, |
190 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ | 190 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ |
191 0x000000FF, | 191 0x000000FF, |
192 0x0000FF00, 0x00FF0000, 0xFF000000 | 192 0x0000FF00, 0x00FF0000, 0xFF000000 |
193 #else | 193 #else |
194 0xFF000000, | 194 0xFF000000, |
195 0x00FF0000, 0x0000FF00, 0x000000FF | 195 0x00FF0000, 0x0000FF00, 0x000000FF |
196 #endif | 196 #endif |
197 ); | 197 ); |
198 if (image == NULL) { | 198 if (image == NULL) { |
199 return 0; | 199 return 0; |
200 } | 200 } |
201 | 201 |
202 /* Save the alpha blending attributes */ | 202 /* Save the alpha blending attributes */ |
203 saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); | 203 saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); |
204 saved_alpha = surface->format->alpha; | 204 saved_alpha = surface->format->alpha; |
205 if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { | 205 if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { |
206 SDL_SetAlpha (surface, 0, 0); | 206 SDL_SetAlpha(surface, 0, 0); |
207 } | 207 } |
208 | 208 |
209 /* Copy the surface into the GL texture image */ | 209 /* Copy the surface into the GL texture image */ |
210 area.x = 0; | 210 area.x = 0; |
211 area.y = 0; | 211 area.y = 0; |
212 area.w = surface->w; | 212 area.w = surface->w; |
213 area.h = surface->h; | 213 area.h = surface->h; |
214 SDL_BlitSurface (surface, &area, image, &area); | 214 SDL_BlitSurface(surface, &area, image, &area); |
215 | 215 |
216 /* Restore the alpha blending attributes */ | 216 /* Restore the alpha blending attributes */ |
217 if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { | 217 if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { |
218 SDL_SetAlpha (surface, saved_flags, saved_alpha); | 218 SDL_SetAlpha(surface, saved_flags, saved_alpha); |
219 } | 219 } |
220 | 220 |
221 /* Create an OpenGL texture for the image */ | 221 /* Create an OpenGL texture for the image */ |
222 glGenTextures (1, &texture); | 222 glGenTextures(1, &texture); |
223 glBindTexture (GL_TEXTURE_2D, texture); | 223 glBindTexture(GL_TEXTURE_2D, texture); |
224 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 224 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
225 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 225 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
226 glTexImage2D (GL_TEXTURE_2D, | 226 glTexImage2D(GL_TEXTURE_2D, |
227 0, | 227 0, |
228 GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); | 228 GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); |
229 SDL_FreeSurface (image); /* No longer needed */ | 229 SDL_FreeSurface(image); /* No longer needed */ |
230 | 230 |
231 return texture; | 231 return texture; |
232 } | 232 } |
233 | 233 |
234 void | 234 void |
235 DrawLogoCursor (void) | 235 DrawLogoCursor(void) |
236 { | 236 { |
237 static GLfloat texMinX, texMinY; | 237 static GLfloat texMinX, texMinY; |
238 static GLfloat texMaxX, texMaxY; | 238 static GLfloat texMaxX, texMaxY; |
239 static int w, h; | 239 static int w, h; |
240 int x, y; | 240 int x, y; |
242 if (!cursor_texture) { | 242 if (!cursor_texture) { |
243 SDL_Surface *image; | 243 SDL_Surface *image; |
244 GLfloat texcoord[4]; | 244 GLfloat texcoord[4]; |
245 | 245 |
246 /* Load the image (could use SDL_image library here) */ | 246 /* Load the image (could use SDL_image library here) */ |
247 image = SDL_LoadBMP (LOGO_FILE); | 247 image = SDL_LoadBMP(LOGO_FILE); |
248 if (image == NULL) { | 248 if (image == NULL) { |
249 return; | 249 return; |
250 } | 250 } |
251 w = image->w; | 251 w = image->w; |
252 h = image->h; | 252 h = image->h; |
253 | 253 |
254 /* Convert the image into an OpenGL texture */ | 254 /* Convert the image into an OpenGL texture */ |
255 cursor_texture = SDL_GL_LoadTexture (image, texcoord); | 255 cursor_texture = SDL_GL_LoadTexture(image, texcoord); |
256 | 256 |
257 /* Make texture coordinates easy to understand */ | 257 /* Make texture coordinates easy to understand */ |
258 texMinX = texcoord[0]; | 258 texMinX = texcoord[0]; |
259 texMinY = texcoord[1]; | 259 texMinY = texcoord[1]; |
260 texMaxX = texcoord[2]; | 260 texMaxX = texcoord[2]; |
261 texMaxY = texcoord[3]; | 261 texMaxY = texcoord[3]; |
262 | 262 |
263 /* We don't need the original image anymore */ | 263 /* We don't need the original image anymore */ |
264 SDL_FreeSurface (image); | 264 SDL_FreeSurface(image); |
265 | 265 |
266 /* Make sure that the texture conversion is okay */ | 266 /* Make sure that the texture conversion is okay */ |
267 if (!cursor_texture) { | 267 if (!cursor_texture) { |
268 return; | 268 return; |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 /* Move the image around */ | 272 /* Move the image around */ |
273 SDL_GetMouseState (&x, &y); | 273 SDL_GetMouseState(&x, &y); |
274 x -= w / 2; | 274 x -= w / 2; |
275 y -= h / 2; | 275 y -= h / 2; |
276 | 276 |
277 /* Show the image on the screen */ | 277 /* Show the image on the screen */ |
278 SDL_GL_Enter2DMode (); | 278 SDL_GL_Enter2DMode(); |
279 glBindTexture (GL_TEXTURE_2D, cursor_texture); | 279 glBindTexture(GL_TEXTURE_2D, cursor_texture); |
280 glBegin (GL_TRIANGLE_STRIP); | 280 glBegin(GL_TRIANGLE_STRIP); |
281 glTexCoord2f (texMinX, texMinY); | 281 glTexCoord2f(texMinX, texMinY); |
282 glVertex2i (x, y); | 282 glVertex2i(x, y); |
283 glTexCoord2f (texMaxX, texMinY); | 283 glTexCoord2f(texMaxX, texMinY); |
284 glVertex2i (x + w, y); | 284 glVertex2i(x + w, y); |
285 glTexCoord2f (texMinX, texMaxY); | 285 glTexCoord2f(texMinX, texMaxY); |
286 glVertex2i (x, y + h); | 286 glVertex2i(x, y + h); |
287 glTexCoord2f (texMaxX, texMaxY); | 287 glTexCoord2f(texMaxX, texMaxY); |
288 glVertex2i (x + w, y + h); | 288 glVertex2i(x + w, y + h); |
289 glEnd (); | 289 glEnd(); |
290 SDL_GL_Leave2DMode (); | 290 SDL_GL_Leave2DMode(); |
291 } | 291 } |
292 | 292 |
293 void | 293 void |
294 DrawLogoTexture (void) | 294 DrawLogoTexture(void) |
295 { | 295 { |
296 static GLfloat texMinX, texMinY; | 296 static GLfloat texMinX, texMinY; |
297 static GLfloat texMaxX, texMaxY; | 297 static GLfloat texMaxX, texMaxY; |
298 static int x = 0; | 298 static int x = 0; |
299 static int y = 0; | 299 static int y = 0; |
300 static int w, h; | 300 static int w, h; |
301 static int delta_x = 1; | 301 static int delta_x = 1; |
302 static int delta_y = 1; | 302 static int delta_y = 1; |
303 | 303 |
304 SDL_Surface *screen = SDL_GetVideoSurface (); | 304 SDL_Surface *screen = SDL_GetVideoSurface(); |
305 | 305 |
306 if (!global_texture) { | 306 if (!global_texture) { |
307 SDL_Surface *image; | 307 SDL_Surface *image; |
308 GLfloat texcoord[4]; | 308 GLfloat texcoord[4]; |
309 | 309 |
310 /* Load the image (could use SDL_image library here) */ | 310 /* Load the image (could use SDL_image library here) */ |
311 image = SDL_LoadBMP (LOGO_FILE); | 311 image = SDL_LoadBMP(LOGO_FILE); |
312 if (image == NULL) { | 312 if (image == NULL) { |
313 return; | 313 return; |
314 } | 314 } |
315 w = image->w; | 315 w = image->w; |
316 h = image->h; | 316 h = image->h; |
317 | 317 |
318 /* Convert the image into an OpenGL texture */ | 318 /* Convert the image into an OpenGL texture */ |
319 global_texture = SDL_GL_LoadTexture (image, texcoord); | 319 global_texture = SDL_GL_LoadTexture(image, texcoord); |
320 | 320 |
321 /* Make texture coordinates easy to understand */ | 321 /* Make texture coordinates easy to understand */ |
322 texMinX = texcoord[0]; | 322 texMinX = texcoord[0]; |
323 texMinY = texcoord[1]; | 323 texMinY = texcoord[1]; |
324 texMaxX = texcoord[2]; | 324 texMaxX = texcoord[2]; |
325 texMaxY = texcoord[3]; | 325 texMaxY = texcoord[3]; |
326 | 326 |
327 /* We don't need the original image anymore */ | 327 /* We don't need the original image anymore */ |
328 SDL_FreeSurface (image); | 328 SDL_FreeSurface(image); |
329 | 329 |
330 /* Make sure that the texture conversion is okay */ | 330 /* Make sure that the texture conversion is okay */ |
331 if (!global_texture) { | 331 if (!global_texture) { |
332 return; | 332 return; |
333 } | 333 } |
350 y = screen->h - h; | 350 y = screen->h - h; |
351 delta_y = -delta_y; | 351 delta_y = -delta_y; |
352 } | 352 } |
353 | 353 |
354 /* Show the image on the screen */ | 354 /* Show the image on the screen */ |
355 SDL_GL_Enter2DMode (); | 355 SDL_GL_Enter2DMode(); |
356 glBindTexture (GL_TEXTURE_2D, global_texture); | 356 glBindTexture(GL_TEXTURE_2D, global_texture); |
357 glBegin (GL_TRIANGLE_STRIP); | 357 glBegin(GL_TRIANGLE_STRIP); |
358 glTexCoord2f (texMinX, texMinY); | 358 glTexCoord2f(texMinX, texMinY); |
359 glVertex2i (x, y); | 359 glVertex2i(x, y); |
360 glTexCoord2f (texMaxX, texMinY); | 360 glTexCoord2f(texMaxX, texMinY); |
361 glVertex2i (x + w, y); | 361 glVertex2i(x + w, y); |
362 glTexCoord2f (texMinX, texMaxY); | 362 glTexCoord2f(texMinX, texMaxY); |
363 glVertex2i (x, y + h); | 363 glVertex2i(x, y + h); |
364 glTexCoord2f (texMaxX, texMaxY); | 364 glTexCoord2f(texMaxX, texMaxY); |
365 glVertex2i (x + w, y + h); | 365 glVertex2i(x + w, y + h); |
366 glEnd (); | 366 glEnd(); |
367 SDL_GL_Leave2DMode (); | 367 SDL_GL_Leave2DMode(); |
368 } | 368 } |
369 | 369 |
370 int | 370 int |
371 RunGLTest (int argc, char *argv[], | 371 RunGLTest(int argc, char *argv[], |
372 int logo, int logocursor, int slowly, int bpp, float gamma, | 372 int logo, int logocursor, int slowly, int bpp, float gamma, |
373 int noframe, int fsaa, int sync, int accel) | 373 int noframe, int fsaa, int sync, int accel) |
374 { | 374 { |
375 int i; | 375 int i; |
376 int rgb_size[3]; | 376 int rgb_size[3]; |
377 int w = 640; | 377 int w = 640; |
378 int h = 480; | 378 int h = 480; |
398 {-0.5, -0.5, 0.5} | 398 {-0.5, -0.5, 0.5} |
399 }; | 399 }; |
400 Uint32 video_flags; | 400 Uint32 video_flags; |
401 int value; | 401 int value; |
402 | 402 |
403 if (SDL_Init (SDL_INIT_VIDEO) < 0) { | 403 if (SDL_Init(SDL_INIT_VIDEO) < 0) { |
404 fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); | 404 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); |
405 exit (1); | 405 exit(1); |
406 } | 406 } |
407 | 407 |
408 /* See if we should detect the display depth */ | 408 /* See if we should detect the display depth */ |
409 if (bpp == 0) { | 409 if (bpp == 0) { |
410 if (SDL_GetVideoInfo ()->vfmt->BitsPerPixel <= 8) { | 410 if (SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8) { |
411 bpp = 8; | 411 bpp = 8; |
412 } else { | 412 } else { |
413 bpp = 16; /* More doesn't seem to work */ | 413 bpp = 16; /* More doesn't seem to work */ |
414 } | 414 } |
415 } | 415 } |
416 | 416 |
417 /* Set the flags we want to use for setting the video mode */ | 417 /* Set the flags we want to use for setting the video mode */ |
418 video_flags = SDL_OPENGL; | 418 video_flags = SDL_OPENGL; |
419 for (i = 1; argv[i]; ++i) { | 419 for (i = 1; argv[i]; ++i) { |
420 if (strcmp (argv[i], "-fullscreen") == 0) { | 420 if (strcmp(argv[i], "-fullscreen") == 0) { |
421 video_flags |= SDL_FULLSCREEN; | 421 video_flags |= SDL_FULLSCREEN; |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
425 if (noframe) { | 425 if (noframe) { |
443 rgb_size[0] = 8; | 443 rgb_size[0] = 8; |
444 rgb_size[1] = 8; | 444 rgb_size[1] = 8; |
445 rgb_size[2] = 8; | 445 rgb_size[2] = 8; |
446 break; | 446 break; |
447 } | 447 } |
448 SDL_GL_SetAttribute (SDL_GL_RED_SIZE, rgb_size[0]); | 448 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]); |
449 SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, rgb_size[1]); | 449 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]); |
450 SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, rgb_size[2]); | 450 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]); |
451 SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16); | 451 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); |
452 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); | 452 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
453 if (fsaa) { | 453 if (fsaa) { |
454 SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1); | 454 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); |
455 SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, fsaa); | 455 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); |
456 } | 456 } |
457 if (accel) { | 457 if (accel) { |
458 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); | 458 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); |
459 } | 459 } |
460 if (sync) { | 460 if (sync) { |
461 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); | 461 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); |
462 } else { | 462 } else { |
463 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 0); | 463 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0); |
464 } | 464 } |
465 if (SDL_SetVideoMode (w, h, bpp, video_flags) == NULL) { | 465 if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) { |
466 fprintf (stderr, "Couldn't set GL mode: %s\n", SDL_GetError ()); | 466 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); |
467 SDL_Quit (); | 467 SDL_Quit(); |
468 exit (1); | 468 exit(1); |
469 } | 469 } |
470 | 470 |
471 printf ("Screen BPP: %d\n", SDL_GetVideoSurface ()->format->BitsPerPixel); | 471 printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel); |
472 printf ("\n"); | 472 printf("\n"); |
473 printf ("Vendor : %s\n", glGetString (GL_VENDOR)); | 473 printf("Vendor : %s\n", glGetString(GL_VENDOR)); |
474 printf ("Renderer : %s\n", glGetString (GL_RENDERER)); | 474 printf("Renderer : %s\n", glGetString(GL_RENDERER)); |
475 printf ("Version : %s\n", glGetString (GL_VERSION)); | 475 printf("Version : %s\n", glGetString(GL_VERSION)); |
476 printf ("Extensions : %s\n", glGetString (GL_EXTENSIONS)); | 476 printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); |
477 printf ("\n"); | 477 printf("\n"); |
478 | 478 |
479 SDL_GL_GetAttribute (SDL_GL_RED_SIZE, &value); | 479 SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); |
480 printf ("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value); | 480 printf("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value); |
481 SDL_GL_GetAttribute (SDL_GL_GREEN_SIZE, &value); | 481 SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); |
482 printf ("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value); | 482 printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value); |
483 SDL_GL_GetAttribute (SDL_GL_BLUE_SIZE, &value); | 483 SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); |
484 printf ("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value); | 484 printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value); |
485 SDL_GL_GetAttribute (SDL_GL_DEPTH_SIZE, &value); | 485 SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); |
486 printf ("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value); | 486 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value); |
487 SDL_GL_GetAttribute (SDL_GL_DOUBLEBUFFER, &value); | 487 SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &value); |
488 printf ("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); | 488 printf("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); |
489 if (fsaa) { | 489 if (fsaa) { |
490 SDL_GL_GetAttribute (SDL_GL_MULTISAMPLEBUFFERS, &value); | 490 SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); |
491 printf ("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); | 491 printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); |
492 SDL_GL_GetAttribute (SDL_GL_MULTISAMPLESAMPLES, &value); | 492 SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); |
493 printf ("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, | 493 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, |
494 value); | 494 value); |
495 } | 495 } |
496 if (accel) { | 496 if (accel) { |
497 SDL_GL_GetAttribute (SDL_GL_ACCELERATED_VISUAL, &value); | 497 SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
498 printf ("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); | 498 printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); |
499 } | 499 } |
500 if (sync) { | 500 if (sync) { |
501 SDL_GL_GetAttribute (SDL_GL_SWAP_CONTROL, &value); | 501 SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &value); |
502 printf ("SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value); | 502 printf("SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value); |
503 } | 503 } |
504 | 504 |
505 /* Set the window manager title bar */ | 505 /* Set the window manager title bar */ |
506 SDL_WM_SetCaption ("SDL GL test", "testgl"); | 506 SDL_WM_SetCaption("SDL GL test", "testgl"); |
507 | 507 |
508 /* Set the gamma for the window */ | 508 /* Set the gamma for the window */ |
509 if (gamma != 0.0) { | 509 if (gamma != 0.0) { |
510 SDL_SetGamma (gamma, gamma, gamma); | 510 SDL_SetGamma(gamma, gamma, gamma); |
511 } | 511 } |
512 | 512 |
513 glViewport (0, 0, w, h); | 513 glViewport(0, 0, w, h); |
514 glMatrixMode (GL_PROJECTION); | 514 glMatrixMode(GL_PROJECTION); |
515 glLoadIdentity (); | 515 glLoadIdentity(); |
516 | 516 |
517 glOrtho (-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); | 517 glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); |
518 | 518 |
519 glMatrixMode (GL_MODELVIEW); | 519 glMatrixMode(GL_MODELVIEW); |
520 glLoadIdentity (); | 520 glLoadIdentity(); |
521 | 521 |
522 glEnable (GL_DEPTH_TEST); | 522 glEnable(GL_DEPTH_TEST); |
523 | 523 |
524 glDepthFunc (GL_LESS); | 524 glDepthFunc(GL_LESS); |
525 | 525 |
526 glShadeModel (GL_SMOOTH); | 526 glShadeModel(GL_SMOOTH); |
527 | 527 |
528 /* Loop until done. */ | 528 /* Loop until done. */ |
529 start_time = SDL_GetTicks (); | 529 start_time = SDL_GetTicks(); |
530 frames = 0; | 530 frames = 0; |
531 while (!done) { | 531 while (!done) { |
532 GLenum gl_error; | 532 GLenum gl_error; |
533 char *sdl_error; | 533 char *sdl_error; |
534 SDL_Event event; | 534 SDL_Event event; |
535 | 535 |
536 /* Do our drawing, too. */ | 536 /* Do our drawing, too. */ |
537 glClearColor (0.0, 0.0, 0.0, 1.0); | 537 glClearColor(0.0, 0.0, 0.0, 1.0); |
538 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 538 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
539 | 539 |
540 glBegin (GL_QUADS); | 540 glBegin(GL_QUADS); |
541 | 541 |
542 #ifdef SHADED_CUBE | 542 #ifdef SHADED_CUBE |
543 glColor3fv (color[0]); | 543 glColor3fv(color[0]); |
544 glVertex3fv (cube[0]); | 544 glVertex3fv(cube[0]); |
545 glColor3fv (color[1]); | 545 glColor3fv(color[1]); |
546 glVertex3fv (cube[1]); | 546 glVertex3fv(cube[1]); |
547 glColor3fv (color[2]); | 547 glColor3fv(color[2]); |
548 glVertex3fv (cube[2]); | 548 glVertex3fv(cube[2]); |
549 glColor3fv (color[3]); | 549 glColor3fv(color[3]); |
550 glVertex3fv (cube[3]); | 550 glVertex3fv(cube[3]); |
551 | 551 |
552 glColor3fv (color[3]); | 552 glColor3fv(color[3]); |
553 glVertex3fv (cube[3]); | 553 glVertex3fv(cube[3]); |
554 glColor3fv (color[4]); | 554 glColor3fv(color[4]); |
555 glVertex3fv (cube[4]); | 555 glVertex3fv(cube[4]); |
556 glColor3fv (color[7]); | 556 glColor3fv(color[7]); |
557 glVertex3fv (cube[7]); | 557 glVertex3fv(cube[7]); |
558 glColor3fv (color[2]); | 558 glColor3fv(color[2]); |
559 glVertex3fv (cube[2]); | 559 glVertex3fv(cube[2]); |
560 | 560 |
561 glColor3fv (color[0]); | 561 glColor3fv(color[0]); |
562 glVertex3fv (cube[0]); | 562 glVertex3fv(cube[0]); |
563 glColor3fv (color[5]); | 563 glColor3fv(color[5]); |
564 glVertex3fv (cube[5]); | 564 glVertex3fv(cube[5]); |
565 glColor3fv (color[6]); | 565 glColor3fv(color[6]); |
566 glVertex3fv (cube[6]); | 566 glVertex3fv(cube[6]); |
567 glColor3fv (color[1]); | 567 glColor3fv(color[1]); |
568 glVertex3fv (cube[1]); | 568 glVertex3fv(cube[1]); |
569 | 569 |
570 glColor3fv (color[5]); | 570 glColor3fv(color[5]); |
571 glVertex3fv (cube[5]); | 571 glVertex3fv(cube[5]); |
572 glColor3fv (color[4]); | 572 glColor3fv(color[4]); |
573 glVertex3fv (cube[4]); | 573 glVertex3fv(cube[4]); |
574 glColor3fv (color[7]); | 574 glColor3fv(color[7]); |
575 glVertex3fv (cube[7]); | 575 glVertex3fv(cube[7]); |
576 glColor3fv (color[6]); | 576 glColor3fv(color[6]); |
577 glVertex3fv (cube[6]); | 577 glVertex3fv(cube[6]); |
578 | 578 |
579 glColor3fv (color[5]); | 579 glColor3fv(color[5]); |
580 glVertex3fv (cube[5]); | 580 glVertex3fv(cube[5]); |
581 glColor3fv (color[0]); | 581 glColor3fv(color[0]); |
582 glVertex3fv (cube[0]); | 582 glVertex3fv(cube[0]); |
583 glColor3fv (color[3]); | 583 glColor3fv(color[3]); |
584 glVertex3fv (cube[3]); | 584 glVertex3fv(cube[3]); |
585 glColor3fv (color[4]); | 585 glColor3fv(color[4]); |
586 glVertex3fv (cube[4]); | 586 glVertex3fv(cube[4]); |
587 | 587 |
588 glColor3fv (color[6]); | 588 glColor3fv(color[6]); |
589 glVertex3fv (cube[6]); | 589 glVertex3fv(cube[6]); |
590 glColor3fv (color[1]); | 590 glColor3fv(color[1]); |
591 glVertex3fv (cube[1]); | 591 glVertex3fv(cube[1]); |
592 glColor3fv (color[2]); | 592 glColor3fv(color[2]); |
593 glVertex3fv (cube[2]); | 593 glVertex3fv(cube[2]); |
594 glColor3fv (color[7]); | 594 glColor3fv(color[7]); |
595 glVertex3fv (cube[7]); | 595 glVertex3fv(cube[7]); |
596 #else /* flat cube */ | 596 #else /* flat cube */ |
597 glColor3f (1.0, 0.0, 0.0); | 597 glColor3f(1.0, 0.0, 0.0); |
598 glVertex3fv (cube[0]); | 598 glVertex3fv(cube[0]); |
599 glVertex3fv (cube[1]); | 599 glVertex3fv(cube[1]); |
600 glVertex3fv (cube[2]); | 600 glVertex3fv(cube[2]); |
601 glVertex3fv (cube[3]); | 601 glVertex3fv(cube[3]); |
602 | 602 |
603 glColor3f (0.0, 1.0, 0.0); | 603 glColor3f(0.0, 1.0, 0.0); |
604 glVertex3fv (cube[3]); | 604 glVertex3fv(cube[3]); |
605 glVertex3fv (cube[4]); | 605 glVertex3fv(cube[4]); |
606 glVertex3fv (cube[7]); | 606 glVertex3fv(cube[7]); |
607 glVertex3fv (cube[2]); | 607 glVertex3fv(cube[2]); |
608 | 608 |
609 glColor3f (0.0, 0.0, 1.0); | 609 glColor3f(0.0, 0.0, 1.0); |
610 glVertex3fv (cube[0]); | 610 glVertex3fv(cube[0]); |
611 glVertex3fv (cube[5]); | 611 glVertex3fv(cube[5]); |
612 glVertex3fv (cube[6]); | 612 glVertex3fv(cube[6]); |
613 glVertex3fv (cube[1]); | 613 glVertex3fv(cube[1]); |
614 | 614 |
615 glColor3f (0.0, 1.0, 1.0); | 615 glColor3f(0.0, 1.0, 1.0); |
616 glVertex3fv (cube[5]); | 616 glVertex3fv(cube[5]); |
617 glVertex3fv (cube[4]); | 617 glVertex3fv(cube[4]); |
618 glVertex3fv (cube[7]); | 618 glVertex3fv(cube[7]); |
619 glVertex3fv (cube[6]); | 619 glVertex3fv(cube[6]); |
620 | 620 |
621 glColor3f (1.0, 1.0, 0.0); | 621 glColor3f(1.0, 1.0, 0.0); |
622 glVertex3fv (cube[5]); | 622 glVertex3fv(cube[5]); |
623 glVertex3fv (cube[0]); | 623 glVertex3fv(cube[0]); |
624 glVertex3fv (cube[3]); | 624 glVertex3fv(cube[3]); |
625 glVertex3fv (cube[4]); | 625 glVertex3fv(cube[4]); |
626 | 626 |
627 glColor3f (1.0, 0.0, 1.0); | 627 glColor3f(1.0, 0.0, 1.0); |
628 glVertex3fv (cube[6]); | 628 glVertex3fv(cube[6]); |
629 glVertex3fv (cube[1]); | 629 glVertex3fv(cube[1]); |
630 glVertex3fv (cube[2]); | 630 glVertex3fv(cube[2]); |
631 glVertex3fv (cube[7]); | 631 glVertex3fv(cube[7]); |
632 #endif /* SHADED_CUBE */ | 632 #endif /* SHADED_CUBE */ |
633 | 633 |
634 glEnd (); | 634 glEnd(); |
635 | 635 |
636 glMatrixMode (GL_MODELVIEW); | 636 glMatrixMode(GL_MODELVIEW); |
637 glRotatef (5.0, 1.0, 1.0, 1.0); | 637 glRotatef(5.0, 1.0, 1.0, 1.0); |
638 | 638 |
639 /* Draw 2D logo onto the 3D display */ | 639 /* Draw 2D logo onto the 3D display */ |
640 if (logo) { | 640 if (logo) { |
641 DrawLogoTexture (); | 641 DrawLogoTexture(); |
642 } | 642 } |
643 if (logocursor) { | 643 if (logocursor) { |
644 DrawLogoCursor (); | 644 DrawLogoCursor(); |
645 } | 645 } |
646 | 646 |
647 SDL_GL_SwapBuffers (); | 647 SDL_GL_SwapBuffers(); |
648 | 648 |
649 /* Check for error conditions. */ | 649 /* Check for error conditions. */ |
650 gl_error = glGetError (); | 650 gl_error = glGetError(); |
651 | 651 |
652 if (gl_error != GL_NO_ERROR) { | 652 if (gl_error != GL_NO_ERROR) { |
653 fprintf (stderr, "testgl: OpenGL error: %d\n", gl_error); | 653 fprintf(stderr, "testgl: OpenGL error: %d\n", gl_error); |
654 } | 654 } |
655 | 655 |
656 sdl_error = SDL_GetError (); | 656 sdl_error = SDL_GetError(); |
657 | 657 |
658 if (sdl_error[0] != '\0') { | 658 if (sdl_error[0] != '\0') { |
659 fprintf (stderr, "testgl: SDL error '%s'\n", sdl_error); | 659 fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error); |
660 SDL_ClearError (); | 660 SDL_ClearError(); |
661 } | 661 } |
662 | 662 |
663 /* Allow the user to see what's happening */ | 663 /* Allow the user to see what's happening */ |
664 if (slowly) { | 664 if (slowly) { |
665 SDL_Delay (20); | 665 SDL_Delay(20); |
666 } | 666 } |
667 | 667 |
668 /* Check if there's a pending event. */ | 668 /* Check if there's a pending event. */ |
669 while (SDL_PollEvent (&event)) { | 669 while (SDL_PollEvent(&event)) { |
670 done = HandleEvent (&event); | 670 done = HandleEvent(&event); |
671 } | 671 } |
672 ++frames; | 672 ++frames; |
673 } | 673 } |
674 | 674 |
675 /* Print out the frames per second */ | 675 /* Print out the frames per second */ |
676 this_time = SDL_GetTicks (); | 676 this_time = SDL_GetTicks(); |
677 if (this_time != start_time) { | 677 if (this_time != start_time) { |
678 printf ("%2.2f FPS\n", | 678 printf("%2.2f FPS\n", |
679 ((float) frames / (this_time - start_time)) * 1000.0); | 679 ((float) frames / (this_time - start_time)) * 1000.0); |
680 } | 680 } |
681 | 681 |
682 if (global_image) { | 682 if (global_image) { |
683 SDL_FreeSurface (global_image); | 683 SDL_FreeSurface(global_image); |
684 global_image = NULL; | 684 global_image = NULL; |
685 } | 685 } |
686 if (global_texture) { | 686 if (global_texture) { |
687 glDeleteTextures (1, &global_texture); | 687 glDeleteTextures(1, &global_texture); |
688 global_texture = 0; | 688 global_texture = 0; |
689 } | 689 } |
690 if (cursor_texture) { | 690 if (cursor_texture) { |
691 glDeleteTextures (1, &cursor_texture); | 691 glDeleteTextures(1, &cursor_texture); |
692 cursor_texture = 0; | 692 cursor_texture = 0; |
693 } | 693 } |
694 | 694 |
695 /* Destroy our GL context, etc. */ | 695 /* Destroy our GL context, etc. */ |
696 SDL_Quit (); | 696 SDL_Quit(); |
697 return (0); | 697 return (0); |
698 } | 698 } |
699 | 699 |
700 int | 700 int |
701 main (int argc, char *argv[]) | 701 main(int argc, char *argv[]) |
702 { | 702 { |
703 int i, logo, logocursor = 0; | 703 int i, logo, logocursor = 0; |
704 int numtests; | 704 int numtests; |
705 int bpp = 0; | 705 int bpp = 0; |
706 int slowly; | 706 int slowly; |
712 | 712 |
713 logo = 0; | 713 logo = 0; |
714 slowly = 0; | 714 slowly = 0; |
715 numtests = 1; | 715 numtests = 1; |
716 for (i = 1; argv[i]; ++i) { | 716 for (i = 1; argv[i]; ++i) { |
717 if (strcmp (argv[i], "-twice") == 0) { | 717 if (strcmp(argv[i], "-twice") == 0) { |
718 ++numtests; | 718 ++numtests; |
719 } | 719 } |
720 if (strcmp (argv[i], "-logo") == 0) { | 720 if (strcmp(argv[i], "-logo") == 0) { |
721 logo = 1; | 721 logo = 1; |
722 } | 722 } |
723 if (strcmp (argv[i], "-logocursor") == 0) { | 723 if (strcmp(argv[i], "-logocursor") == 0) { |
724 logocursor = 1; | 724 logocursor = 1; |
725 } | 725 } |
726 if (strcmp (argv[i], "-slow") == 0) { | 726 if (strcmp(argv[i], "-slow") == 0) { |
727 slowly = 1; | 727 slowly = 1; |
728 } | 728 } |
729 if (strcmp (argv[i], "-bpp") == 0) { | 729 if (strcmp(argv[i], "-bpp") == 0) { |
730 bpp = atoi (argv[++i]); | 730 bpp = atoi(argv[++i]); |
731 } | 731 } |
732 if (strcmp (argv[i], "-gamma") == 0) { | 732 if (strcmp(argv[i], "-gamma") == 0) { |
733 gamma = (float) atof (argv[++i]); | 733 gamma = (float) atof(argv[++i]); |
734 } | 734 } |
735 if (strcmp (argv[i], "-noframe") == 0) { | 735 if (strcmp(argv[i], "-noframe") == 0) { |
736 noframe = 1; | 736 noframe = 1; |
737 } | 737 } |
738 if (strcmp (argv[i], "-fsaa") == 0) { | 738 if (strcmp(argv[i], "-fsaa") == 0) { |
739 ++fsaa; | 739 ++fsaa; |
740 } | 740 } |
741 if (strcmp (argv[i], "-accel") == 0) { | 741 if (strcmp(argv[i], "-accel") == 0) { |
742 ++accel; | 742 ++accel; |
743 } | 743 } |
744 if (strcmp (argv[i], "-sync") == 0) { | 744 if (strcmp(argv[i], "-sync") == 0) { |
745 ++sync; | 745 ++sync; |
746 } | 746 } |
747 if (strncmp (argv[i], "-h", 2) == 0) { | 747 if (strncmp(argv[i], "-h", 2) == 0) { |
748 printf | 748 printf |
749 ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n", | 749 ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n", |
750 argv[0]); | 750 argv[0]); |
751 exit (0); | 751 exit(0); |
752 } | 752 } |
753 } | 753 } |
754 for (i = 0; i < numtests; ++i) { | 754 for (i = 0; i < numtests; ++i) { |
755 RunGLTest (argc, argv, logo, logocursor, slowly, bpp, gamma, | 755 RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, |
756 noframe, fsaa, sync, accel); | 756 noframe, fsaa, sync, accel); |
757 } | 757 } |
758 return 0; | 758 return 0; |
759 } | 759 } |
760 | 760 |
761 #else /* HAVE_OPENGL */ | 761 #else /* HAVE_OPENGL */ |
762 | 762 |
763 int | 763 int |
764 main (int argc, char *argv[]) | 764 main(int argc, char *argv[]) |
765 { | 765 { |
766 printf ("No OpenGL support on this system\n"); | 766 printf("No OpenGL support on this system\n"); |
767 return 1; | 767 return 1; |
768 } | 768 } |
769 | 769 |
770 #endif /* HAVE_OPENGL */ | 770 #endif /* HAVE_OPENGL */ |