Jagged edges on lines when using SDL_Rect, seemingly all of a sudden.

Hello Everyone,

I recently did a “dnf upgrade” on my Linux system where I’m developing an SDL2 application. It seems after the update, jagged edges are being shown when drawing lines using SDL_Rect’s. I checked with previous versions of my application and I receive the same result so I can be certain this issue isn’t related to a code change on my end.

My first guess is that this may be related to an update in SDL2?

Also note that I don’t see this problem in Windows which has an older version of SDL2 as I have to update the Libs in Windows manually. The Libs in Linux where I am seeing the problem are updated as I update the system.

Has anyone seen an issue like this before? Do you know where I can start to look to resolve this issue? I’m a little bit at a loss as to where to begin because it seems that this issue is not related to a particular code change that I have made.


I am drawing the rectangle like this.

void ley::SimpleShape::drawRect(const SDL_Rect* r) {

And this is where I create the rectangles:


firstSimpleShape.addShape(“nextboundry”,{ley::START_X_OFFSET_PX - 145,39,130,130});
firstSimpleShape.addShape(“testboundry”, {10,10,20,20});


What version of SDL are you using? There has been an ongoing struggle to fix SDL_RenderDrawLine() so that it works as documented (i.e. drawing the line inclusive of both end-points) on all platforms with all renderers. This has proved difficult and there have been some regressions which might perhaps have affected SDL_RenderDrawRect().

It might be worth trying SDL_RenderDrawRectF() (which takes floating-point coordinates), in case that works better.

1 Like

On Windows I am using SDL version 2.0.12 and on Linux I am using SDL version 2.0.16.

I have tried the following, and I get the exact same result. SDL_RenderDrawRectF() seems to produce the same result as SDL_RenderDrawRect().

void ley::SimpleShape::drawRect(const SDL_Rect* r) {

SDL_FRect* fRect;

fRect->x = r->x;
fRect->y = r->y;
fRect->w = r->w;
fRect->h = r->h;



1 Like

Hmm it seems now being a FAQ… DrawRect/Line is broken on some backend.

I had hoped it would be fixed in 2.0.16, but seemingly not. I like the comment at one of the linked bug reports that this is Ryan’s “favourite thing to fix”! I just don’t want it to be his epitaph…

I was able to downgrade this library in Fedora using dnf with the following command:

sudo dnf downgrade sdl2-devel

This seems like a perfectly viable workaround for now.

Thanks for all the insights.

It’s definitely going to be my epitaph.


Heads up, @icculus did a commit recently on SDL that appears to fix this

1 Like