[SDL] Alpha again

Lilith Calbridge lilith at dcccd.edu
Tue Oct 10 10:27:34 PDT 2006



>>> On 10/10/2006 at 12:15 PM, in message
<MPG.1f959f2ac9b1eb89989696 at news.gmane.org>, Ilya Olevsky
<info at valengames.com>
wrote:
>>  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.

Hmmmm.  Up front I don't have an image.  I can generate a PNG file with
alpha
but I'm looking at drawing pixels directly to the display surface.  Am
I going to need to
use an intermediate surface and blit it to the display surface?

Sorry, if I seem confused.  But much of the data I can find on the
subject seems to be 
scattered about.  And there's a lot of how to do but not an awful lot
on why to do, which
would help me understand why something's done a certain way.  Is there
an overview
of SDL rather than raw API documentation?  My roommate says she has a
book on SDL
but it's buried under a roomful of gaming books.  :-)

Lilith




More information about the SDL mailing list