<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>create_trans_table</title>
		<link>http://www.allegro.cc/forums/view/580693</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 21 Apr 2006 14:53:42 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Setting up a little translucent GUI for my game.  I haven&#39;t messed with the blender or draw_trans_sprite and/or draw_lit_sprite functions hardly at all, so pardon if I say something obviously incorrect.  Anyway, as a quick test, I added this to the game:</p><div class="source-code snippet"><div class="inner"><pre>...
<a href="http://www.allegro.cc/manual/PALETTE" target="_blank"><span class="a">PALETTE</span></a> pal<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/COLOR_MAP" target="_blank"><span class="a">COLOR_MAP</span></a> trans_table<span class="k2">;</span>

<a href="http://www.allegro.cc/manual/set_palette" target="_blank"><span class="a">set_palette</span></a><span class="k2">(</span>pal<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/create_trans_table" target="_blank"><span class="a">create_trans_table</span></a><span class="k2">(</span><span class="k3">&amp;</span>trans_table, pal, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, NULL<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/set_trans_blender" target="_blank"><span class="a">set_trans_blender</span></a><span class="k2">(</span><span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">128</span><span class="k2">)</span><span class="k2">;</span>

...
<span class="c">//Inside game loop</span>
<a href="http://www.allegro.cc/manual/rectfill" target="_blank"><span class="a">rectfill</span></a><span class="k2">(</span>bText, <span class="n">0</span>, <span class="n">0</span>, bText-&gt;w, bText-&gt;h, GREEN<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/draw_trans_sprite" target="_blank"><span class="a">draw_trans_sprite</span></a><span class="k2">(</span>buffer, bText, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
...
</pre></div></div><p>

Now, the manual says about create_trans_table:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The r, g, and b parameters specify the solidity of each color component, ranging from 0 (totally transparent) to 255 (totally solid). For 50% solidity, pass 128.
</p></div></div><p>
But, when I try to change anything of those parameters, nothing changes.  In fact, if I try to change the first parameters of set_trans_blender parameters, nothing changes. To me, only changing the last parameter of set_trans_blender does anything.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Fri, 21 Apr 2006 08:19:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Have you remembered to set the rgb_map and the color_map global variables after creating your transparency table?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Fri, 21 Apr 2006 08:29:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Have you remembered to set the rgb_map and the color_map global variables after creating your transparency table?
</p></div></div><p>
It&#39;s not that I didn&#39;t remember, it&#39;s that I didn&#39;t know.  What do I set them to?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Fri, 21 Apr 2006 08:49:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><i>rgb_map</i> isn&#39;t necessary it seems, it only speeds transformations up. Check <a href="http://www.koders.com/c/fid14C9954173938475738A9C0E4A3ED60B9651A19E.aspx#L98">extrans.c</a>, line 99. You set the global <i>color_map</i> to point to your <i>trans_table</i>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Fri, 21 Apr 2006 08:56:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I set color_map = &amp;trans_table and the parameters of create_trans_table and set_trans_blender still don&#39;t make any difference.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Fri, 21 Apr 2006 09:09:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Try the extrans.c, modifying the values you are modifying in your program, and see if it doesn&#39;t change as well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Fri, 21 Apr 2006 09:15:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It seems if I set the color depth to 32, those parameters don&#39;t do anything.  At least, that&#39;s what I did with the extrans.c.</p><p>That&#39;s okay, I still have enough control to do what I need.  I was just curious as to why they weren&#39;t doing anything.  Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Fri, 21 Apr 2006 09:31:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Wait... you were using 32bpp? Palettes are for 8bpp only.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Fri, 21 Apr 2006 09:34:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
pardon if I say something obviously incorrect
</p></div></div><p>
I didn&#39;t know that either.  I just saw the create_trans_table() function needed a palette, so I set one up.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Fri, 21 Apr 2006 10:15:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You need to set the drawing mode to tell allegro you want fancy effects. Like so:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// let's do some fancy schmancy stuff!</span>
<a href="http://www.allegro.cc/manual/drawing_mode" target="_blank"><span class="a">drawing_mode</span></a><span class="k2">(</span>DRAW_MODE_TRANS, NULL, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="c">// draw it</span>
<a href="http://www.allegro.cc/manual/rectfill" target="_blank"><span class="a">rectfill</span></a><span class="k2">(</span>...<span class="k2">)</span><span class="k2">;</span>
<span class="c">// back to normal drawing</span>
<a href="http://www.allegro.cc/manual/solid_mode" target="_blank"><span class="a">solid_mode</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Peitz)</author>
		<pubDate>Fri, 21 Apr 2006 10:23:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, that&#39;s what you really want unless you&#39;re dealing with lower color modes. (256 and below I believe) Remember allegro&#39;s blender modes are a little slow.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ceagon Xylas)</author>
		<pubDate>Fri, 21 Apr 2006 10:28:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Oh, don&#39;t worry. You know, I only work with 8bpp modes, so stuff like palette manipulation I take it for granted... from 15bpp to above, I know nothing <img src="http://www.allegro.cc/forums/smileys/embarassed.gif" alt=":-[" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Fri, 21 Apr 2006 10:32:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Colors are represented ultimately differently between 8bpp and everything else. 8bpp uses a global palette, and each color value represents an index into the palette. 15bpp and above packs RGB values directly into a single integer (16, 24 or 32 bits wide).<br />In high-color modes, a color&#39;s rgb components can be manipulated directly, and all kinds of blending, mixing, and lighting are implemented through blender functions, all of which take two colors and output another color.<br />In palette (8bpp) mode, though, this is highly inefficient, since it would involve:<br />1. Get the input color RGB values from the current palette<br />2. Appy the blender function<br />3. Find the nearest match for the result and return it.<br />Especially step 3 takes too long to be useful, even with an rgb_map.<br />Instead, one calculates the result for each possible pair of input values once and stores it in a table (the trans_table). After that, the &quot;blend&quot; operation is nothing more than a simple 2d array lookup.<br />Apart from that, a custom blender table allows for &quot;special&quot; colors, e.g. something like an alpha-aware palette that chooses blend factors according to color index; or &quot;team colors&quot;, implemented using a selective color replacement table.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 21 Apr 2006 14:53:42 +0000</pubDate>
	</item>
</rss>
