comparison test/testgl.c @ 1662:782fd950bd46 SDL-1.3

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