I’ve noticed that SDL_UpdateRect() will return without doing any work if
the passed arguments effectively form an update rectangle that goes “off
screen” either on the right side, or the bottom edge.
SDL_UpdateRect() will NOT fail if the effective rectangle goes “off
screen” on the left side or the top edge. It only fails (does no work)
if the effective rectangle goes “off screen” on the right or bottom.
On the other hand, SDL_UpdateRects() does not make these tests and it
will update virtually any logical rectangle, regardless of whether any
part of the update rectangle is “off screen”.
I just wondering if this is “by design” or potentially a bug? What I
found out was that I cannot use these two functions interchangably.
That is, if I have calculated an update rectangle that may include an
"off screen" region, I must use SDL_UpdateRects(). I can only use
SDL_UpdateRect() if I preprocess my rectangle to clip to the screen.
The code in question in SDL_video.c for SDL_UpdateRect() are:
if ( (int)(x+w) > screen->w )
if ( (int)(y+h) > screen->h )
Are there any historical reasons for these tests, or could they possibly
be removed for future releases of SDL?