Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Any way to make a transparent white primitive?

Credits go to gillius for helping out!
This thread is locked; no one can reply to it. rss feed Print
Any way to make a transparent white primitive?
Engired
Member #23,752
April 2023

I was trying to do a simple fade in fade out sort of thing with primitives, but it looks like al_map_rgba_f(1.0, 1.0, 1.0, 0.5 (as an example)) won't blend properly. I assume there's a better blending option that would make it work, but I'm a bit concerned that it'll make the transparent parts of my bitmaps not blend properly either. Fading with black works, so I can always just do that, but I'd love it if there is a way to do it with white.

(allegro 5 by the way)

gillius
Member #119
April 2000

It's been awhile since I used Allegro, but my guess is it's an issue with the blending mode.

https://www.allegro.cc/manual/5/al_set_blender

It seems like you want a weighted average of the source and destination color, which starts at alpha 0 (no effect) to 1.0 (full white).

In that case I think you'd want this:
al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA)

Gillius
Gillius's Programming -- https://gillius.org/

Engired
Member #23,752
April 2023

Works exactly as I wanted it to. Thanks for the help!

Go to: