Subtractive Blending
Michael Moffitt

Hi everyone, I've played around with Allegro's blending mode parameters, but I'm not sure I am exploring as fully as I could be to get this desired effect.

Basically, let's say I have a bitmap already drawn called A. I have another bitmap, B, which has not yet been drawn.

When I draw B on top of A, I want the result to be A - B, with all negative values clamped to zero.

In reality, A represents a buffer to which I am blitting most of the game. For the final image B, I want that one to be blended with subtractive blending while the others are all normal.

Is this something that can be done without massive complication?

Edgar Reynaldo

See al_set_blender and al_set_separate_blender.

I think this will do what you want. Not sure about clamping negative values though, but it probably does.

al_set_blender(ALLEGRO_DEST_MINUS_SRC , ALLEGRO_ONE , ALLEGRO_ONE);

Thread #615575. Printed from Allegro.cc