To get Additive blending in SDL you have to write you own funktion which
does this for you.
I have written an funktion but sadly it is very slow and i dont know how to
Also i think additive blending should be a part of SDL.
Here of how it works.
You need an source and an destionation alpha component
here the pseudo code
uint8 src_alpha, uint8 dst_alpha
float f_scr = scr_alpha / 255;
float f_dst = dst_alpha / 255;
for( int i=0;i < hight;i++)
for( int j=0; j < width ; j++)
u8 sR,sG,sB; // color value from the source image
u8 dR,dG,dB; // color value from the destination image
GetPixelValueFromSource( sR,sG,sB ,j,i);
GetPixelValueFromDestionation( dR,dG,dB ,j,i);
//calculate the final pixel which will be written to the
uint 16 r,g,b;
r = ( ( sR * f_src ) ) + ( (dR * f_dst ) ) ;
g = ( ( sG * f_src ) ) + ( (dG * f_dst ) ) ;
b = ( ( sB * f_src ) ) + ( (dB * f_dst ) ) ;
//Saturat the value to fitt
dR = r > 255 ? 255 : r;
dG = g > 255 ? 255 : g;
dB = b > 255 ? 255 : b;
PS. i have an implemtion in c for additive blending.
Maybe some one want to optimized it.( Some MMX or SSE )
2006/5/20, Rob :>
I use both SDL and sdl_gfx and I’m wondering if anyone has an example of
blitting with RLE, alpha channel using additive blending. This is kinda
going to be used for special effects and all things glowy.
I’m not an experienced programmer and I am using blitzmax, which isn’t
C++ with the SDL dll. So please be gentle
Thanks in advance!
SDL mailing list
SDL at libsdl.org