diff dmdrawline.h @ 234:a2abd0b991b6

Modularize line drawing related templates and functions, add clipping functions to dmlib.h.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 08 Oct 2012 15:21:59 +0300
parents 79dac918c81e
children 51ba74f7668c
line wrap: on
line diff
--- a/dmdrawline.h	Mon Oct 08 09:01:16 2012 +0300
+++ b/dmdrawline.h	Mon Oct 08 15:21:59 2012 +0300
@@ -5,7 +5,11 @@
  * (C) Copyright 2011-2012 Tecnic Software productions (TNSP)
  */
 
-int DM_DRAWLINE_NAME (SDL_Surface *screen, int x0, int y0, int x1, int y1, const Uint32 col)
+int DM_DRAWLINE_NAME (SDL_Surface *screen, int x0, int y0, int x1, int y1, const Uint32 col
+#ifdef DM_DRAWLINE_ARGS
+    DM_DRAWLINE_ARGS
+#endif
+)
 #ifdef DM_HEADER
 ;
 #else
@@ -14,7 +18,7 @@
     const int qpitch = screen->pitch / DM_DRAWLINE_DST_BYTES;
 
     // Clipping
-    if (dmClipLineCoordsInt(&x0, &y0, &x1, &y1, screen) < 0)
+    if (dmClipLineCoordsInt(screen, &x0, &y0, &x1, &y1) < 0)
         return -1;
 
     // Compute initial deltas
@@ -33,14 +37,17 @@
     if (dy < 0)
     {
         dy = -dy;
-        ystep = -qpitch;
+        ystep = -1;
     }
     else
-        ystep = qpitch;
+        ystep = 1;
 
+#ifndef DM_DRAWLINE_SPEC
     // Compute offsets
     y0 *= qpitch;
     y1 *= qpitch;
+    ystep *= qpitch;
+#endif
 
 #ifdef DM_DRAWLINE_INIT
     DM_DRAWLINE_INIT
@@ -89,6 +96,7 @@
 #endif
 
 #undef DM_DRAWLINE_NAME
+#undef DM_DRAWLINE_ARGS
 #undef DM_DRAWLINE_DST_BYTES
 #undef DM_DRAWLINE_DST_TYPE
 #undef DM_DRAWLINE_INIT