diff test/testsprite2.c @ 3596:f638ded38b8a

Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color. Renamed SDL_RenderPoint() and SDL_RenderLine() to SDL_RenderDrawPoint() and SDL_RenderDrawLine(). Added API for rectangle drawing (as opposed to filling) Added placeholder API functions for circles and ellipses ... I'm not sure whether these will stay. Optimized software line drawing quite a bit. Added support for Wu's anti-aliased line drawing, currently disabled by default.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 23 Dec 2009 01:55:00 +0000
parents 5543db4239e6
children 64ce267332c6
line wrap: on
line diff
--- a/test/testsprite2.c	Fri Dec 18 08:19:18 2009 +0000
+++ b/test/testsprite2.c	Wed Dec 23 01:55:00 2009 +0000
@@ -139,21 +139,21 @@
 
     /* Draw a gray background */
     SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-    SDL_RenderRect(NULL);
+    SDL_RenderClear();
 
     /* 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);
+    SDL_RenderDrawPoint(0, 0);
+    SDL_RenderDrawPoint(window_w-1, 0);
+    SDL_RenderDrawPoint(0, window_h-1);
+    SDL_RenderDrawPoint(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);
+    SDL_RenderDrawLine(1, 0, window_w-2, 0);
+    SDL_RenderDrawLine(1, window_h-1, window_w-2, window_h-1);
+    SDL_RenderDrawLine(0, 1, 0, window_h-2);
+    SDL_RenderDrawLine(window_w-1, 1, window_w-1, window_h-2);
 
     /* Test fill and copy */
     SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF);
@@ -161,33 +161,33 @@
     temp.y = 1;
     temp.w = sprite_w;
     temp.h = sprite_h;
-    SDL_RenderRect(&temp);
+    SDL_RenderFillRect(&temp);
     SDL_RenderCopy(sprite, NULL, &temp);
     temp.x = window_w-sprite_w-1;
     temp.y = 1;
     temp.w = sprite_w;
     temp.h = sprite_h;
-    SDL_RenderRect(&temp);
+    SDL_RenderFillRect(&temp);
     SDL_RenderCopy(sprite, NULL, &temp);
     temp.x = 1;
     temp.y = window_h-sprite_h-1;
     temp.w = sprite_w;
     temp.h = sprite_h;
-    SDL_RenderRect(&temp);
+    SDL_RenderFillRect(&temp);
     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_RenderRect(&temp);
+    SDL_RenderFillRect(&temp);
     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);
+    SDL_RenderDrawLine(sprite_w, sprite_h,
+                       window_w-sprite_w-2, window_h-sprite_h-2);
+    SDL_RenderDrawLine(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;
@@ -302,7 +302,7 @@
     for (i = 0; i < state->num_windows; ++i) {
         SDL_SelectRenderer(state->windows[i]);
         SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-        SDL_RenderRect(NULL);
+        SDL_RenderClear();
     }
     if (LoadSprite("icon.bmp") < 0) {
         quit(2);
@@ -348,7 +348,7 @@
                 case SDL_WINDOWEVENT_EXPOSED:
                     SDL_SelectRenderer(event.window.windowID);
                     SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
-                    SDL_RenderRect(NULL);
+                    SDL_RenderClear();
                     break;
                 }
                 break;