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 1214 31103dbf1c26
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
--- a/test/testsprite.c	Mon Jan 02 07:09:52 2006 +0000
+++ b/test/testsprite.c	Mon Jan 02 08:07:41 2006 +0000
@@ -9,8 +9,6 @@
 
 #include "SDL.h"
 
-#define DEBUG_FLIP 1
-
 #define NUM_SPRITES	100
 #define MAX_SPEED 	1
 
@@ -20,6 +18,7 @@
 SDL_Rect *positions;
 SDL_Rect *velocities;
 int sprites_visible;
+int debug_flip;
 Uint16 sprite_w, sprite_h;
 
 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
@@ -92,24 +91,22 @@
 		sprite_rects[nupdates++] = area;
 	}
 
-#if DEBUG_FLIP
-    {
-	if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
-            static int t = 0;
+	if (debug_flip) {
+		if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+			static int t = 0;
 
-            Uint32 color = SDL_MapRGB (screen->format, 255, 0, 0);
-            SDL_Rect r;
-            r.x = (sin((float)t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w-20);
-            r.y = 0;
-            r.w = 20;
-            r.h = screen->h;
-        
-            SDL_FillRect (screen, &r, color);
-            t+=2;
-        }
-    }
-#endif
-    
+			Uint32 color = SDL_MapRGB (screen->format, 255, 0, 0);
+			SDL_Rect r;
+			r.x = (sin((float)t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w-20);
+			r.y = 0;
+			r.w = 20;
+			r.h = screen->h;
+
+			SDL_FillRect (screen, &r, color);
+			t+=2;
+		}
+	}
+
 	/* Update the screen! */
 	if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
 		SDL_Flip(screen);
@@ -174,6 +171,7 @@
 	width = 640;
 	height = 480;
 	video_bpp = 8;
+	debug_flip = 0;
 	while ( argc > 1 ) {
 		--argc;
 		if ( strcmp(argv[argc-1], "-width") == 0 ) {
@@ -198,6 +196,9 @@
 		if ( strcmp(argv[argc], "-flip") == 0 ) {
 			videoflags ^= SDL_DOUBLEBUF;
 		} else
+		if ( strcmp(argv[argc], "-debugflip") == 0 ) {
+			debug_flip ^= 1;
+		} else
 		if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
 			videoflags ^= SDL_FULLSCREEN;
 		} else