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?