Mercurial > sdl-ios-xcode
comparison test/testsprite2.c @ 1965:a788656ca29a
SDL constants are all uppercase.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 05 Aug 2006 17:09:42 +0000 |
parents | 3f54b3ec5a07 |
children | 8055185ae4ed |
comparison
equal
deleted
inserted
replaced
1964:071b6598d48f | 1965:a788656ca29a |
---|---|
14 static int num_sprites; | 14 static int num_sprites; |
15 static SDL_TextureID *sprites; | 15 static SDL_TextureID *sprites; |
16 static SDL_Rect *positions; | 16 static SDL_Rect *positions; |
17 static SDL_Rect *velocities; | 17 static SDL_Rect *velocities; |
18 static int sprite_w, sprite_h; | 18 static int sprite_w, sprite_h; |
19 static SDL_TextureBlendMode blendMode = SDL_TextureBlendMode_Mask; | 19 static SDL_TextureBlendMode blendMode = SDL_TEXTUREBLENDMODE_MASK; |
20 static SDL_TextureScaleMode scaleMode = SDL_TextureScaleMode_None; | 20 static SDL_TextureScaleMode scaleMode = SDL_TEXTURESCALEMODE_NONE; |
21 | 21 |
22 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ | 22 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
23 static void | 23 static void |
24 quit(int rc) | 24 quit(int rc) |
25 { | 25 { |
58 | 58 |
59 /* Create textures from the image */ | 59 /* Create textures from the image */ |
60 for (i = 0; i < state->num_windows; ++i) { | 60 for (i = 0; i < state->num_windows; ++i) { |
61 SDL_SelectRenderer(state->windows[i]); | 61 SDL_SelectRenderer(state->windows[i]); |
62 sprites[i] = | 62 sprites[i] = |
63 SDL_CreateTextureFromSurface(0, SDL_TextureAccess_Remote, temp); | 63 SDL_CreateTextureFromSurface(0, SDL_TEXTUREACCESS_REMOTE, temp); |
64 if (!sprites[i]) { | 64 if (!sprites[i]) { |
65 fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); | 65 fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError()); |
66 SDL_FreeSurface(temp); | 66 SDL_FreeSurface(temp); |
67 return (-1); | 67 return (-1); |
68 } | 68 } |
132 if (consumed == 0) { | 132 if (consumed == 0) { |
133 consumed = -1; | 133 consumed = -1; |
134 if (SDL_strcasecmp(argv[i], "--blend") == 0) { | 134 if (SDL_strcasecmp(argv[i], "--blend") == 0) { |
135 if (argv[i + 1]) { | 135 if (argv[i + 1]) { |
136 if (SDL_strcasecmp(argv[i + 1], "none") == 0) { | 136 if (SDL_strcasecmp(argv[i + 1], "none") == 0) { |
137 blendMode = SDL_TextureBlendMode_None; | 137 blendMode = SDL_TEXTUREBLENDMODE_NONE; |
138 consumed = 2; | 138 consumed = 2; |
139 } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) { | 139 } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) { |
140 blendMode = SDL_TextureBlendMode_Mask; | 140 blendMode = SDL_TEXTUREBLENDMODE_MASK; |
141 consumed = 2; | 141 consumed = 2; |
142 } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) { | 142 } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) { |
143 blendMode = SDL_TextureBlendMode_Blend; | 143 blendMode = SDL_TEXTUREBLENDMODE_BLEND; |
144 consumed = 2; | 144 consumed = 2; |
145 } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { | 145 } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { |
146 blendMode = SDL_TextureBlendMode_Add; | 146 blendMode = SDL_TEXTUREBLENDMODE_ADD; |
147 consumed = 2; | 147 consumed = 2; |
148 } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { | 148 } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { |
149 blendMode = SDL_TextureBlendMode_Mod; | 149 blendMode = SDL_TEXTUREBLENDMODE_MOD; |
150 consumed = 2; | 150 consumed = 2; |
151 } | 151 } |
152 } | 152 } |
153 } else if (SDL_strcasecmp(argv[i], "--scale") == 0) { | 153 } else if (SDL_strcasecmp(argv[i], "--scale") == 0) { |
154 if (argv[i + 1]) { | 154 if (argv[i + 1]) { |
155 if (SDL_strcasecmp(argv[i + 1], "none") == 0) { | 155 if (SDL_strcasecmp(argv[i + 1], "none") == 0) { |
156 scaleMode = SDL_TextureScaleMode_None; | 156 scaleMode = SDL_TEXTURESCALEMODE_NONE; |
157 consumed = 2; | 157 consumed = 2; |
158 } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) { | 158 } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) { |
159 scaleMode = SDL_TextureScaleMode_Fast; | 159 scaleMode = SDL_TEXTURESCALEMODE_FAST; |
160 consumed = 2; | 160 consumed = 2; |
161 } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) { | 161 } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) { |
162 scaleMode = SDL_TextureScaleMode_Slow; | 162 scaleMode = SDL_TEXTURESCALEMODE_SLOW; |
163 consumed = 2; | 163 consumed = 2; |
164 } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) { | 164 } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) { |
165 scaleMode = SDL_TextureScaleMode_Best; | 165 scaleMode = SDL_TEXTURESCALEMODE_BEST; |
166 consumed = 2; | 166 consumed = 2; |
167 } | 167 } |
168 } | 168 } |
169 } else if (SDL_isdigit(*argv[i])) { | 169 } else if (SDL_isdigit(*argv[i])) { |
170 num_sprites = SDL_atoi(argv[i]); | 170 num_sprites = SDL_atoi(argv[i]); |
204 if (!positions || !velocities) { | 204 if (!positions || !velocities) { |
205 fprintf(stderr, "Out of memory!\n"); | 205 fprintf(stderr, "Out of memory!\n"); |
206 quit(2); | 206 quit(2); |
207 } | 207 } |
208 srand(time(NULL)); | 208 srand(time(NULL)); |
209 if (scaleMode != SDL_TextureScaleMode_None) { | 209 if (scaleMode != SDL_TEXTURESCALEMODE_NONE) { |
210 sprite_w += sprite_w / 2; | 210 sprite_w += sprite_w / 2; |
211 sprite_h += sprite_h / 2; | 211 sprite_h += sprite_h / 2; |
212 } | 212 } |
213 for (i = 0; i < num_sprites; ++i) { | 213 for (i = 0; i < num_sprites; ++i) { |
214 positions[i].x = rand() % (state->window_w - sprite_w); | 214 positions[i].x = rand() % (state->window_w - sprite_w); |