raysan5/raylib

[rshapes] Off-by-one difference between DrawRectangleLinesEx and DrawLine/DrawLineV at drawing position.

raulbonifacio opened this issue · 3 comments

Issue description

Hi! I've been testing raylib for some time and noticed a off-by-one difference between DrawRectangleLinesEx and DrawLine when drawing at the same position, creating a 2px border when combined. I looked into the documentation but couldn't find any mention of difference in behavior between those two. I've also tested with DrawLineV and the behavior persists.

Is this the expected behavior?

Thank you for you time!

Environment

Operating System: Endeavour OS
OpenGL: OpenGL version string: 4.6 (Compatibility Profile)
GPU: AMD Radeon RX 580 8GB

Issue Screenshot

weird

Code Example

#include <raylib.h>

int main(void) {

    InitWindow(400, 400, "Weird.");

    SetTargetFPS(75);

    Font font = GetFontDefault();

    Rectangle rect = {20, 20, 240, 240};

    while (!WindowShouldClose()) {

        BeginDrawing();

        ClearBackground(LIGHTGRAY);

        DrawRectangleLinesEx(rect, 1, DARKGRAY);

        DrawLine(rect.x, rect.y, rect.x, rect.y + rect.height, DARKGRAY);

        EndDrawing();
    }


    CloseWindow();

    return 0;
}

@raulbonifacio Are you testing latest raylib master branch? DrawRectangleLines() and DrawRectangleLinesEx() were reviewed 2 days ago... In any case, this could be not trivial to solve because I'm afraid that pixel offset could be GPU/driver dependant...

Hi @raysan5!

Yes, I'm testing on the master branch! Today I took my time to perform more tests. Just to be sure I pulled and compiled it again but nothing changed.

I tested on different hardware, without a dedicated GPU, but the issue persisted. It's a notebook.

Operating System: Endeavour OS
OpenGL: OpenGL version string: 4.6 (Compatibility Profile)
GPU: Intel Corporation TigerLake-LP GT2 [Iris Xe Graphics]

It's the same OS. Perhaps it has to do with the driver, as you've said.

WhatsApp Image 2024-04-23 at 10 45 44

@raulbonifacio Reviewed! Let's hope it works as expected in all GPU/drivers out there...