[SDL] sRGB alpha blending
david at olofson.net
Sat Feb 26 14:58:07 PST 2005
On Saturday 26 February 2005 23.04, Xavier Joubert wrote:
> Current implementation is enough to draw a nice antialised space
> ship over a battlefield. Most applications don't want sRGB
> conversion, since this would mean a big drop in speed.
Then again, there's usually no h/w acceleration for alpha anyway, and
with RLE acceleration, AA sprites only depend on blending for the
Fixed Rate Pig uses AA for all sprites, and translucency for a good
deal of them at that, and still achieves frame rates in the thousands
with s/w rendering on my old P-III. I don't think it would be an
issue if the alpha blending was a few times more expensive - though
it would probably rule out old Pentium and 486 machines.
> Of course, painting programs badly need accurate alpha blending and
> don't care that much about speed.
They also tend to need a whole lot of other stuff, so I don't really
see the point in having SDL deal with their specific problems. It's
easy enough to do this in an add-on library.
> I see one way to handle this dilemna : implement a new
> SDL_BlitSurfaceAccurateBlending() function that would use sRGB
> conversion. This one would of course not be hardware accelerated,
> and so not recommended on hardware surfaces.
...you *can* h/w accelerate this, and much more, with pixel shaders.
That way, you can do it properly while running in circles around the
current s/w blitters.
Of course, that won't work on anything older than a GeForce 3 or
something, and it will only work on platforms with serious OpenGL or
Either way, it actually seems like some video cards implement, or at
least approximate this when doing normal alpha blending using some 3D
API. At least, blending with glSDL looks different on some cards and
> Maybe this function would better fit an add-on lib than SDL
Yes, but that *really* rules out h/w acceleration, unless SDL provides
some kind of low level backend API for such add-on libs to talk to.
And if such a thing is added, we risk get various add-on libs that
only support certain backends... Tricky stuff to get right.
//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 ---
More information about the SDL