<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>alpha on back buffer</title>
		<link>http://www.allegro.cc/forums/view/606098</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 18 Jan 2011 19:21:38 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Why do I get different behavior when I run this on the back buffer vs a video bitmap?
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a><span class="k2">(</span>ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO<span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/al_clear_to_color"><span class="a">al_clear_to_color</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a><span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">1</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
c <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_pixel"><span class="a">al_get_pixel</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_target_bitmap"><span class="a">al_get_target_bitmap</span></a><span class="k2">(</span><span class="k2">)</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>    
<a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%f %f %f %f\n"</span>, c.r, c.g, c.b, c.a<span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/al_draw_pixel"><span class="a">al_draw_pixel</span></a><span class="k2">(</span><span class="n">0</span>.<span class="n">5</span>,<span class="n">0</span>.<span class="n">5</span>, <a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a><span class="k2">(</span><span class="n">1</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
c <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_pixel"><span class="a">al_get_pixel</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_target_bitmap"><span class="a">al_get_target_bitmap</span></a><span class="k2">(</span><span class="k2">)</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>    
<a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%f %f %f %f\n"</span>, c.r, c.g, c.b, c.a<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Output using display&#39;s back buffer:
</p><pre>
0,0,0,1 
1,0,0,1
</pre><p>
But I&#39;d expect the second line to be <tt>1,0,0,0</tt>, and the pixel not to be drawn.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 17 Jan 2011 10:10:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I assume your back buffer has no alpha channel - you can check it with al_get_bitmap_format(al_get_target_bitmap()).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 17 Jan 2011 18:03:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It still shouldn&#39;t draw the pixel, should it..?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Mon, 17 Jan 2011 19:28:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>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.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 17 Jan 2011 19:37:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You mean the order of his 1&#39;s and 0&#39;s is AGBR and the incorrect alpha value should be disregarded?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 17 Jan 2011 19:40:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>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.</p><p>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).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 17 Jan 2011 20:03:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, I didn&#39;t see the al_set_blender call.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Mon, 17 Jan 2011 20:04:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606098/899077#target">Elias</a> said:</div><div class="quote"><p> I assume your back buffer has no alpha channel - you can check it with al_get_bitmap_format(al_get_target_bitmap()).
</p></div></div><p>Pixel format is reported to be <span class="source-code">ALLEGRO_PIXEL_FORMAT_ABGR_8888</span> on both the backbuffer and the video bitmap.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 17 Jan 2011 21:40:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sounds like a bug then - I guess the backbuffer never has actual alpha without doing something special. Is this with OpenGL?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 17 Jan 2011 22:02:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606098/899120#target">Elias</a> said:</div><div class="quote"><p> Is this with OpenGL?
</p></div></div><p>Yes.</p><p>How is one supposed to set the back buffer format with Allegro?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Mon, 17 Jan 2011 22:05:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>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?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Mon, 17 Jan 2011 23:57:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>0.5,0.5 is the middle of the pixel in the top left corner, so it will always flag that one.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (J-Gamer)</author>
		<pubDate>Tue, 18 Jan 2011 00:06:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606098/899122#target">Matthew Leverton</a> said:</div><div class="quote"><p>How is one supposed to set the back buffer format with Allegro?
</p></div></div><p>

You&#39;re not supposed to use anything but the default <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> In all other cases, you can use <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_new_display_option"><span class="a">al_set_new_display_option</span></a></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Tue, 18 Jan 2011 00:30:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I like the integration of the forum with the manual. Very cool.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Tue, 18 Jan 2011 19:21:38 +0000</pubDate>
	</item>
</rss>
