Mercurial > sdl-ios-xcode
comparison test/testsprite2.c @ 3685:64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 21 Jan 2010 06:21:52 +0000 |
parents | f638ded38b8a |
children | dc26c37ad70e |
comparison
equal
deleted
inserted
replaced
3684:cc564f08884f | 3685:64ce267332c6 |
---|---|
9 #define NUM_SPRITES 100 | 9 #define NUM_SPRITES 100 |
10 #define MAX_SPEED 1 | 10 #define MAX_SPEED 1 |
11 | 11 |
12 static CommonState *state; | 12 static CommonState *state; |
13 static int num_sprites; | 13 static int num_sprites; |
14 static SDL_TextureID *sprites; | 14 static SDL_Texture **sprites; |
15 static SDL_bool cycle_color; | 15 static SDL_bool cycle_color; |
16 static SDL_bool cycle_alpha; | 16 static SDL_bool cycle_alpha; |
17 static int cycle_direction = 1; | 17 static int cycle_direction = 1; |
18 static int current_alpha = 0; | 18 static int current_alpha = 0; |
19 static int current_color = 0; | 19 static int current_color = 0; |
96 /* We're ready to roll. :) */ | 96 /* We're ready to roll. :) */ |
97 return (0); | 97 return (0); |
98 } | 98 } |
99 | 99 |
100 void | 100 void |
101 MoveSprites(SDL_WindowID window, SDL_TextureID sprite) | 101 MoveSprites(SDL_Window * window, SDL_Texture * sprite) |
102 { | 102 { |
103 int i, n; | 103 int i, n; |
104 int window_w, window_h; | 104 int window_w, window_h; |
105 SDL_Rect temp; | 105 SDL_Rect temp; |
106 SDL_Rect *position, *velocity; | 106 SDL_Rect *position, *velocity; |
292 quit(2); | 292 quit(2); |
293 } | 293 } |
294 | 294 |
295 /* Create the windows, initialize the renderers, and load the textures */ | 295 /* Create the windows, initialize the renderers, and load the textures */ |
296 sprites = | 296 sprites = |
297 (SDL_TextureID *) SDL_malloc(state->num_windows * sizeof(*sprites)); | 297 (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); |
298 if (!sprites) { | 298 if (!sprites) { |
299 fprintf(stderr, "Out of memory!\n"); | 299 fprintf(stderr, "Out of memory!\n"); |
300 quit(2); | 300 quit(2); |
301 } | 301 } |
302 for (i = 0; i < state->num_windows; ++i) { | 302 for (i = 0; i < state->num_windows; ++i) { |
344 CommonEvent(state, &event, &done); | 344 CommonEvent(state, &event, &done); |
345 switch (event.type) { | 345 switch (event.type) { |
346 case SDL_WINDOWEVENT: | 346 case SDL_WINDOWEVENT: |
347 switch (event.window.event) { | 347 switch (event.window.event) { |
348 case SDL_WINDOWEVENT_EXPOSED: | 348 case SDL_WINDOWEVENT_EXPOSED: |
349 SDL_SelectRenderer(event.window.windowID); | 349 SDL_SelectRenderer(SDL_GetWindowFromID(event.window.windowID)); |
350 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); | 350 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); |
351 SDL_RenderClear(); | 351 SDL_RenderClear(); |
352 break; | 352 break; |
353 } | 353 } |
354 break; | 354 break; |