Mercurial > sdl-ios-xcode
diff test/testsprite2.c @ 1724:6c63fc2bd986 SDL-1.3
Proof of concept done - Win32 GDI implementation mostly complete.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 06 Jul 2006 07:17:11 +0000 |
parents | 931d111e737a |
children | 98a3207ddde8 |
line wrap: on
line diff
--- a/test/testsprite2.c Thu Jul 06 05:53:32 2006 +0000 +++ b/test/testsprite2.c Thu Jul 06 07:17:11 2006 +0000 @@ -5,11 +5,12 @@ #include "SDL.h" -#define NUM_WINDOWS 2 +#define NUM_WINDOWS 4 #define WINDOW_W 640 #define WINDOW_H 480 #define NUM_SPRITES 100 #define MAX_SPEED 1 +#define BACKGROUND 0x00FFFFFF static int num_windows; static int num_sprites; @@ -85,8 +86,6 @@ SDL_SelectRenderer(window); - SDL_RenderFill(NULL, 0); - /* Query the sizes */ SDL_GetWindowSize(window, &window_w, &window_h); @@ -94,6 +93,10 @@ n = 0; for (i = 0; i < num_sprites; ++i) { position = &positions[i]; + SDL_RenderFill(position, BACKGROUND); + } + for (i = 0; i < num_sprites; ++i) { + position = &positions[i]; velocity = &velocities[i]; position->x += velocity->x; if ((position->x < 0) || (position->x >= (window_w - sprite_w))) { @@ -168,7 +171,8 @@ SDL_snprintf(title, sizeof(title), "testsprite %d", i + 1); windows[i] = - SDL_CreateWindow(title, -1, -1, window_w, window_h, + SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, window_w, window_h, SDL_WINDOW_SHOWN); if (!windows[i]) { fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); @@ -179,6 +183,7 @@ fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); quit(2); } + SDL_RenderFill(NULL, BACKGROUND); } if (LoadSprite("icon.bmp") < 0) { quit(2); @@ -214,6 +219,17 @@ ++frames; while (SDL_PollEvent(&event)) { switch (event.type) { + case SDL_WINDOWEVENT: + switch (event.window.event) { + case SDL_WINDOWEVENT_EXPOSED: + SDL_SelectRenderer(event.window.windowID); + SDL_RenderFill(NULL, BACKGROUND); + break; + case SDL_WINDOWEVENT_CLOSE: + done = 1; + break; + } + break; case SDL_KEYDOWN: /* Any keypress quits the app... */ case SDL_QUIT: