<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>ALLEGRO_COLOR for noobs</title>
		<link>http://www.allegro.cc/forums/view/618335</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 11 Jan 2021 22:42:45 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m new to Allegro. And I had a hard time figuring out how to make and array of ALLEGRO_COLOR structures. I figured it out in probably a very noobish way. Here it is but maybe someone will show how it can be done better, idk.</p><p>First define the colors.</p><p>#define BLACK al_map_rgb(0, 0 ,0)<br />#define RED al_map_rgb(255, 0, 0)<br />#define GREEN al_map_rgb(0, 255, 0)<br />#define BLUE al_map_rgb(0, 0, 255)<br />#define DARKRED al_map_rgb(128,0,0)<br />#define DARKGREEN al_map_rgb(0, 128, 0)<br />#define DARKBLUE al_map_rgb(0, 0, 128)<br />#define PINK al_map_rgb(255, 20, 147)<br />#define ORANGE al_map_rgb(255, 140, 0)<br />#define YELLOW al_map_rgb(255, 255, 0)<br />#define PURPLE al_map_rgb(147, 112, 219)<br />#define BROWN al_map_rgb(160, 82, 45)<br />#define BEIGE al_map_rgb(210, 180, 140)<br />#define LIGHTGRAY al_map_rgb(211, 211, 211)<br />#define DARKGRAY al_map_rgb(105, 105, 105)<br />#define WHITE al_map_rgb(250, 250, 250)</p><p>Then create the global ALLEGRO_COLOR structure array.</p><p>struct ALLEGRO_COLOR color[MAX_COLORS];</p><p>Then in Initialize() after al_init().</p><p>struct ALLEGRO_COLOR c[] = <br />{ BLACK,DARKBLUE,DARKRED,DARKGREEN,PINK,YELLOW,ORANGE,PURPLE,BLUE,RED,GREEN,BEIGE,BROWN };<br />for (int i = 0; i &lt; MAX_COLORS; i++) color[i] = c[i];</p><p>And now one can use the global array as in color[i] or just use a color define as in RED wherever an ALLEGRO_COLOR is needed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kingnoob)</author>
		<pubDate>Sun, 10 Jan 2021 08:46:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Isn&#39;t that redundant? Why don&#39;t you define the array directly like so:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">struct</span> <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color<span class="k2">[</span><span class="k2">]</span> <span class="k3">=</span> <span class="k2">{</span> BLACK,DARKBLUE,DARKRED,DARKGREEN,PINK,YELLOW,ORANGE,PURPLE,BLUE,RED,GREEN,BEIGE,BROWN <span class="k2">}</span><span class="k2">;</span>
</pre></div></div><p>
No need to copy the data.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (amarillion)</author>
		<pubDate>Mon, 11 Jan 2021 00:40:10 +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/618335/1048912#target">amarillion</a> said:</div><div class="quote"><p> Why don&#39;t you
</p></div></div><p>You can&#39;t call <span class="source-code"><a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a></span> before <span class="source-code"><a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a></span> so it doesn&#39;t work as a global initialiser. (actually the reason why you can&#39;t is a bit disappointing and could be fixed quite easily I think)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Mon, 11 Jan 2021 02:27: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/618335/1048914#target">Peter Hull</a> said:</div><div class="quote"><p>
(actually the reason why you can&#39;t is a bit disappointing and could be fixed quite easily I think)
</p></div></div><p>
I thought it was because the color format could change based on what system you&#39;re on.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Mon, 11 Jan 2021 10:15:25 +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/618335/1048914#target">Peter Hull</a> said:</div><div class="quote"><p> (actually the reason why you can&#39;t is a bit disappointing and could be fixed quite easily I think) </p></div></div><p><a href="https://github.com/liballeg/allegro5/pull/1217">https://github.com/liballeg/allegro5/pull/1217</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 11 Jan 2021 12:46:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nice one SL!</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618335/1048916#target">Chris Katko</a> said:</div><div class="quote"><p> I thought it was because the color format could change based on what system you&#39;re on. 
</p></div></div><p>So did I until recently; I was probably thinking of <span class="source-code"><a href="http://www.allegro.cc/manual/makecol"><span class="a">makecol</span></a></span> from Allegro 4.</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a></span> is just a 16-byte struct of four floats R, G, B and A. <span class="source-code"><a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a></span> converts each integer 0..255 to a float using a lookup table and it&#39;s that table that needs to be initialised by al_init (that is, until PR #1217!)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Mon, 11 Jan 2021 20:27:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think even the color addon will work with this change, so al_color_name(&quot;red&quot;) should be callable before main as well now (and without initializing the color addon). Not sure there&#39;s much reason to advertise it in the documentation but I may start doing it from now on in some test code <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 11 Jan 2021 22:42:45 +0000</pubDate>
	</item>
</rss>
