What is the A5 equivalent of set_multiply_blender / draw_trans_sprite?
draw_trans_sprite = al_convert_mask_to_alpha?
The other one I have no idea.
Sorry I meant the combination of set_multiply_blender with draw_trans_sprite. I want to get that effect.
al_draw_tinted_bitmap is effectively equal to draw_trans_sprite with the right blender set.
For someone not knowing what those A4 functions do - what is the effect you want?
Well here is the description from allegro.txt:
void set_multiply_blender(int r, int g, int b, int a);
Enables a multiply blender mode for combining translucent or lit
truecolor pixels. Combines the source and destination images, multiplying
the colours to produce a darker colour. If a colour is multiplied by
white it remains unchanged; when multiplied by black it also becomes
black.
I don't know how to describe what the blender is doing any other way. Its implemented by multiplying the individual components of the two colors (source and destination). Here is the code I use in sdl which was copied from allegro4.
Where x is source, y is destination, and n is the current alpha value.
trans sprite is going to be
ALLEGRO_BITMAP *bmp; float alpha = 0.1; al_draw_tinted_bitmap(bmp, al_map_rgba_f(alpha, alpha, alpha, alpha), x, y, NULL);
There is no multiply blender. The closest thing you can get to is the subtractive blender:
al_set_blender(ALLEGRO_DEST_MINUS_SRC, ALLEGRO_ONE, ALLEGRO_ONE);
or make a shader
Are all the hardware blenders implemented in scanline_drawers.c? Couldn't a new blender be added that did
r = dr * dst * sr * sa; ...
Or am I missing how the blenders are associated with hardware acceleration?
Those are software blenders. They are used on locked bitmaps, or memory bitmaps.
So yes, if you want to add it, you need to add it to the software blenders, but also for OpenGL and DirectX.
For OpenGL it would be almost trivial, what you need is probably either the SRC_COLOR or DST_COLOR blend factor (in A5 it would be another blend factor like ALLEGRO_ALPHA mapped 1:1 to it, ALLEGRO_SOURCE_COLOR and ALLEGRO_DESTINATION_COLOR maybe):
http://www.khronos.org/opengles/sdk/docs/man/xhtml/glBlendFunc.xml
No idea about DirectX but since GPUs support it DirectX most likely also supports it somehow.