Transparency (blitting)...

Is there a way to draw a sprite or primitive so that it is transparent on-the-fly? Usually I would just create a bitmap and blit it with a trans_blender. But is there a way to call something like rectfill and have it draw to an existing bitmap with a set opacity level?

I believe this is possible through draw modes but am not sure.


You could use FBLend, it's fast.


void   fblend_rect_trans (BITMAP *dst, int x, int y, int w, int h, int color, int fact)


It's a nice suggestion, but I could use OpenGL or OpenLayer or a number of other alternatives but I'm sticking with vanilla Allegro on this one!

Jonny Cook

It is possible.

drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
set_trans_blender(0, 0, 0, 100);

After that, every primitive will be drawn with translucency.

Use solid_mode() or drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0) to revert back to normal drawing.

Oh, and I've been meaning to ask. There's a shortcut function for solid mode and xor mode, but why not for trans mode?

Fladimir da Gorf
drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);

Thread #577264. Printed from