Is it legal to blit to and from the same surface, as long as the source and
destination areas don’t overlap? SDL’s behavior seems inconsistent.
I wrote a simple program to fill areas of a surface with a checkerboard
pattern of 2 colors: http://burningsmell.org/code-snippets/checker.c
It does this:
- Sets clip rect to allowed area
- Draws a pattern of 4 squares in the upper left with SDL_FillRect’s
- While it’s narrower than the area, blit it right of and double width
- While it’s shorter than the area, blit it below itself and double height
Usually this works great, but in circumstances that seem to be painfully
difficult to reduce to a simple example, it only draws the upper left
rectangle – nothing else appears. I have confirmed that it actually is
doing all the blitting it’s supposed to when this happens – the blits just
Is this supposed to work, or am I relying on undefined behavior by using the
same source and destination surface?