Alpha again

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.

Thanks,
Lilith

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.

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. :slight_smile:

Lilith>>> On 10/10/2006 at 12:15 PM, in message <MPG.1f959f2ac9b1eb89989696 at news.gmane.org>, Ilya Olevsky wrote:

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?

You can do it manually too. I’ve never tried it, but this should work:
make an RGBA surface using SDL_CreateRGBSurface() (you have to set the
alpha mask, there’s an example in the wiki). Then, you can use
SDL_MapRGBA() to convert each RGBA pixel value you want to put in the
surface to the surface’s pixel format. And finally, there are some
helpful functions for putting the pixel into the surface here:
http://www.libsdl.org/cgi/docwiki.cgi/Pixel_20Access

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. :slight_smile:

There are a bunch of books that cover SDL in some way, search for "SDL"
on amazon.com and you’ll see them. I don’t know if they’d cover this
kind of stuff though. I learned SDL the good old fashioned way, by using
the API docs and the mailing list. :slight_smile:

Ilya

Be careful though, many other things in the computer industry use the
acronym “SDL”. :wink:

http://en.wikipedia.org/wiki/Simple_Declarative_Language



http://en.wikipedia.org/wiki/POV-Ray (has a “Scene Description Language”)On 10/10/06, Ilya Olevsky wrote:

There are a bunch of books that cover SDL in some way, search for "SDL"
on amazon.com and you’ll see them. I don’t know if they’d cover this
kind of stuff though. I learned SDL the good old fashioned way, by using
the API docs and the mailing list. :slight_smile:

  • SR

I found that out while doing a Google on the subject. And some of the
snippets in the Google listings were misleading.

Lilith

There are a bunch of books that cover SDL in some way, search for
"SDL"

on amazon.com and you’ll see them. I don’t know if they’d cover
this

kind of stuff though. I learned SDL the good old fashioned way, by
using

the API docs and the mailing list. :slight_smile:

Be careful though, many other things in the computer industry use
the
acronym “SDL”. :wink:

http://en.wikipedia.org/wiki/Simple_Declarative_Language
http://en.wikipedia.org/wiki/Specification_and_Description_Language

http://en.wikipedia.org/wiki/Trustworthy_Computing_Security_Development_Life

cycle
http://en.wikipedia.org/wiki/POV-Ray (has a “Scene Description
Language”)>>> On 10/10/2006 at 1:11 PM, in message <3158703d0610101111u57c503cfk7d0a4d2aa58bb061 at mail.gmail.com>, “Simon Roby” <simon.roby at gmail.com> wrote:
On 10/10/06, Ilya Olevsky wrote: