*** empty log message ***
authorSam Lantinga <slouken@libsdl.org>
Mon, 16 Sep 2002 06:17:34 +0000
changeset 492c59692dcdce0
parent 491 da6a7e859616
child 493 806fcbde0af3
*** empty log message ***
test/testgl.c
     1.1 --- a/test/testgl.c	Mon Sep 16 06:14:46 2002 +0000
     1.2 +++ b/test/testgl.c	Mon Sep 16 06:17:34 2002 +0000
     1.3 @@ -18,8 +18,12 @@
     1.4  /* The SDL_OPENGLBLIT interface is deprecated.
     1.5     The code is still available for benchmark purposes though.
     1.6  */
     1.7 +
     1.8  static SDL_bool USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
     1.9  
    1.10 +static SDL_Surface *global_image = NULL;
    1.11 +static GLuint global_texture = 0;
    1.12 +
    1.13  /**********************************************************************/
    1.14  
    1.15  void HotKey_ToggleFullScreen(void)
    1.16 @@ -233,9 +237,9 @@
    1.17  	return texture;
    1.18  }
    1.19  
    1.20 +
    1.21  void DrawLogoTexture(void)
    1.22  {
    1.23 -	static GLuint texture;
    1.24  	static GLfloat texMinX, texMinY;
    1.25  	static GLfloat texMaxX, texMaxY;
    1.26  	static int x = 0;
    1.27 @@ -247,7 +251,7 @@
    1.28  
    1.29  	SDL_Surface *screen = SDL_GetVideoSurface();
    1.30  
    1.31 -	if ( ! texture ) {
    1.32 +	if ( ! global_texture ) {
    1.33  		SDL_Surface *image;
    1.34  		GLfloat texcoord[4];
    1.35  
    1.36 @@ -260,7 +264,7 @@
    1.37  		h = image->h;
    1.38  
    1.39  		/* Convert the image into an OpenGL texture */
    1.40 -		texture = SDL_GL_LoadTexture(image, texcoord);
    1.41 +		global_texture = SDL_GL_LoadTexture(image, texcoord);
    1.42  
    1.43  		/* Make texture coordinates easy to understand */
    1.44  		texMinX = texcoord[0];
    1.45 @@ -272,7 +276,7 @@
    1.46  		SDL_FreeSurface(image);
    1.47  
    1.48  		/* Make sure that the texture conversion is okay */
    1.49 -		if ( ! texture ) {
    1.50 +		if ( ! global_texture ) {
    1.51  			return;
    1.52  		}
    1.53  	}
    1.54 @@ -299,7 +303,7 @@
    1.55  
    1.56  	/* Show the image on the screen */
    1.57  	SDL_GL_Enter2DMode();
    1.58 -	glBindTexture(GL_TEXTURE_2D, texture);
    1.59 +	glBindTexture(GL_TEXTURE_2D, global_texture);
    1.60  	glBegin(GL_TRIANGLE_STRIP);
    1.61  	glTexCoord2f(texMinX, texMinY); glVertex2i(x,   y  );
    1.62  	glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y  );
    1.63 @@ -312,10 +316,6 @@
    1.64  /* This code is deprecated, but available for speed comparisons */
    1.65  void DrawLogoBlit(void)
    1.66  {
    1.67 -	static SDL_Surface *image = NULL;
    1.68 -	static GLuint texture;
    1.69 -	static GLfloat texMinX, texMinY;
    1.70 -	static GLfloat texMaxX, texMaxY;
    1.71  	static int x = 0;
    1.72  	static int y = 0;
    1.73  	static int w, h;
    1.74 @@ -326,7 +326,7 @@
    1.75  	SDL_Rect dst;
    1.76  	SDL_Surface *screen = SDL_GetVideoSurface();
    1.77  
    1.78 -	if ( image == NULL ) {
    1.79 +	if ( global_image == NULL ) {
    1.80  		SDL_Surface *temp;
    1.81  
    1.82  		/* Load the image (could use SDL_image library here) */
    1.83 @@ -338,7 +338,7 @@
    1.84  		h = temp->h;
    1.85  
    1.86  		/* Convert the image into the screen format */
    1.87 -		image = SDL_CreateRGBSurface(
    1.88 +		global_image = SDL_CreateRGBSurface(
    1.89  				SDL_SWSURFACE,
    1.90  				w, h,
    1.91  				screen->format->BitsPerPixel,
    1.92 @@ -346,13 +346,13 @@
    1.93  				screen->format->Gmask,
    1.94  				screen->format->Bmask,
    1.95  				screen->format->Amask);
    1.96 -		if ( image ) {
    1.97 -			SDL_BlitSurface(temp, NULL, image, NULL);
    1.98 +		if ( global_image ) {
    1.99 +			SDL_BlitSurface(temp, NULL, global_image, NULL);
   1.100  		}
   1.101  		SDL_FreeSurface(temp);
   1.102  
   1.103  		/* Make sure that the texture conversion is okay */
   1.104 -		if ( ! image ) {
   1.105 +		if ( ! global_image ) {
   1.106  			return;
   1.107  		}
   1.108  	}
   1.109 @@ -386,7 +386,7 @@
   1.110  	dst.y = y;
   1.111  	dst.w = w;
   1.112  	dst.h = h;
   1.113 -	SDL_BlitSurface(image, NULL, screen, &dst);
   1.114 +	SDL_BlitSurface(global_image, NULL, screen, &dst);
   1.115  
   1.116  	/* Show the image on the screen */
   1.117  	SDL_UpdateRects(screen, 1, &dst);
   1.118 @@ -678,6 +678,15 @@
   1.119  			((float)frames/(this_time-start_time))*1000.0);
   1.120  	}
   1.121  
   1.122 +	if ( global_image ) {
   1.123 +	   	SDL_FreeSurface(global_image);
   1.124 +		global_image = NULL;
   1.125 +	}
   1.126 +	if ( global_texture ) {
   1.127 +		glDeleteTextures( 1, &global_texture );
   1.128 +		global_texture = 0;
   1.129 +	}
   1.130 +
   1.131  	/* Destroy our GL context, etc. */
   1.132  	SDL_Quit( );
   1.133  	return(0);
   1.134 @@ -690,7 +699,7 @@
   1.135  	int bpp = 0;
   1.136  	int slowly;
   1.137  	float gamma = 0.0;
   1.138 -        int noframe = 0;
   1.139 +	int noframe = 0;
   1.140  
   1.141  	logo = 0;
   1.142  	slowly = 0;
   1.143 @@ -727,7 +736,7 @@
   1.144  		}
   1.145  	}
   1.146  	for ( i=0; i<numtests; ++i ) {
   1.147 - 	       RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe);
   1.148 + 		RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe);
   1.149  	}
   1.150  	return 0;
   1.151  }