diff dmdrawline.h @ 265:51ba74f7668c

Make line clipping floating point only.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 10 Oct 2012 13:28:31 +0300
parents a2abd0b991b6
children cf7612c8de1f
line wrap: on
line diff
--- a/dmdrawline.h	Wed Oct 10 13:02:35 2012 +0300
+++ b/dmdrawline.h	Wed Oct 10 13:28:31 2012 +0300
@@ -5,7 +5,7 @@
  * (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, DMFloat fx0, DMFloat fy0, DMFloat fx1, DMFloat fy1, const Uint32 col
 #ifdef DM_DRAWLINE_ARGS
     DM_DRAWLINE_ARGS
 #endif
@@ -18,9 +18,11 @@
     const int qpitch = screen->pitch / DM_DRAWLINE_DST_BYTES;
 
     // Clipping
-    if (dmClipLineCoordsInt(screen, &x0, &y0, &x1, &y1) < 0)
+    if (dmClipLineCoordsFloat(screen, &fx0, &fy0, &fx1, &fy1) < 0)
         return -1;
 
+    int x0 = fx0, y0 = fy0, x1 = fx1, y1 = fy1;
+
     // Compute initial deltas
     dx = (x1 - x0) * 2;
     dy = (y1 - y0) * 2;
@@ -58,7 +60,7 @@
     // Continue based on which delta is larger
     if (dx > dy)
     {
-        int afrac = dy - (dx / 2);
+        int afrac = dy - (dx / 2.0);
         while (x0 != x1)
         {
             if (afrac >= 0)
@@ -75,7 +77,7 @@
     }
     else
     {
-        int afrac = dx - (dy / 2);
+        int afrac = dx - (dy / 2.0);
         while (y0 != y1)
         {
             if (afrac >= 0)