Hi All,
I am fairly new to graphics programming in general and I’m trying some
things out with SDL/OpenGL.
One thing that has gotten me very confused is blitting, specifically to do
with off screen surfaces. I have put a test program together that uses
SDL_Image to load some .pngs (32 bit), which works fine. Now I am trying to
create an off screen (actually SDL_SWSURFACE) surface and then blit multiple
pngs into it to form a surface that will pretty much stay the same frame to
frame (but will be recreated periodically). The surface creation call is
below:
m_pSurface =
SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, m_iWidth, m_iHeight,
32,rmask,gmask,bmask,amask);
The problem is I would like to preserve the alpha channel from the image
when blitting to the newly created surface (or even better have the two
blend) but this doesn’t seem possible with standard SDL commands. A quote
from the documentation for SDL_SetAlpha
"
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. :
”
I think this means that in order to have my images show properly my
destination surface should have alpha == 255 which means that blitting this
new surface to the opengl backbuffer will not allow for partial transparancy
from the original image. What’s more, for those pixels that don’t have
images blitted over them I would prefer a 0 alpha, but in order to do this I
would have to use a mask or something to zero out the alpha after the blits.
I am probably way off on all this and would appreciate any thoughts the more
knowledgable may have. Do I have to implement the pixel copies myself in
order to blend the alpha channels from source and destination together? It’s
not a problem, I guess I just assumed that SDL would handle this kind of
thing.
Thanks in advance.
Mike.