From 731a5d1c530d3eb26c655f77059da69edd89bdb7 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 8 Nov 2020 03:18:05 -0500 Subject: [PATCH] metal: Fix line drawing, again. --- src/render/metal/SDL_render_metal.m | 31 +++++++++-------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m index 06d8382f1..ac5dd7201 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; }