hi
is it possible to blit surfaces with SDL that contain different alpha
values? e.g. to have a sprite that has alpha values of 0 for regions
that should not be visible.
Yes. But do you really need alpha? You could use colorkeying instead,
at least on slow machines, as that’s much faster.
Or just take the route I did in Kobo Deluxe; my SDL port of XKobo:
http://olofson.net/skobo
I convert everything into 32 bit RGBA, run it through scaling filters
and stuff, and eventually run a “contrast/brightness” filter and then a
“max/min threshold” filter on the alpha channels. This enables me to
tweak the blending effects (such as that of the game window frame), and
remove any “alpha noise” that could cause the alpha blitter to be used
more than necessary. It would also be possible to set the filters up to
practically eliminate alpha blending, but I’m currently not doing this,
as it made little difference when I tried it. (Maybe it matters more on
machines with very slow multiplications… Haven’t tested that
thoroughly.)
i know this could be done with openGL but i
can’t count on hardware acceleration for my program.
Ok - but keep in mind that it’s pretty slow, compared to opaque and
colorkey blits. Also keep in mind that fully opaque and fully transparent
areas are optimized by the RLE blitter of SDL, so those areas don’t cost
more than opaque blits, or just skipping, even if there are alpha blended
areas on the surface.
Further, 50% alpha is a special case that faster than other alpha levels
- you could try using that as much as possible if you’re low on CPU
power, but still need alpha blending.
if alpha blitting is possible, how must the pixel format be specified?
RGBA, basically. Just pass the surfaces through SDL_SetAlpha() or
SDL_SetColorKey() with the SDL_RLEACCEL flag set, and then
SDL_DisplayFormatAlpha() or SDL_DisplayFormat() respectively, and you
should get what you want.
//David Olofson — Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |
-------------------------------------> http://olofson.net -'On Monday 04 February 2002 23:14, Eike Umlauf wrote: