<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_set_blender and al_draw_tinted_bitmap</title>
		<link>http://www.allegro.cc/forums/view/612304</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 29 Mar 2013 13:23:05 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I searched a bit and played with various calls to <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a></span> and <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_separate_blender"><span class="a">al_set_separate_blender</span></a></span>, but now I&#39;m pretty sure this is an Allegro bug or oversight.</p><p>What I&#39;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 <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a></span> and <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_tinted_bitmap"><span class="a">al_draw_tinted_bitmap</span></a></span>, but it doesn&#39;t work as expected.</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_ONE<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_draw_tinted_bitmap"><span class="a">al_draw_tinted_bitmap</span></a><span class="k2">(</span>current_buffer, <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">1</span>, <span class="n">1</span>, <span class="n">0</span>.<span class="n">5f</span><span class="k2">)</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

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.</p><p>I&#39;m using Allegro 5.0.9.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Schyfis)</author>
		<pubDate>Fri, 29 Mar 2013 11:48:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Use the default blender (don&#39;t call <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a></span>).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jeff Bernard)</author>
		<pubDate>Fri, 29 Mar 2013 12:06:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I do this all the time (exactly the way you described) but I use ALLEGRO_ALPHA and ALLEGRO_INVERSE_ALPHA.</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_ALPHA, ALLEGRO_INVERSE_ALPHA<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Fri, 29 Mar 2013 12:11:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Try it with ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Fri, 29 Mar 2013 12:13:58 +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/612304/979324#target">Jeff Bernard</a> said:</div><div class="quote"><p>
Use the default blender (don&#39;t call al_set_blender).
</p></div></div><p>
If I do that, it&#39;s not drawn using additive blending...</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/612304/979325#target">kazzmir</a> said:</div><div class="quote"><p>
I do this all the time (exactly the way you described) but I use ALLEGRO_ALPHA and ALLEGRO_INVERSE_ALPHA.
</p></div></div><p>
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/612304/979326#target">tobing</a> said:</div><div class="quote"><p>
Try it with ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA.
</p></div></div><p>

I tried this, but it doesn&#39;t give the desired effect.<br /><span class="remote-thumbnail"><span class="json">{"name":"607330","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/2\/a2de032033c4340b3980591b20152f57.png","w":960,"h":303,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/2\/a2de032033c4340b3980591b20152f57"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/a/2/a2de032033c4340b3980591b20152f57-240.jpg" alt="607330" width="240" height="75" /></span></p><p>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 <b>should</b> be the same as the second picture, but Allegro isn&#39;t doing anything with the alpha channel. Even if it&#39;s zero, it&#39;ll still look like the third picture.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Schyfis)</author>
		<pubDate>Fri, 29 Mar 2013 12:51:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Show code &#39;cuz you&#39;re doing it wrong.</p><p>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).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Fri, 29 Mar 2013 13:13:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Argh, why didn&#39;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.</p><p>Thanks for the fix, it now looks almost exactly the same as my XNA implementation!</p><p>*gives cookies*
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Schyfis)</author>
		<pubDate>Fri, 29 Mar 2013 13:23:05 +0000</pubDate>
	</item>
</rss>
