metal: Fix line drawing, again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
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;
}