SDL_RenderDrawRect function broken

Hi guys. This change makes SDL_RenderDrawRect function broken:

I posted comment and screenshot there.

Rectangle

1 Like

There is SDL_RenderDrawRect not rectangular Ā· Issue #4001 Ā· libsdl-org/SDL Ā· GitHub

I can also confirm this, im seeing the same on my end (linux, all gl renderers)

1 Like

That change was bound to break the case when two or more lines are drawn (i.e. when count is greater than one) because it can move the start point of the last line segment (in order to force it to be plotted) but that is also the end point of the penultimate line segment, which as a result is drawn skewed!

Iā€™m not entirely convinced that lengthening a line segment is the right approach to forcing both end points to be drawn. When Iā€™ve wanted to do that in the past Iā€™ve done it by appending an additional zero-length (or perhaps one-pixel length) segment.

1 Like

I think, in on itself, lengthening a line within the ā€œrulesā€ of opengl is fine. That is, moving the end point so far that the last point exits the pixel. Everything else however is probably going to break more than it fixes.

My understanding is that the previous version of the code did indeed move only the very last point (the end point of the last segment), but whilst that was ā€˜safeā€™ it didnā€™t have the desired effect of ensuring both end points were always plotted. :frowning_face:

It seems to me that the best way of ensuring that an end point of a line is always plotted is to arrange that it is also the start point of another line (since it must be drawn as part of one or the other!). Hence my preference for appending an extra, short, segment.

This is buggy right now. Iā€™m going to fight with this more once GitHub migration settles down. It feels a little like fixing one broken case breaks another, but itā€™s clear the last fix I made to this, after 2.0.14 shipped, was straight-up goofy.

2 Likes

Tested the latest version and the OpenGL lines are sooo close to being right now - previous attempts have been a lot worse. Itā€™s just that last line going backwards gets knocked down 1 pixel. At least they seem to be joining up at the same point now.

Sending positive vibes your way Ryan as I know this is your favourite thing to fix right now :wink:

1 Like