-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pixel perfect DrawRectangleLines under OpenGL 1.1 #7
Comments
Hi debiatan! Excuse me for the late response! Getting pixel-perfect rendering in OpenGL is quite difficult, actually, it highly depends on the graphic card and the driver implementation. I tested same raylib program on different hardware (AMD/NVIDIA) and I get different results on pixel-alignment. You can read more about this issue here and here. Additionally, if you activate some kind of MSAA, disabled by default on raylib ( I'm afraid there is not a perfect solution... |
I see. That is a sad state of affairs. I'll try drawing degenerate Thanks for the discussion and the links. 2014-11-20 19:42 GMT+01:00 Ray [email protected]:
|
Currently, several pixel-based routines in RayLib are not pixel-perfect. I have picked
DrawRectangleLines
because I am using it in a program of mine.DrawRectangleLines
takes four arguments that define the shape of the rectangle to draw(int posX, int posY, int width, int height)
and generates eightrlVertex2i
calls to draw lines that define a square with corners in(posX+1, posY+1)
,(posX+width, posY+1)
,(posX+width, posY+height)
and(posX+1, posY+height)
. Those corners are offset by one pixel, in both the horizontal and the vertical axis, from the intended behavior of the call.Leaving aside that superficial mistake, in order to get pixel-perfect results, care must be taken to recompile the library after uncommenting the following line from
core.c:BeginDrawing
:Since that solution is less than ideal, and given that the initial orthographic projection is set as
inside
rlgl.c:rlglInitGraphics
, I would suggest offsetting the corners of the rectangle by half a pixel so that they fall on their intended position.DrawRectangleLines
would then read:I understand that working with non-integer coordinates can get cumbersome quickly, but only the rest of the 2D primitives of
shapes.c
would need to be adapted and users ofRayLib
would be blissfully shielded from having to think in terms of floating-point coordinates or from recompiling the library.What do you think?
Cheers!
The text was updated successfully, but these errors were encountered: