- Online Community Forums » Programming Questions » Transparency (blitting)...

This thread is locked; no one can reply to it. rss feed Print
Transparency (blitting)...
Member #5,114
October 2004

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.

Member #4,338
February 2004

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)

* * * * *
"Multiplayer is actually the best way of not programming a good AI" -ReyBrujo

Member #5,114
October 2004

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
Member #4,055
November 2003

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?

The face of a child can say it all, especially the mouth part of the face.

Fladimir da Gorf
Member #1,565
October 2001

drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Go to: