|
al_set_blender and al_draw_tinted_bitmap |
Schyfis
Member #9,752
May 2008
|
I searched a bit and played with various calls to al_set_blender and al_set_separate_blender, but now I'm pretty sure this is an Allegro bug or oversight. What I'm trying to do is port some existing XNA code over to Allegro, and part of that involves drawing an image using additive blending, but at 50% opacity. As far as I can tell, Allegro should be capable of this if I use al_set_blender and al_draw_tinted_bitmap, but it doesn't work as expected. al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE); al_draw_tinted_bitmap(current_buffer, al_map_rgba_f(1, 1, 1, 0.5f), 0, 0, 0); Even if I change the 0.5f to 0, it will still be drawn at 100% opacity. The red, green, and blue values work as expected with additive blending, but not alpha. I'm using Allegro 5.0.9. ________________________________________________________________________________________________________ |
Jeff Bernard
Member #6,698
December 2005
|
Use the default blender (don't call al_set_blender). -- |
kazzmir
Member #1,786
December 2001
|
I do this all the time (exactly the way you described) but I use ALLEGRO_ALPHA and ALLEGRO_INVERSE_ALPHA. al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
|
tobing
Member #5,213
November 2004
|
Try it with ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA. |
Schyfis
Member #9,752
May 2008
|
Jeff Bernard said: Use the default blender (don't call al_set_blender). If I do that, it's not drawn using additive blending... kazzmir said: I do this all the time (exactly the way you described) but I use ALLEGRO_ALPHA and ALLEGRO_INVERSE_ALPHA.
tobing said: Try it with ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA.
I tried this, but it doesn't give the desired effect. The original is drawn first, then the glow is drawn on top of it using an additive blender and at 50% opacity. The third picture should be the same as the second picture, but Allegro isn't doing anything with the alpha channel. Even if it's zero, it'll still look like the third picture. ________________________________________________________________________________________________________ |
Trent Gamblin
Member #261
April 2000
|
Show code 'cuz you're doing it wrong. EDIT: nvm, you showed enough code. Allegro uses premultiplied alpha, so your color should be al_map_rgba_f(color.r*a, color.g*a, color.b*a, a).
|
Schyfis
Member #9,752
May 2008
|
Argh, why didn't I think of that?! Using additive blending, doing that is exactly the same as changing the alpha! I guess I was looking at it for too long. Thanks for the fix, it now looks almost exactly the same as my XNA implementation! *gives cookies* ________________________________________________________________________________________________________ |
|