test/testgamma.c
changeset 1151 be9c9c8f6d53
parent 0 74212992fb08
child 1662 782fd950bd46
child 1895 c121d94672cb
     1.1 --- a/test/testgamma.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/testgamma.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -8,6 +8,13 @@
     1.4  
     1.5  #include "SDL.h"
     1.6  
     1.7 +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
     1.8 +static void quit(int rc)
     1.9 +{
    1.10 +	SDL_Quit();
    1.11 +	exit(rc);
    1.12 +}
    1.13 +
    1.14  /* Turn a normal gamma value into an appropriate gamma ramp */
    1.15  void CalculateGamma(double gamma, Uint16 *ramp)
    1.16  {
    1.17 @@ -82,16 +89,15 @@
    1.18  	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    1.19  		fprintf(stderr,
    1.20  			"Couldn't initialize SDL: %s\n", SDL_GetError());
    1.21 -		exit(1);
    1.22 +		return(1);
    1.23  	}
    1.24 -	atexit(SDL_Quit);
    1.25  
    1.26  	/* Initialize the display, always use hardware palette */
    1.27  	screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_HWPALETTE);
    1.28  	if ( screen == NULL ) {
    1.29  		fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
    1.30  						w, h, SDL_GetError());
    1.31 -		exit(1);
    1.32 +		quit(1);
    1.33  	}
    1.34  
    1.35  	/* Set the window manager title bar */
    1.36 @@ -104,7 +110,7 @@
    1.37  	}
    1.38  	if ( SDL_SetGamma(gamma, gamma, gamma) < 0 ) {
    1.39  		fprintf(stderr, "Unable to set gamma: %s\n", SDL_GetError());
    1.40 -		exit(1);
    1.41 +		quit(1);
    1.42  	}
    1.43  
    1.44  #if 0 /* This isn't supported.  Integrating the gamma ramps isn't exact */
    1.45 @@ -186,5 +192,6 @@
    1.46  	}
    1.47  	SDL_Delay(1*1000);
    1.48  
    1.49 +	SDL_Quit();
    1.50  	return(0);
    1.51  }