test/testgl.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 02 Nov 2001 18:12:52 +0000
changeset 221 50620ec9c86a
parent 214 0e5d6dd77bda
child 233 5b42a7f5fab3
permissions -rw-r--r--
*** empty log message ***
slouken@0
     1
#include <stdlib.h>
slouken@0
     2
#include <stdio.h>
slouken@0
     3
#include <string.h>
slouken@0
     4
#include <math.h>
slouken@0
     5
slouken@0
     6
#include "SDL.h"
slouken@0
     7
slouken@0
     8
#ifdef HAVE_OPENGL
slouken@214
     9
#include "SDL_opengl.h"
slouken@0
    10
slouken@0
    11
#define SHADED_CUBE
slouken@0
    12
slouken@0
    13
slouken@0
    14
void HotKey_ToggleFullScreen(void)
slouken@0
    15
{
slouken@0
    16
	SDL_Surface *screen;
slouken@0
    17
slouken@0
    18
	screen = SDL_GetVideoSurface();
slouken@0
    19
	if ( SDL_WM_ToggleFullScreen(screen) ) {
slouken@0
    20
		printf("Toggled fullscreen mode - now %s\n",
slouken@0
    21
		    (screen->flags&SDL_FULLSCREEN) ? "fullscreen" : "windowed");
slouken@0
    22
	} else {
slouken@0
    23
		printf("Unable to toggle fullscreen mode\n");
slouken@0
    24
	}
slouken@0
    25
}
slouken@0
    26
slouken@0
    27
void HotKey_ToggleGrab(void)
slouken@0
    28
{
slouken@0
    29
	SDL_GrabMode mode;
slouken@0
    30
slouken@0
    31
	printf("Ctrl-G: toggling input grab!\n");
slouken@0
    32
	mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
slouken@0
    33
	if ( mode == SDL_GRAB_ON ) {
slouken@0
    34
		printf("Grab was on\n");
slouken@0
    35
	} else {
slouken@0
    36
		printf("Grab was off\n");
slouken@0
    37
	}
slouken@0
    38
	mode = SDL_WM_GrabInput(!mode);
slouken@0
    39
	if ( mode == SDL_GRAB_ON ) {
slouken@0
    40
		printf("Grab is now on\n");
slouken@0
    41
	} else {
slouken@0
    42
		printf("Grab is now off\n");
slouken@0
    43
	}
slouken@0
    44
}
slouken@0
    45
slouken@0
    46
void HotKey_Iconify(void)
slouken@0
    47
{
slouken@0
    48
	printf("Ctrl-Z: iconifying window!\n");
slouken@0
    49
	SDL_WM_IconifyWindow();
slouken@0
    50
}
slouken@0
    51
slouken@0
    52
int HandleEvent(SDL_Event *event)
slouken@0
    53
{
slouken@0
    54
	int done;
slouken@0
    55
slouken@0
    56
	done = 0;
slouken@0
    57
	switch( event->type ) {
slouken@0
    58
	    case SDL_ACTIVEEVENT:
slouken@0
    59
		/* See what happened */
slouken@0
    60
		printf( "app %s ", event->active.gain ? "gained" : "lost" );
slouken@0
    61
		if ( event->active.state & SDL_APPACTIVE ) {
slouken@0
    62
			printf( "active " );
slouken@0
    63
		} else if ( event->active.state & SDL_APPMOUSEFOCUS ) {
slouken@0
    64
			printf( "mouse " );
slouken@0
    65
		} else if ( event->active.state & SDL_APPINPUTFOCUS ) {
slouken@0
    66
			printf( "input " );
slouken@0
    67
		}
slouken@0
    68
		printf( "focus\n" );
slouken@0
    69
		break;
slouken@0
    70
		
slouken@0
    71
slouken@0
    72
	    case SDL_KEYDOWN:
slouken@0
    73
		if ( event->key.keysym.sym == SDLK_ESCAPE ) {
slouken@0
    74
			done = 1;
slouken@0
    75
		}
slouken@0
    76
		if ( (event->key.keysym.sym == SDLK_g) &&
slouken@0
    77
		     (event->key.keysym.mod & KMOD_CTRL) ) {
slouken@0
    78
			HotKey_ToggleGrab();
slouken@0
    79
		}
slouken@0
    80
		if ( (event->key.keysym.sym == SDLK_z) &&
slouken@0
    81
		     (event->key.keysym.mod & KMOD_CTRL) ) {
slouken@0
    82
			HotKey_Iconify();
slouken@0
    83
		}
slouken@0
    84
		if ( (event->key.keysym.sym == SDLK_RETURN) &&
slouken@0
    85
		     (event->key.keysym.mod & KMOD_ALT) ) {
slouken@0
    86
			HotKey_ToggleFullScreen();
slouken@0
    87
		}
slouken@0
    88
		printf("key '%s' pressed\n", 
slouken@0
    89
			SDL_GetKeyName(event->key.keysym.sym));
slouken@0
    90
		break;
slouken@0
    91
	    case SDL_QUIT:
slouken@0
    92
		done = 1;
slouken@0
    93
		break;
slouken@0
    94
	}
slouken@0
    95
	return(done);
slouken@0
    96
}
slouken@0
    97
slouken@0
    98
void DrawSDLLogo(void)
slouken@0
    99
{
slouken@0
   100
	static SDL_Surface *image = NULL;
slouken@0
   101
	static int x = 0;
slouken@0
   102
	static int y = 0;
slouken@0
   103
	static int delta_x = 1;
slouken@0
   104
	static int delta_y = 1;
slouken@0
   105
	static Uint32 last_moved = 0;
slouken@0
   106
slouken@0
   107
	SDL_Rect dst;
slouken@0
   108
	SDL_Surface *screen;
slouken@0
   109
slouken@0
   110
	if ( image == NULL ) {
slouken@0
   111
		SDL_Surface *temp;
slouken@0
   112
slouken@0
   113
		temp = SDL_LoadBMP("icon.bmp");
slouken@0
   114
		if ( temp == NULL ) {
slouken@0
   115
			return;
slouken@0
   116
		}
slouken@0
   117
		image = SDL_CreateRGBSurface(
slouken@0
   118
				SDL_SWSURFACE,
slouken@0
   119
				temp->w, temp->h,
slouken@0
   120
				32,
slouken@0
   121
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
slouken@0
   122
				0x000000FF, 
slouken@0
   123
				0x0000FF00, 
slouken@0
   124
				0x00FF0000, 
slouken@0
   125
 			       0xFF000000
slouken@0
   126
#else
slouken@0
   127
 			       0xFF000000,
slouken@0
   128
 			       0x00FF0000, 
slouken@0
   129
 			       0x0000FF00, 
slouken@0
   130
 			       0x000000FF
slouken@0
   131
#endif
slouken@0
   132
 			       );
slouken@0
   133
		if ( image != NULL ) {
slouken@0
   134
			SDL_BlitSurface(temp, NULL, image, NULL);
slouken@0
   135
		}
slouken@0
   136
		SDL_FreeSurface(temp);
slouken@0
   137
		if ( image == NULL ) {
slouken@0
   138
			return;
slouken@0
   139
		}
slouken@0
   140
	}
slouken@0
   141
slouken@0
   142
	screen = SDL_GetVideoSurface();
slouken@0
   143
slouken@0
   144
	/* Show the image on the screen */
slouken@0
   145
	dst.x = x;
slouken@0
   146
	dst.y = y;
slouken@0
   147
	dst.w = image->w;
slouken@0
   148
	dst.h = image->h;
slouken@0
   149
slouken@0
   150
	/* Move it around
slouken@0
   151
           Note that we do not clear the old position.  This is because we
slouken@0
   152
           perform a glClear() which clears the framebuffer and then only
slouken@0
   153
           update the new area.
slouken@0
   154
           Note that you can also achieve interesting effects by modifying
slouken@0
   155
           the screen surface alpha channel.  It's set to 255 by default..
slouken@0
   156
         */
slouken@0
   157
	if ( (SDL_GetTicks() - last_moved) > 100 ) {
slouken@0
   158
		x += delta_x;
slouken@0
   159
		if ( x < 0 ) {
slouken@0
   160
			x = 0;
slouken@0
   161
			delta_x = -delta_x;
slouken@0
   162
		} else
slouken@0
   163
		if ( (x+image->w) > screen->w ) {
slouken@0
   164
			x = screen->w-image->w;
slouken@0
   165
			delta_x = -delta_x;
slouken@0
   166
		}
slouken@0
   167
		y += delta_y;
slouken@0
   168
		if ( y < 0 ) {
slouken@0
   169
			y = 0;
slouken@0
   170
			delta_y = -delta_y;
slouken@0
   171
		} else
slouken@0
   172
		if ( (y+image->h) > screen->h ) {
slouken@0
   173
			y = screen->h-image->h;
slouken@0
   174
			delta_y = -delta_y;
slouken@0
   175
		}
slouken@0
   176
		SDL_BlitSurface(image, NULL, screen, &dst);
slouken@0
   177
	}
slouken@0
   178
	SDL_UpdateRects(screen, 1, &dst);
slouken@0
   179
}
slouken@0
   180
slouken@0
   181
int RunGLTest( int argc, char* argv[],
slouken@0
   182
               int logo, int slowly, int bpp, float gamma )
slouken@0
   183
{
slouken@0
   184
	int i;
slouken@0
   185
	int rgb_size[3];
slouken@0
   186
	int w = 640;
slouken@0
   187
	int h = 480;
slouken@0
   188
	int done = 0;
slouken@0
   189
	int frames;
slouken@0
   190
	Uint32 start_time, this_time;
slouken@0
   191
        float color[8][3]= {{ 1.0,  1.0,  0.0}, 
slouken@0
   192
			    { 1.0,  0.0,  0.0},
slouken@0
   193
			    { 0.0,  0.0,  0.0},
slouken@0
   194
			    { 0.0,  1.0,  0.0},
slouken@0
   195
			    { 0.0,  1.0,  1.0},
slouken@0
   196
			    { 1.0,  1.0,  1.0},
slouken@0
   197
			    { 1.0,  0.0,  1.0},
slouken@0
   198
			    { 0.0,  0.0,  1.0}};
slouken@0
   199
	float cube[8][3]= {{ 0.5,  0.5, -0.5}, 
slouken@0
   200
			   { 0.5, -0.5, -0.5},
slouken@0
   201
			   {-0.5, -0.5, -0.5},
slouken@0
   202
			   {-0.5,  0.5, -0.5},
slouken@0
   203
			   {-0.5,  0.5,  0.5},
slouken@0
   204
			   { 0.5,  0.5,  0.5},
slouken@0
   205
			   { 0.5, -0.5,  0.5},
slouken@0
   206
			   {-0.5, -0.5,  0.5}};
slouken@0
   207
	Uint32 video_flags;
slouken@0
   208
	int value;
slouken@0
   209
slouken@0
   210
	if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
slouken@0
   211
		fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
slouken@0
   212
		exit( 1 );
slouken@0
   213
	}
slouken@0
   214
slouken@0
   215
	/* See if we should detect the display depth */
slouken@0
   216
	if ( bpp == 0 ) {
slouken@0
   217
		if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 ) {
slouken@0
   218
			bpp = 8;
slouken@0
   219
		} else {
slouken@0
   220
			bpp = 16;  /* More doesn't seem to work */
slouken@0
   221
		}
slouken@0
   222
	}
slouken@0
   223
slouken@0
   224
	/* Set the flags we want to use for setting the video mode */
slouken@0
   225
	if ( logo ) {
slouken@0
   226
		video_flags = SDL_OPENGLBLIT;
slouken@0
   227
	} else {
slouken@0
   228
		video_flags = SDL_OPENGL;
slouken@0
   229
	}
slouken@0
   230
	for ( i=1; argv[i]; ++i ) {
slouken@0
   231
		if ( strcmp(argv[1], "-fullscreen") == 0 ) {
slouken@0
   232
			video_flags |= SDL_FULLSCREEN;
slouken@0
   233
		}
slouken@0
   234
	}
slouken@0
   235
slouken@0
   236
	/* Initialize the display */
slouken@0
   237
	switch (bpp) {
slouken@0
   238
	    case 8:
slouken@0
   239
		rgb_size[0] = 2;
slouken@0
   240
		rgb_size[1] = 3;
slouken@0
   241
		rgb_size[2] = 3;
slouken@0
   242
		break;
slouken@0
   243
	    case 15:
slouken@0
   244
	    case 16:
slouken@0
   245
		rgb_size[0] = 5;
slouken@0
   246
		rgb_size[1] = 5;
slouken@0
   247
		rgb_size[2] = 5;
slouken@0
   248
		break;
slouken@0
   249
            default:
slouken@0
   250
		rgb_size[0] = 8;
slouken@0
   251
		rgb_size[1] = 8;
slouken@0
   252
		rgb_size[2] = 8;
slouken@0
   253
		break;
slouken@0
   254
	}
slouken@0
   255
	SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
slouken@0
   256
	SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
slouken@0
   257
	SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
slouken@0
   258
	SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
slouken@0
   259
	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
slouken@0
   260
	if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
slouken@0
   261
		fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
slouken@0
   262
		SDL_Quit();
slouken@0
   263
		exit(1);
slouken@0
   264
	}
slouken@0
   265
slouken@0
   266
	printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
slouken@0
   267
	printf("\n");
slouken@0
   268
	printf( "Vendor     : %s\n", glGetString( GL_VENDOR ) );
slouken@0
   269
	printf( "Renderer   : %s\n", glGetString( GL_RENDERER ) );
slouken@0
   270
	printf( "Version    : %s\n", glGetString( GL_VERSION ) );
slouken@0
   271
	printf( "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
slouken@0
   272
	printf("\n");
slouken@0
   273
slouken@0
   274
	SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
slouken@0
   275
	printf( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);
slouken@0
   276
	SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
slouken@0
   277
	printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value);
slouken@0
   278
	SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
slouken@0
   279
	printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
slouken@0
   280
	SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
slouken@0
   281
	printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
slouken@0
   282
	SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
slouken@0
   283
	printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
slouken@0
   284
slouken@0
   285
	/* Set the window manager title bar */
slouken@0
   286
	SDL_WM_SetCaption( "SDL GL test", "testgl" );
slouken@0
   287
slouken@0
   288
	/* Set the gamma for the window */
slouken@0
   289
	if ( gamma != 0.0 ) {
slouken@0
   290
		SDL_SetGamma(gamma, gamma, gamma);
slouken@0
   291
	}
slouken@0
   292
slouken@0
   293
	glViewport( 0, 0, w, h );
slouken@0
   294
	glMatrixMode( GL_PROJECTION );
slouken@0
   295
	glLoadIdentity( );
slouken@0
   296
slouken@0
   297
	glOrtho( -2.0, 2.0, -2.0, 2.0, -20.0, 20.0 );
slouken@0
   298
slouken@0
   299
	glMatrixMode( GL_MODELVIEW );
slouken@0
   300
	glLoadIdentity( );
slouken@0
   301
slouken@0
   302
	glEnable(GL_DEPTH_TEST);
slouken@0
   303
slouken@0
   304
	glDepthFunc(GL_LESS);
slouken@0
   305
slouken@0
   306
	glShadeModel(GL_SMOOTH);
slouken@0
   307
slouken@0
   308
	/* Loop until done. */
slouken@0
   309
	start_time = SDL_GetTicks();
slouken@0
   310
	frames = 0;
slouken@0
   311
	while( !done ) {
slouken@0
   312
		GLenum gl_error;
slouken@0
   313
		char* sdl_error;
slouken@0
   314
		SDL_Event event;
slouken@0
   315
slouken@0
   316
		/* Do our drawing, too. */
slouken@0
   317
		glClearColor( 0.0, 0.0, 0.0, 1.0 );
slouken@0
   318
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
slouken@0
   319
slouken@0
   320
		glBegin( GL_QUADS );
slouken@0
   321
slouken@0
   322
#ifdef SHADED_CUBE
slouken@0
   323
			glColor3fv(color[0]);
slouken@0
   324
			glVertex3fv(cube[0]);
slouken@0
   325
			glColor3fv(color[1]);
slouken@0
   326
			glVertex3fv(cube[1]);
slouken@0
   327
			glColor3fv(color[2]);
slouken@0
   328
			glVertex3fv(cube[2]);
slouken@0
   329
			glColor3fv(color[3]);
slouken@0
   330
			glVertex3fv(cube[3]);
slouken@0
   331
			
slouken@0
   332
			glColor3fv(color[3]);
slouken@0
   333
			glVertex3fv(cube[3]);
slouken@0
   334
			glColor3fv(color[4]);
slouken@0
   335
			glVertex3fv(cube[4]);
slouken@0
   336
			glColor3fv(color[7]);
slouken@0
   337
			glVertex3fv(cube[7]);
slouken@0
   338
			glColor3fv(color[2]);
slouken@0
   339
			glVertex3fv(cube[2]);
slouken@0
   340
			
slouken@0
   341
			glColor3fv(color[0]);
slouken@0
   342
			glVertex3fv(cube[0]);
slouken@0
   343
			glColor3fv(color[5]);
slouken@0
   344
			glVertex3fv(cube[5]);
slouken@0
   345
			glColor3fv(color[6]);
slouken@0
   346
			glVertex3fv(cube[6]);
slouken@0
   347
			glColor3fv(color[1]);
slouken@0
   348
			glVertex3fv(cube[1]);
slouken@0
   349
			
slouken@0
   350
			glColor3fv(color[5]);
slouken@0
   351
			glVertex3fv(cube[5]);
slouken@0
   352
			glColor3fv(color[4]);
slouken@0
   353
			glVertex3fv(cube[4]);
slouken@0
   354
			glColor3fv(color[7]);
slouken@0
   355
			glVertex3fv(cube[7]);
slouken@0
   356
			glColor3fv(color[6]);
slouken@0
   357
			glVertex3fv(cube[6]);
slouken@0
   358
slouken@0
   359
			glColor3fv(color[5]);
slouken@0
   360
			glVertex3fv(cube[5]);
slouken@0
   361
			glColor3fv(color[0]);
slouken@0
   362
			glVertex3fv(cube[0]);
slouken@0
   363
			glColor3fv(color[3]);
slouken@0
   364
			glVertex3fv(cube[3]);
slouken@0
   365
			glColor3fv(color[4]);
slouken@0
   366
			glVertex3fv(cube[4]);
slouken@0
   367
slouken@0
   368
			glColor3fv(color[6]);
slouken@0
   369
			glVertex3fv(cube[6]);
slouken@0
   370
			glColor3fv(color[1]);
slouken@0
   371
			glVertex3fv(cube[1]);
slouken@0
   372
			glColor3fv(color[2]);
slouken@0
   373
			glVertex3fv(cube[2]);
slouken@0
   374
			glColor3fv(color[7]);
slouken@0
   375
			glVertex3fv(cube[7]);
slouken@0
   376
#else // flat cube
slouken@0
   377
			glColor3f(1.0, 0.0, 0.0);
slouken@0
   378
			glVertex3fv(cube[0]);
slouken@0
   379
			glVertex3fv(cube[1]);
slouken@0
   380
			glVertex3fv(cube[2]);
slouken@0
   381
			glVertex3fv(cube[3]);
slouken@0
   382
			
slouken@0
   383
			glColor3f(0.0, 1.0, 0.0);
slouken@0
   384
			glVertex3fv(cube[3]);
slouken@0
   385
			glVertex3fv(cube[4]);
slouken@0
   386
			glVertex3fv(cube[7]);
slouken@0
   387
			glVertex3fv(cube[2]);
slouken@0
   388
			
slouken@0
   389
			glColor3f(0.0, 0.0, 1.0);
slouken@0
   390
			glVertex3fv(cube[0]);
slouken@0
   391
			glVertex3fv(cube[5]);
slouken@0
   392
			glVertex3fv(cube[6]);
slouken@0
   393
			glVertex3fv(cube[1]);
slouken@0
   394
			
slouken@0
   395
			glColor3f(0.0, 1.0, 1.0);
slouken@0
   396
			glVertex3fv(cube[5]);
slouken@0
   397
			glVertex3fv(cube[4]);
slouken@0
   398
			glVertex3fv(cube[7]);
slouken@0
   399
			glVertex3fv(cube[6]);
slouken@0
   400
slouken@0
   401
			glColor3f(1.0, 1.0, 0.0);
slouken@0
   402
			glVertex3fv(cube[5]);
slouken@0
   403
			glVertex3fv(cube[0]);
slouken@0
   404
			glVertex3fv(cube[3]);
slouken@0
   405
			glVertex3fv(cube[4]);
slouken@0
   406
slouken@0
   407
			glColor3f(1.0, 0.0, 1.0);
slouken@0
   408
			glVertex3fv(cube[6]);
slouken@0
   409
			glVertex3fv(cube[1]);
slouken@0
   410
			glVertex3fv(cube[2]);
slouken@0
   411
			glVertex3fv(cube[7]);
slouken@0
   412
#endif /* SHADED_CUBE */
slouken@0
   413
slouken@0
   414
		glEnd( );
slouken@0
   415
		
slouken@0
   416
		glMatrixMode(GL_MODELVIEW);
slouken@0
   417
		glRotatef(5.0, 1.0, 1.0, 1.0);
slouken@0
   418
slouken@0
   419
		/* Draw 2D logo onto the 3D display */
slouken@0
   420
		if ( logo ) {
slouken@0
   421
			DrawSDLLogo();
slouken@0
   422
		}
slouken@0
   423
slouken@0
   424
		SDL_GL_SwapBuffers( );
slouken@0
   425
slouken@0
   426
		/* Check for error conditions. */
slouken@0
   427
		gl_error = glGetError( );
slouken@0
   428
slouken@0
   429
		if( gl_error != GL_NO_ERROR ) {
slouken@0
   430
			fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error );
slouken@0
   431
		}
slouken@0
   432
slouken@0
   433
		sdl_error = SDL_GetError( );
slouken@0
   434
slouken@0
   435
		if( sdl_error[0] != '\0' ) {
slouken@0
   436
			fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error);
slouken@0
   437
			SDL_ClearError();
slouken@0
   438
		}
slouken@0
   439
slouken@0
   440
		/* Allow the user to see what's happening */
slouken@0
   441
		if ( slowly ) {
slouken@0
   442
			SDL_Delay( 20 );
slouken@0
   443
		}
slouken@0
   444
slouken@0
   445
		/* Check if there's a pending event. */
slouken@0
   446
		while( SDL_PollEvent( &event ) ) {
slouken@0
   447
			done = HandleEvent(&event);
slouken@0
   448
		}
slouken@0
   449
		++frames;
slouken@0
   450
	}
slouken@0
   451
slouken@0
   452
	/* Print out the frames per second */
slouken@0
   453
	this_time = SDL_GetTicks();
slouken@0
   454
	if ( this_time != start_time ) {
slouken@0
   455
		printf("%2.2f FPS\n",
slouken@0
   456
			((float)frames/(this_time-start_time))*1000.0);
slouken@0
   457
	}
slouken@0
   458
slouken@0
   459
	/* Destroy our GL context, etc. */
slouken@0
   460
	SDL_Quit( );
slouken@0
   461
	return(0);
slouken@0
   462
}
slouken@0
   463
slouken@0
   464
int main(int argc, char *argv[])
slouken@0
   465
{
slouken@0
   466
	int i, logo;
slouken@0
   467
	int numtests;
slouken@0
   468
	int bpp = 0;
slouken@0
   469
	int slowly;
slouken@0
   470
	float gamma = 0.0;
slouken@0
   471
slouken@0
   472
	logo = 0;
slouken@0
   473
	slowly = 0;
slouken@0
   474
	numtests = 1;
slouken@0
   475
	for ( i=1; argv[i]; ++i ) {
slouken@0
   476
		if ( strcmp(argv[i], "-twice") == 0 ) {
slouken@0
   477
			++numtests;
slouken@0
   478
		}
slouken@0
   479
		if ( strcmp(argv[i], "-logo") == 0 ) {
slouken@0
   480
			logo = 1;
slouken@0
   481
		}
slouken@0
   482
		if ( strcmp(argv[i], "-slow") == 0 ) {
slouken@0
   483
			slowly = 1;
slouken@0
   484
		}
slouken@0
   485
		if ( strcmp(argv[i], "-bpp") == 0 ) {
slouken@0
   486
 		       bpp = atoi(argv[++i]);
slouken@0
   487
		}
slouken@0
   488
		if ( strcmp(argv[i], "-gamma") == 0 ) {
slouken@0
   489
 		       gamma = (float)atof(argv[++i]);
slouken@0
   490
		}
slouken@0
   491
		if ( strncmp(argv[i], "-h", 2) == 0 ) {
slouken@0
   492
 		       printf(
slouken@0
   493
"Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n]\n",
slouken@0
   494
 			      argv[0]);
slouken@0
   495
			exit(0);
slouken@0
   496
		}
slouken@0
   497
	}
slouken@0
   498
	for ( i=0; i<numtests; ++i ) {
slouken@0
   499
 	       RunGLTest(argc, argv, logo, slowly, bpp, gamma);
slouken@0
   500
	}
slouken@0
   501
	return 0;
slouken@0
   502
}
slouken@0
   503
slouken@0
   504
#else /* HAVE_OPENGL */
slouken@0
   505
slouken@0
   506
int main(int argc, char *argv[])
slouken@0
   507
{
slouken@0
   508
	printf("No OpenGL support on this system\n");
slouken@0
   509
	return 1;
slouken@0
   510
}
slouken@0
   511
slouken@0
   512
#endif /* HAVE_OPENGL */