[SDL] A couple questions on SDL

Gerry JJ trick at icculus.org
Thu Jul 13 04:44:52 PDT 2006


On Thu, 13 Jul 2006 05:55:44 +0200, Lilith Calbridge <lilith at dcccd.edu>  
wrote:
> That'll teach me to leave my thinking cap back at the office.  I was
> thrown by the statement in the documentation that only the x and y
> values of the source rectangle are used.  I should have figured that the
> blit would use the w and h values of the destination rectangle to define
> what to transfer from the source surface.

You got that backwards.  The w and h values are used in the source
rectangle, but not in the destination rectangle (since the size was
already determined by the source rect, and SDL doesn't support scaled
blits).  Also note that the dest rect is modified to contain the
rectangle that was affected (after clipping).

> One more question if I could.  The SDL_CreateRGBSurfaceFrom
> documenation says "The pixel data is not copied into the SDL_Surface
> structure so it should not be freed until the surface has been freed
> with a call to SDL_FreeSurface."  Does this mean that the surface
> structure is set to point to the pixel data presented in the function
> argument and doesn't create a pixel array of its own?

Yes.  (If you want SDL to handle the allocation and freeing of the pixel
data, you can use SDL_CreateRGBSurface() and blit/copy/etc to the created
surface.  If you copy the pixels directly, be careful of the pitch.)

- Gerry




More information about the SDL mailing list