|
alpha on back buffer |
Matthew Leverton
Supreme Loser
January 1999
|
Why do I get different behavior when I run this on the back buffer vs a video bitmap? al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_clear_to_color(al_map_rgba_f(0,0,0,1)); c = al_get_pixel(al_get_target_bitmap(), 0, 0); printf("%f %f %f %f\n", c.r, c.g, c.b, c.a); al_draw_pixel(0.5,0.5, al_map_rgba_f(1,0,0,0)); c = al_get_pixel(al_get_target_bitmap(), 0, 0); printf("%f %f %f %f\n", c.r, c.g, c.b, c.a); Output using display's back buffer: 0,0,0,1 1,0,0,1 But I'd expect the second line to be 1,0,0,0, and the pixel not to be drawn. |
Elias
Member #358
May 2000
|
I assume your back buffer has no alpha channel - you can check it with al_get_bitmap_format(al_get_target_bitmap()). -- |
X-G
Member #856
December 2000
|
It still shouldn't draw the pixel, should it..? -- |
Elias
Member #358
May 2000
|
ADD/ONE/ZERO means the r/g/b/a value simply is copied as is. So his 1/0/0/0 pixel is copied to the target. The alpha channel only matters when you use a blend mode of ALPHA or INVERSE_ALPHA somewhere. -- |
Arthur Kalliokoski
Second in Command
February 2005
|
You mean the order of his 1's and 0's is AGBR and the incorrect alpha value should be disregarded? They all watch too much MSNBC... they get ideas. |
Elias
Member #358
May 2000
|
No, he draws a pixel with r=1,g=0,b=0,a=0. With a blend mode of ADD/ALPHA/INVERSE this would mean that r/g/b/a is multiplied with a first so everything is multiplied with 0 so it all gets 0. Nothing at all is drawn. With the blend mode he uses (ADD/ONE/ZERO) the r/g/b/a are simply copied (the destination is multiplied with 0, the source is multiplied with 1 therefore left as is). The alpha value (a=0) is not used at all. The only unexpected thing is that when he reads the pixel back the alpha magically turned 1. This is a bug if the bitmap does have an alpha channel, otherwise is expected (a bitmap without alpha always behaves like a bitmap with an alpha channel of all 1). -- |
X-G
Member #856
December 2000
|
Yeah, I didn't see the al_set_blender call. -- |
Matthew Leverton
Supreme Loser
January 1999
|
Elias said: I assume your back buffer has no alpha channel - you can check it with al_get_bitmap_format(al_get_target_bitmap()). Pixel format is reported to be ALLEGRO_PIXEL_FORMAT_ABGR_8888 on both the backbuffer and the video bitmap. |
Elias
Member #358
May 2000
|
Sounds like a bug then - I guess the backbuffer never has actual alpha without doing something special. Is this with OpenGL? -- |
Matthew Leverton
Supreme Loser
January 1999
|
Elias said: Is this with OpenGL? Yes. How is one supposed to set the back buffer format with Allegro? |
Neil Walker
Member #210
April 2000
|
Trying not to sound stupid, could it be something to do with the position and not the colour? as in one buffer is interpreting 0.5 at the wrong location? Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
J-Gamer
Member #12,491
January 2011
|
0.5,0.5 is the middle of the pixel in the top left corner, so it will always flag that one. " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
Elias
Member #358
May 2000
|
Matthew Leverton said: How is one supposed to set the back buffer format with Allegro? You're not supposed to use anything but the default In all other cases, you can use al_set_new_display_option. -- |
Neil Walker
Member #210
April 2000
|
I like the integration of the forum with the manual. Very cool. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
|