summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2024-04-28 22:59:35 +0200
committerRay <[email protected]>2024-04-28 22:59:35 +0200
commite0027eb767031bdf8f4fb688b6bf5a977c250c05 (patch)
treef5925e9ae48ed3236d357ed38121715e3004b03d
parent915dd95d88cb9fe7b47d3d48e61ffcc7bfafce40 (diff)
downloadraylib-e0027eb767031bdf8f4fb688b6bf5a977c250c05.tar.gz
raylib-e0027eb767031bdf8f4fb688b6bf5a977c250c05.zip
REVIEWED: `DrawLine()` to avoid pixel rounding issues #3931
-rw-r--r--src/rshapes.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rshapes.c b/src/rshapes.c
index 90201959..f13f4b01 100644
--- a/src/rshapes.c
+++ b/src/rshapes.c
@@ -178,8 +178,9 @@ void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color colo
{
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f((float)startPosX, (float)startPosY);
- rlVertex2f((float)endPosX, (float)endPosY);
+ // WARNING: Adding 0.5f offset to "center" point on selected pixel
+ rlVertex2f((float)startPosX + 0.5f, (float)startPosY + 0.5f);
+ rlVertex2f((float)endPosX + 0.5f, (float)endPosY + 0.5f);
rlEnd();
}
@@ -188,8 +189,9 @@ void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
{
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
- rlVertex2f(startPos.x, startPos.y);
- rlVertex2f(endPos.x, endPos.y);
+ // WARNING: Adding 0.5f offset to "center" point on selected pixel
+ rlVertex2f(startPos.x + 0.5f, startPos.y + 0.5f);
+ rlVertex2f(endPos.x + 0.5f, endPos.y + 0.5f);
rlEnd();
}