From 30b43e4034f685c36970fa06a54d1ea0318729ba Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 19 Sep 2009 05:43:15 +0000 Subject: [PATCH] Added more tests for the different primitive types --- test/testsprite2.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/test/testsprite2.c b/test/testsprite2.c index b502a9caa..af19256a6 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -100,6 +100,7 @@ MoveSprites(SDL_WindowID window, SDL_TextureID sprite) { int i, n; int window_w, window_h; + SDL_Rect temp; SDL_Rect *position, *velocity; SDL_SelectRenderer(window); @@ -138,13 +139,52 @@ MoveSprites(SDL_WindowID window, SDL_TextureID sprite) SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderFill(NULL); - /* Draw two red points to make sure they show up correctly */ + /* Test points */ SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF); SDL_RenderPoint(0, 0); SDL_RenderPoint(window_w-1, 0); SDL_RenderPoint(0, window_h-1); SDL_RenderPoint(window_w-1, window_h-1); + /* Test horizontal and vertical lines */ + SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF); + SDL_RenderLine(1, 0, window_w-2, 0); + SDL_RenderLine(1, window_h-1, window_w-2, window_h-1); + SDL_RenderLine(0, 1, 0, window_h-2); + SDL_RenderLine(window_w-1, 1, window_w-1, window_h-2); + + /* Test fill */ + SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF); + temp.x = window_w-sprite_w-1; + temp.y = 1; + temp.w = sprite_w; + temp.h = sprite_h; + SDL_RenderFill(&temp); + temp.x = 1; + temp.y = window_h-sprite_h-1; + temp.w = sprite_w; + temp.h = sprite_h; + SDL_RenderFill(&temp); + + /* Test copy */ + temp.x = 1; + temp.y = 1; + temp.w = sprite_w; + temp.h = sprite_h; + SDL_RenderCopy(sprite, NULL, &temp); + temp.x = window_w-sprite_w-1; + temp.y = window_h-sprite_h-1; + temp.w = sprite_w; + temp.h = sprite_h; + SDL_RenderCopy(sprite, NULL, &temp); + + /* Test diagonal lines */ + SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF); + SDL_RenderLine(sprite_w, sprite_h, + window_w-sprite_w-2, window_h-sprite_h-2); + SDL_RenderLine(window_w-sprite_w-2, sprite_h, + sprite_w, window_h-sprite_h-2); + /* Move the sprite, bounce at the wall, and draw */ n = 0; for (i = 0; i < num_sprites; ++i) {