Hello sdl,
And more questions…
I want to blit pictures with alpha channel. Because there is
function for loading images only for .bmp format I saved my picture
in that format, with 32 bits. I’m even know is .bmp supporting
alpha channel, but I assumed it does, because there is 32bit mode
(is it?).
There might be some recent or unofficial alpha extension to BMP, but
even if there is, I’m quite sure SDL doesn’t support it.
Then I set alpha mode for blitting:
SDL_SetAlpha(sprite, SDL_SRCALPHA |SDL_SRCCOLORKEY , 255);
I tried also:
SDL_SetAlpha(sprite, SDL_SRCALPHA , 255);
The latter is what you should use. The colorkey flag is for the
SDL_SetColorKey() call, and you shouldn’t mess with colorkeying
together with alpha channel normally anyway.
But then whole image is visible - alpha is ignored. What is wrong
here? bmp format or wrong alpha setting?
Have you tried loading those images into GIMP, PhotoShop or whatever
you’re using? I suspect that there is no alpha channel. It could be
that the generating application has reduced alpha to colorkey, but
you most probably don’t want that. (1 bit “alpha”…)
(Only last parameter really works (effects blending))
Yeah, that’s the full surface blending feature - and since that
doesn’t mix with alpha channel blending, you obviously do not get an
alpha channel when you load those images.
If .bmp is guilty for that how can I open i.e. .tga format?
TGA should work, but I’d strongly recommend PNG. It does what you
need, and you get serious non-destructive compression as a bonus.
Generally speaking what is the best way to improvise sprites (with
alpha)?
The way you’re trying to do it (with a suitable file format) - or
perhaps via OpenGL, if accelerated OpenGL is an acceptable system
requirement…
I mean should I for every frame blit background and then
sprites, or should I save background only of areas that sprites
will destroy, and at next frame first do all repairs and get new
backgrounds and then draw sprites or some other way is better?
Something in between. Never blit from the screen! You could end up
reading VRAM, which is slow enough that just a few sprites will
render slower than rerendering the whole screen every frame.
By “something in between” I mean remove sprites by redrawing the
background over the old areas, using map + tiles or whatever you’re
using. You could have a look at by Pig “example” (playable game, sort
of), which does exactly this. (See URL in sig; “SDL Examples”.)
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Wednesday 01 December 2004 12.22, Milan Golubovic wrote: