Commit 731a5d1c530d3eb26c655f77059da69edd89bdb7

Ryan C. Gordon 2020-11-08T03:18:05

metal: Fix line drawing, again.

diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m
index 06d8382..ac5dd72 100644
--- a/src/render/metal/SDL_render_metal.m
+++ b/src/render/metal/SDL_render_metal.m
@@ -1066,32 +1066,19 @@ METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
        angles. Maybe !!! FIXME for later, though. */
 
     points += count - 2;  /* update the last line. */
-    verts += count - 2;
+    verts += (count * 2) - 2;
 
-    float xstart = /*0.5f +*/ points[0].x;   /* 0.5f to get to the center of the pixel. */
-    float ystart = /*0.5f +*/ points[0].y;
-    float xend = /*0.5f +*/ points[1].x;
-    float yend = /*0.5f +*/ points[1].y;
+    const float xstart = points[0].x;
+    const float ystart = points[0].y;
+    const float xend = points[1].x;
+    const float yend = points[1].y;
 
-    if (xstart == xend) {  /* vertical line */
-        if (yend > ystart) {
-            yend += 1.0f;
-        } else {
-            ystart += 1.0f;
-        }
-    } else if (ystart == yend) {  /* horizontal line */
-        if (xend > xstart) {
-            xend += 1.0f;
-        } else {
-            xstart += 1.0f;
-        }
+    if (ystart == yend) {  /* horizontal line */
+        verts[0] += (xend > xstart) ? 1.0f : -1.0f;
+    } else if (xstart == xend) {  /* vertical line */
+        verts[1] += (yend > ystart) ? 1.0f : -1.0f;
     }
 
-    *(verts++) = xstart;
-    *(verts++) = ystart;
-    *(verts++) = xend;
-    *(verts++) = yend;
-
     return 0;
 }