Skip to content

Commit

Permalink
metal: Fix line drawing, again.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Nov 8, 2020
1 parent 4ea1a10 commit 731a5d1
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/render/metal/SDL_render_metal.m
Expand Up @@ -1066,32 +1066,19 @@ - (void)dealloc
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;
}

Expand Down

0 comments on commit 731a5d1

Please sign in to comment.