test/testsprite2.c
changeset 1916 c773b0c0ac89
parent 1915 a228436a2404
child 1917 3f54b3ec5a07
     1.1 --- a/test/testsprite2.c	Wed Jul 19 04:24:41 2006 +0000
     1.2 +++ b/test/testsprite2.c	Wed Jul 19 05:03:21 2006 +0000
     1.3 @@ -8,7 +8,7 @@
     1.4  
     1.5  #define NUM_SPRITES	100
     1.6  #define MAX_SPEED 	1
     1.7 -#define BACKGROUND  0x00FFFFFF
     1.8 +#define BACKGROUND  0x00A0A0A0
     1.9  
    1.10  static CommonState *state;
    1.11  static int num_sprites;
    1.12 @@ -16,6 +16,7 @@
    1.13  static SDL_Rect *positions;
    1.14  static SDL_Rect *velocities;
    1.15  static int sprite_w, sprite_h;
    1.16 +static SDL_TextureBlendMode blendMode = SDL_TextureBlendMode_Mask;
    1.17  
    1.18  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    1.19  static void
    1.20 @@ -107,7 +108,7 @@
    1.21          }
    1.22  
    1.23          /* Blit the sprite onto the screen */
    1.24 -        SDL_RenderCopy(sprite, NULL, position, SDL_TextureBlendMode_Mask,
    1.25 +        SDL_RenderCopy(sprite, NULL, position, blendMode,
    1.26                         SDL_TextureScaleMode_None);
    1.27      }
    1.28  
    1.29 @@ -135,11 +136,31 @@
    1.30  
    1.31          consumed = CommonArg(state, i);
    1.32          if (consumed == 0) {
    1.33 -            num_sprites = SDL_atoi(argv[i]);
    1.34 -            consumed = 1;
    1.35 +            consumed = -1;
    1.36 +            if (SDL_strcasecmp(argv[i], "--blend") == 0) {
    1.37 +                if (argv[i + 1]) {
    1.38 +                    if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
    1.39 +                        blendMode = SDL_TextureBlendMode_None;
    1.40 +                        consumed = 2;
    1.41 +                    } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
    1.42 +                        blendMode = SDL_TextureBlendMode_Blend;
    1.43 +                        consumed = 2;
    1.44 +                    } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
    1.45 +                        blendMode = SDL_TextureBlendMode_Add;
    1.46 +                        consumed = 2;
    1.47 +                    } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
    1.48 +                        blendMode = SDL_TextureBlendMode_Mod;
    1.49 +                        consumed = 2;
    1.50 +                    }
    1.51 +                }
    1.52 +            } else if (SDL_isdigit(*argv[i])) {
    1.53 +                num_sprites = SDL_atoi(argv[i]);
    1.54 +                consumed = 1;
    1.55 +            }
    1.56          }
    1.57          if (consumed < 0) {
    1.58 -            fprintf(stderr, "Usage: %s %s", argv[0], CommonUsage(state));
    1.59 +            fprintf(stderr, "Usage: %s %s [--blend none|blend|add|mod]",
    1.60 +                    argv[0], CommonUsage(state));
    1.61              quit(1);
    1.62          }
    1.63          i += consumed;