/[pcsx2_0.9.7]/trunk/3rdparty/SDL-1.3.0-5387/test/testgl.c
ViewVC logotype

Contents of /trunk/3rdparty/SDL-1.3.0-5387/test/testgl.c

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22