Toggle flip debugging in testsprite.c on the command line, not as a hardcoded
authorRyan C. Gordon <icculus@icculus.org>
Mon, 02 Jan 2006 08:07:41 +0000
changeset 121431103dbf1c26
parent 1213 8eb191652834
child 1215 d082d2d66ec8
Toggle flip debugging in testsprite.c on the command line, not as a hardcoded
#define.

--ryan.
test/testsprite.c
     1.1 --- a/test/testsprite.c	Mon Jan 02 07:09:52 2006 +0000
     1.2 +++ b/test/testsprite.c	Mon Jan 02 08:07:41 2006 +0000
     1.3 @@ -9,8 +9,6 @@
     1.4  
     1.5  #include "SDL.h"
     1.6  
     1.7 -#define DEBUG_FLIP 1
     1.8 -
     1.9  #define NUM_SPRITES	100
    1.10  #define MAX_SPEED 	1
    1.11  
    1.12 @@ -20,6 +18,7 @@
    1.13  SDL_Rect *positions;
    1.14  SDL_Rect *velocities;
    1.15  int sprites_visible;
    1.16 +int debug_flip;
    1.17  Uint16 sprite_w, sprite_h;
    1.18  
    1.19  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    1.20 @@ -92,24 +91,22 @@
    1.21  		sprite_rects[nupdates++] = area;
    1.22  	}
    1.23  
    1.24 -#if DEBUG_FLIP
    1.25 -    {
    1.26 -	if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
    1.27 -            static int t = 0;
    1.28 +	if (debug_flip) {
    1.29 +		if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
    1.30 +			static int t = 0;
    1.31  
    1.32 -            Uint32 color = SDL_MapRGB (screen->format, 255, 0, 0);
    1.33 -            SDL_Rect r;
    1.34 -            r.x = (sin((float)t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w-20);
    1.35 -            r.y = 0;
    1.36 -            r.w = 20;
    1.37 -            r.h = screen->h;
    1.38 -        
    1.39 -            SDL_FillRect (screen, &r, color);
    1.40 -            t+=2;
    1.41 -        }
    1.42 -    }
    1.43 -#endif
    1.44 -    
    1.45 +			Uint32 color = SDL_MapRGB (screen->format, 255, 0, 0);
    1.46 +			SDL_Rect r;
    1.47 +			r.x = (sin((float)t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w-20);
    1.48 +			r.y = 0;
    1.49 +			r.w = 20;
    1.50 +			r.h = screen->h;
    1.51 +
    1.52 +			SDL_FillRect (screen, &r, color);
    1.53 +			t+=2;
    1.54 +		}
    1.55 +	}
    1.56 +
    1.57  	/* Update the screen! */
    1.58  	if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
    1.59  		SDL_Flip(screen);
    1.60 @@ -174,6 +171,7 @@
    1.61  	width = 640;
    1.62  	height = 480;
    1.63  	video_bpp = 8;
    1.64 +	debug_flip = 0;
    1.65  	while ( argc > 1 ) {
    1.66  		--argc;
    1.67  		if ( strcmp(argv[argc-1], "-width") == 0 ) {
    1.68 @@ -198,6 +196,9 @@
    1.69  		if ( strcmp(argv[argc], "-flip") == 0 ) {
    1.70  			videoflags ^= SDL_DOUBLEBUF;
    1.71  		} else
    1.72 +		if ( strcmp(argv[argc], "-debugflip") == 0 ) {
    1.73 +			debug_flip ^= 1;
    1.74 +		} else
    1.75  		if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
    1.76  			videoflags ^= SDL_FULLSCREEN;
    1.77  		} else