[SDL] Alpha again
Ilya Olevsky
info at valengames.com
Tue Oct 10 10:53:10 PDT 2006
> 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. :-)
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. :-)
Ilya
More information about the SDL
mailing list