Stray Pixels in SDL2 Program

I’m seeing a lot of stray pixels attached to objects that I draw using SDL2. The objects the extra pixels get added to are lines, filled rectangles, and TTF text turned into textures. The SDL_RenderFillRect() function takes two arguments: an SDL_Renderer* and an SDL_Rect* to specify where to display the rectangle. I use that function for drawing rectangles. I don’t see how I could be doing something wrong. Whenever there is a stray pixel, it’s always one single pixel attached to the object. For instance, my rectangles will look like the following:

XXXXXXXXXXX
XXXXXXXXXXX
XXXXXXXXXXXX   <--- stray pixel on the right-bottom

The above is not the same number of pixels as the real image, nor the same scale, but it’s the same idea. There is an extra attached pixel.

I’ll get something similar with lines. Like this (composed of 3 lines):

                X   <--- stray pixel
XXXXXXXXXXXXXXXXX
X               X
X               X

For text, I’ll get something like this:

XXXXXXXXX
    X
    X
    X

        X   <--- stray pixel

The stray pixels always show up in the same place. For text, they’re always there. For lines and boxes, they are only sometimes there.

Any idea why this is happening? What are the sorts of things that can cause this?

Can you provide some code that reproduce the problem?

Thanks for your response. I have not yet been able to produce a minimal reproducible example. However, I did find at least a workaround (as well as a hint as to what is causing the problem), that is hopefully temporary. I found that the stray pixels went away when I called SDL_CreateRenderer() with flag SDL_RENDERER_SOFTWARE rather than SDL_RENDERER_ACCELERATED. Hopefully, I don’t find my program running super slow as I draw more things on the screen. But doing this has completely gotten rid of the stray pixels. So, I am very happy about that, at least for right now.

Can you try your code on another computer?

The reason I’m asking is that it may be a problem with your graphic card (be it drivers or an hardware failure).

I tried very similar code on a Windows machine, and the problem didn’t happen on that machine. I think it’s just an issue with the video card drivers on the other CentOS machine.

Thanks for your help. I’m good on this issue for now.