[SDL] Blitting through an Intermediary

Brian bjc9019 at rit.edu
Mon Apr 26 06:32:31 PDT 2004


I am using one png file (with alpha) to hold several images belonging to a
sprite.  
I have a sprite class which I would like to have a function returning a
surface corresponding to a given request.  
My attempt at this has been calling SDL_CreateRGBSurface(…) with the default
options as presented in the documentation.
I then blit to this surface and return it.  On the upper level now I blit 
this temporary surface to the screen.  
The result is simple: nothing appears.  
If I set the amask to 0 I get a black box, but any other value (including
default 0x000000ff) seems does nothing.  
Every SDL command I call returns success. 

Some relevant code:

image = IMG_Load_RW( SDL_RWFromFile( imageFile, "rb" ), 1 );
…
temp = SDL_CreateRGBSurface(SDL_HWSURFACE, 40,80,32,rmask,gmask,bmask,amask);
…
src.w = 40;
src.h = 80;
src.x = 40*i;
src.y = 80*j;
dst.x = 0;
dst.y = 0;
SDL_BlitSurface( image, &src, temp, &dst );
…
(passed up)
…
dst.x = 2;
dst.y = 2;
SDL_BlitSurface( temp, NULL, target, &dst );


Where “target” is the screen.  
Other blits going from File -> Surface -> Display work with alpha. 
(As oppose to this File -> Surface -> Surface -> Display)

I’ve removed all my error checking and obviously quite a bit of other code,
but this is everything involving SDL calls.  
The sprite is currently 40x80 pixels,and the png file holds 3x3 images.

Thanks.






More information about the SDL mailing list