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