diff src/video/SDL_draw.h @ 3594:c8bed77b0386

Added SDL_DrawRect(), SDL_DrawRects(), SDL_BlendRect() and SDL_BlendRects() Fixed line drawing so when blending a sequence of lines there are no overlapping pixels drawn.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 18 Dec 2009 07:41:59 +0000
parents b931bcfd94a0
children f638ded38b8a
line wrap: on
line diff
--- a/src/video/SDL_draw.h	Fri Dec 18 07:03:09 2009 +0000
+++ b/src/video/SDL_draw.h	Fri Dec 18 07:41:59 2009 +0000
@@ -283,7 +283,7 @@
 
 #define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
 
-#define BRESENHAM(x1, y1, x2, y2, op) \
+#define BRESENHAM(x1, y1, x2, y2, op, draw_end) \
 { \
     int i, deltax, deltay, numpixels; \
     int d, dinc1, dinc2; \
@@ -325,6 +325,9 @@
     x = x1; \
     y = y1; \
  \
+    if (!draw_end) { \
+        --numpixels; \
+    } \
     for (i = 0; i < numpixels; ++i) { \
         op(x, y); \
         if (d < 0) { \
@@ -338,10 +341,11 @@
         } \
     } \
 }
-#define DRAWLINE(x0, y0, x1, y1, op)	BRESENHAM(x0, y0, x1, y1, op)
+#define DRAWLINE    BRESENHAM
 
 /*
  * Define draw rect macro
+ * (not tested, this level of optimization not needed ... yet?)
  */
 #define DRAWRECT(type, op) \
 do { \