Why this SDL_UpdateRect behavior?

I have a 800x600 surface. If I call SDL_UpdateRect(screen, 790, 1, 10,
5),
everything works as expected (note that 790 + 10 <= 800). However, if I
call SDL_UpdateRect(screen, 790, 1, 11, 5), nothing gets updated,
although
the rectangle I’m passing does overlap the screen.

The problem lies within SDL_UpdateRect itself :

if ( (int)(x+w) > screen->w )
	return;

Why is this? It’s not documented. The behavior I’d expect would be

if ( (int)(x+w) > screen->w )
	w = screen->w - x;

Or, as optimizations,

if (( x > screen->w ) || ( x + w < 0) )
	return;

Thanks,
–Gabriel

Ing. Gabriel Gambetta
ARTech - GeneXus Development Team
ggambett at artech.com.uy

Gabriel Gambetta wrote:

I have a 800x600 surface. If I call SDL_UpdateRect(screen, 790, 1, 10,
5),
everything works as expected (note that 790 + 10 <= 800). However, if I
call SDL_UpdateRect(screen, 790, 1, 11, 5), nothing gets updated,
although the rectangle I’m passing does overlap the screen.

Unless it’s considered a bug, it has to be documented, of course. Though,
none of the SDL functions are strictly specified, so you shouldn’t rely
on undocumented behaviour anyway and beware exploiting strange effects.
IMHO, the check shouldn’t be within the routine because it would penalize
everyone who doesn’t pass out-of-bounds values and I guess it’s rather
unlikely that someone does.–
Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040114/eee6d098/attachment.pgp

SDL_UpdateRect and SDL_UpdateRects do not clip, this is documented.
However, SDL_BlitSurface does clip it’s output rectangle so that it
can be passed directly to SDL_UpdateRects. This is an optimization
from back when clipping lots of rectangles twice made a significant
difference in performance.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment