Bug in SDL?

After some hours of debugging and source-code reading
I found this problem in SDL.

the problem was that with a surface created with

SDL_CreateRGBSurfaceFrom(…)

I couldnt use any blitting or filling operations on it.
nothing changed on the surface.

the thing was that clip_rect was { 0,0,0,0 }
causing everything to get clipped.

checking the source for SDL_CreateRGBSurfaceFrom…

— snip ----

SDL_Surface * SDL_CreateRGBSurfaceFrom (void *pixels,
int width, int height, int depth, int pitch,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
SDL_Surface *surface;

surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, depth,
Rmask, Gmask, Bmask, Amask);
if ( surface != NULL ) {
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
surface->w = width;
surface->h = height;
surface->pitch = pitch;
}
return(surface);
}

— snip —

then I noticed that clip_rect is set up in the call to SDL_CreateRGBSurface,
and with width and height set to 0.

is this correct behavior? or should clip_rect be { 0,0,w,h }?

/Lomax of Probe.

SDL_CreateRGBSurfaceFrom(…)
[…]
the thing was that clip_rect was { 0,0,0,0 }
causing everything to get clipped.

Thanks, patch follows. Sam, please apply.

diff -u -r1.8.2.22 SDL_surface.c
— SDL_surface.c 2000/10/10 19:23:03 1.8.2.22
+++ SDL_surface.c 2000/11/21 16:51:40
@@ -154,6 +154,7 @@
surface->w = width;
surface->h = height;
surface->pitch = pitch;

  •   SDL_SetClipRect(surface, NULL);
    
    }
    return(surface);
    }

SDL_CreateRGBSurfaceFrom(…)
[…]
the thing was that clip_rect was { 0,0,0,0 }
causing everything to get clipped.

Thanks, patch follows. Sam, please apply.

Done! I’m off to catch my flight!

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software