RGBA surface

I have problem. I don’t understand how to create RGBA surface. I need to create surface like created when i loaded transparent png picture (using SDL_image). It must be only transparent surface. I read http://www.libsdl.org/cgi/docwiki.cgi/SDL_SetAlpha but i haven’t understood.

Having the same problem, I tried modifying the testgl.c program that comes with the SDL source package to use png files instead of bmp files, but the alpha gets lost. Been posting my questions on the SDL development forum. Will try and remember to post what I find here if I get a good answer.

Also you might want to check out the tests directory in SDL-1.X.XX.tar.gz think there is a testalpha.c that might be of help, I’m trying to do it with opengl so the code I’m trying may be slightly different.

If you are transferring from one surface to another using SDL_BlitSurface call

SDL_Surface * destSurface,srcSurface;
/* Initialise surfaces in here */

This sets the surface to copy the alpha from the source alpha to the destination alpha, without trying to do any blending. From the SDL docs :>

Note: Note that RGBA->RGBA blits (with SDL_SRCALPHA set) keep the alpha of the destination surface. This means that you cannot compose two arbitrary RGBA surfaces this way and get the result you would expect from “overlaying” them; the destination alpha will work as a mask.