[SDL] Alpha again
Ilya Olevsky
info at valengames.com
Tue Oct 10 10:15:11 PDT 2006
> Maybe I'm not understanding how to do this or even what alpha is about.
> I've got a display surface on which I've
>
> SDL_SetAlpha (screen, SDL_SRCALPHA, 255);
>
> The pixels I'm placing directly on the surface, after having blitted a
> solid white background, have been OR'd with 0x20000000. Should I not
> see some indication of partial transparency. I seem to be getting solid
> colors in this test.
It doesn't quite work that way. There's per-surface alpha, and per-pixel
alpha, and they can't be combined. What you're setting with that call is
the per-surface alpha. So you're basically setting the surface to to be
100% opaque. What you want to do requires the surface to have an alpha
channel (RGBA), which will cause per-pixel blending. Easiest way to do
it is to make your image file store the alpha channel (use PNG or TGA).
SDL_Image will create a properly set up surface for you when you load
it.
More information about the SDL
mailing list