<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>No red, only green and blue!</title>
		<link>http://www.allegro.cc/forums/view/589314</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 30 Dec 2006 20:26:06 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello Allegro gurus,</p><p>I am currently working on my game project and I have some strange behaviours with the colors. When I use 15 bits colors (values taken from the game boy palettes) I get the correct display colors when I use the getr15, getg15 and getb15 under Windows. When I recompile the project on Mac OS X (tiger-intel c2d and Xeon) I get wrong colors: I have only green and blue composites and no red. I have declared 32bits color depth on my bitmaps. When I check the degugging values I have the corect colors values on both Windows and Tiger but the display result differ. Is there a problem with colors on Mac OS X? Did I missed something somewhere? (yes, I have used the set_color_depth function before initializing the set_gfx_mode function)</p><p>Thanks in advance for the help.</p><p>Best regards.</p><p>Fred.</p><p>OK I solved the problem:<br />On Mac OS X the colors are reverted: it is BGR, not RGB. Colors are now applied correctly.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 00:18:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are you composing the 32bit colours yourself with fixed code? If so then you may face compatibility issues - not all Windows machines go RGB and I dare guess that not all OS X machines go BGR. I definitely wouldn&#39;t be surprised if the order of colours within a word varies between Intel and PowerPC for obvious reasons. makecol32 will sort things out for you though...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Fri, 29 Dec 2006 01:48:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What is really surprising is that I have intel Macs. 1 Macbook Pro Core2Duo and a Mac Pro (Xeon x64).</p><p>I should get the same bit order as it is intel based processors.</p><p>I suspect a Mac OS legacy.</p><p>Other people will have the information now <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>Best regards.</p><p>Fred.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 01:52:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I should get the same bit order as it is intel based processors.
</p></div></div><p>
Only if they&#39;re using the same video cards in the same video modes.</p><p>Windows (pre-Vista) makes applications write straight to the framebuffer. OS X keeps a buffer of the current state of each application which, starting with 10.2, is in VRAM (so the graphics card can do window composition).</p><p>So, in Windows, RGB/BGR/whatever ordering is determined by the order used by the framebuffer.</p><p>In OS X, BGR/RGB/whatever ordering is determined by the order OS X selects for its texture format. After that it is purely hardware driven - OS X will not and cannot impose any legacy order if the hardware doesn&#39;t support it.</p><p>Neither OS guarantees either order. Allegro figures out the order at runtime, and provides makecol32 so that you can build your 32bit words correctly.</p><p><b>If you assume a byte order based solely on OS then your program will not work on all hardware.</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Fri, 29 Dec 2006 02:00:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>as I said, I use 15 bits colors from the Game Boy that I transform into 32 bits colors for Allegro platform (Mac OS X and Windows).</p><p>When I apply the 15bits color I use the current code:<br />on Mac OS X:<br />colDest=makecol(getb15(palette[colorIndex]), getg15(palette[colorIndex]), getr15(palette[colorIndex]));</p><p>on Windows:<br />colDest=makecol(getr15(palette[colorIndex]), getg15(palette[colorIndex]), getb15(palette[colorIndex]));</p><p>RGB values are just inverted.<br />The current code gives me the correct colors. But maybe there is a universal way to do so no matter the OS or platform to do something more standard?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 02:11:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If there is a way to detect what order OSX is using then it should be used instead.  In either case I believe this issue has been discussed many times for OSX but I&#39;ve never seen a solution that caused a good working patch to the lib... Maybe someone with better skills on OSX can create a patch for set_gfx_mode that detects the RGB/BGR order and sets things up appropriately.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ron Novy)</author>
		<pubDate>Fri, 29 Dec 2006 02:23:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
colDest=makecol(getb15(palette[colorIndex]), getg15(palette[colorIndex]), getr15(palette[colorIndex]));
</p></div></div><p>

Uh... makecol always takes its arguments in the order R, G, B, regardless of platform.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Fri, 29 Dec 2006 02:25:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
In either case I believe this issue has been discussed many times for OSX but I&#39;ve never seen a solution that caused a good working patch to the lib..
</p></div></div><p>
Eh?</p><p>@OP: Make sure you&#39;re loading/creating your graphics <i>after</i> you call set_gfx_mode. Allegro doesn&#39;t know the RGB ordering until you call set_gfx_mode(). You may get lucky on one system, but it will fail on others.<br />If that doesn&#39;t help, try reproducing the problem with the Allegro examples.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 29 Dec 2006 07:18:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Actually, I think it is because of the coding of the palettes .<br />I use a word to code the colors. They are coded on 15 bits.</p><p>I&#39;m not sure yet it comes from the makecol function, but maybe the coding of a word.</p><p>As I use universal binary compiler, it is maybe the cause. I&#39;ll try tonight with the intel compiler. maybe it&#39;ll give the correct sorted values (RGB, not BGR).</p><p>On Windows either virtual running under Parallels Desktop for Mac or native (standard ISO insall on mac or PC) the compistes are RGB sorted, and only on Mac OS X (tiger 10.4.8 - intel) values are BGR.</p><p>fred.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 13:19:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Actually, I think it is because of the coding of the palettes .<br />I use a word to code the colors. They are coded on 15 bits.
</p></div></div><p>
This makes no sense to me... what do you mean? Can you post some sample code to show what you&#39;re doing?</p><p>Aside, can a moderator move this topic to Programming Questions instead of Allegro Development?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 29 Dec 2006 16:46:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I do the following:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">void</span> ApplyPalette<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> tiles, WORD<span class="k3">*</span> palette, <span class="k1">int</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a>, <span class="k1">int</span> transparency<span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td>  <span class="k1">int</span>        x<span class="k3">=</span><span class="k3">-</span><span class="n">1</span>, y<span class="k3">=</span><span class="k3">-</span><span class="n">1</span>, colSrc<span class="k3">=</span><span class="k3">-</span><span class="n">1</span>, colDest<span class="k3">=</span><span class="k3">-</span><span class="n">1</span>, colorIndex<span class="k3">=</span><span class="k3">-</span><span class="n">1</span><span class="k2">;</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td>  <span class="c">// apply the pallete to the background image</span></td></tr><tr><td class="number">6</td><td>  <span class="k1">for</span> <span class="k2">(</span>y<span class="k3">=</span><span class="n">0</span><span class="k2">;</span> y<span class="k3">&lt;</span>TILE_HEIGHT<span class="k2">;</span> y<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">7</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">8</td><td>    <span class="k1">for</span> <span class="k2">(</span>x<span class="k3">=</span><span class="n">0</span><span class="k2">;</span> x<span class="k3">&lt;</span>TILE_WIDTH<span class="k2">;</span> x<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">9</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">10</td><td>      colSrc<span class="k3">=</span><a href="http://www.allegro.cc/manual/getpixel" target="_blank"><span class="a">getpixel</span></a><span class="k2">(</span>tiles, <span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a><span class="k3">*</span>TILE_WIDTH<span class="k2">)</span><span class="k3">+</span>x, y<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>&#160;</td></tr><tr><td class="number">12</td><td>      <span class="k1">if</span> <span class="k2">(</span>colSrc <span class="k3">=</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>, <span class="n">255</span>, <span class="n">255</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">13</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">14</td><td>        colorIndex<span class="k3">=</span><span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>      <span class="k2">}</span></td></tr><tr><td class="number">16</td><td>      <span class="k1">else</span> <span class="k1">if</span> <span class="k2">(</span>colSrc <span class="k3">=</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">215</span>, <span class="n">215</span>, <span class="n">215</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">17</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">18</td><td>        colorIndex<span class="k3">=</span><span class="n">1</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>      <span class="k2">}</span></td></tr><tr><td class="number">20</td><td>      <span class="k1">else</span> <span class="k1">if</span> <span class="k2">(</span>colSrc <span class="k3">=</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">178</span>, <span class="n">178</span>, <span class="n">178</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">21</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">22</td><td>        colorIndex<span class="k3">=</span><span class="n">2</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td>      <span class="k2">}</span>          </td></tr><tr><td class="number">24</td><td>      <span class="k1">else</span> <span class="k1">if</span> <span class="k2">(</span>colSrc <span class="k3">=</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><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></td></tr><tr><td class="number">25</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">26</td><td>        colorIndex<span class="k3">=</span><span class="n">3</span><span class="k2">;</span></td></tr><tr><td class="number">27</td><td>      <span class="k2">}</span></td></tr><tr><td class="number">28</td><td>      </td></tr><tr><td class="number">29</td><td><span class="p">#ifdef WIN32</span></td></tr><tr><td class="number">30</td><td>      colDest<span class="k3">=</span><a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/getr15" target="_blank"><span class="a">getr15</span></a><span class="k2">(</span>palette<span class="k2">[</span>colorIndex<span class="k2">]</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/getg15" target="_blank"><span class="a">getg15</span></a><span class="k2">(</span>palette<span class="k2">[</span>colorIndex<span class="k2">]</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/getb15" target="_blank"><span class="a">getb15</span></a><span class="k2">(</span>palette<span class="k2">[</span>colorIndex<span class="k2">]</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">31</td><td>&#160;</td></tr><tr><td class="number">32</td><td>      <span class="k1">if</span> <span class="k2">(</span>transparency <span class="k3">!</span><span class="k3">=</span> <span class="k3">-</span><span class="n">1</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> colDest <span class="k3">=</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/getr15" target="_blank"><span class="a">getr15</span></a><span class="k2">(</span>palette<span class="k2">[</span>transparency<span class="k2">]</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/getg15" target="_blank"><span class="a">getg15</span></a><span class="k2">(</span>palette<span class="k2">[</span>transparency<span class="k2">]</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/getb15" target="_blank"><span class="a">getb15</span></a><span class="k2">(</span>palette<span class="k2">[</span>transparency<span class="k2">]</span><span class="k2">)</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">33</td><td><span class="p">#else</span></td></tr><tr><td class="number">34</td><td>      colDest<span class="k3">=</span><a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/getb15" target="_blank"><span class="a">getb15</span></a><span class="k2">(</span>palette<span class="k2">[</span>colorIndex<span class="k2">]</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/getg15" target="_blank"><span class="a">getg15</span></a><span class="k2">(</span>palette<span class="k2">[</span>colorIndex<span class="k2">]</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/getr15" target="_blank"><span class="a">getr15</span></a><span class="k2">(</span>palette<span class="k2">[</span>colorIndex<span class="k2">]</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">35</td><td>&#160;</td></tr><tr><td class="number">36</td><td>      <span class="k1">if</span> <span class="k2">(</span>transparency <span class="k3">!</span><span class="k3">=</span> <span class="k3">-</span><span class="n">1</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> colDest <span class="k3">=</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/getb15" target="_blank"><span class="a">getb15</span></a><span class="k2">(</span>palette<span class="k2">[</span>transparency<span class="k2">]</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/getg15" target="_blank"><span class="a">getg15</span></a><span class="k2">(</span>palette<span class="k2">[</span>transparency<span class="k2">]</span><span class="k2">)</span>, <a href="http://www.allegro.cc/manual/getr15" target="_blank"><span class="a">getr15</span></a><span class="k2">(</span>palette<span class="k2">[</span>transparency<span class="k2">]</span><span class="k2">)</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">37</td><td><span class="p">#endif  // WIN32</span></td></tr><tr><td class="number">38</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">39</td><td>        colDest<span class="k3">=</span><a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">255</span>, <span class="n">0</span>, <span class="n">255</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">40</td><td>      <span class="k2">}</span></td></tr><tr><td class="number">41</td><td>      </td></tr><tr><td class="number">42</td><td>      <a href="http://www.allegro.cc/manual/putpixel" target="_blank"><span class="a">putpixel</span></a><span class="k2">(</span>tiles, <span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a><span class="k3">*</span>TILE_WIDTH<span class="k2">)</span><span class="k3">+</span>x, y, colDest<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">43</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">44</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">45</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>
I call the function that way:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">void</span> LoadAnimatedTiles<span class="k2">(</span>PENVIRONMENTDESC pEnvironment<span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td>  <span class="k1">int</span>          i<span class="k3">=</span><span class="k3">-</span><span class="n">1</span><span class="k2">;</span></td></tr><tr><td class="number">4</td><td>  WORD        palette<span class="k2">[</span><span class="n">4</span><span class="k2">]</span><span class="k2">[</span><span class="n">4</span><span class="k2">]</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td>  palette<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x0060</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td>  palette<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x0100</span><span class="k2">;</span></td></tr><tr><td class="number">8</td><td>  palette<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x01e0</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>  palette<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x0ee3</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>  </td></tr><tr><td class="number">11</td><td>  palette<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x00e0</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>  palette<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x0136</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>  palette<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x008f</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>  palette<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x0008</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>&#160;</td></tr><tr><td class="number">16</td><td>  palette<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x5400</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>  palette<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x58c2</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>  palette<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x7249</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>  palette<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x7f8e</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>&#160;</td></tr><tr><td class="number">21</td><td>  palette<span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x00a0</span><span class="k2">;</span></td></tr><tr><td class="number">22</td><td>  palette<span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x02bf</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td>  palette<span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x001f</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td>  palette<span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k3">=</span><span class="n">0x7f20</span><span class="k2">;</span></td></tr><tr><td class="number">25</td><td>&#160;</td></tr><tr><td class="number">26</td><td>  <span class="k1">switch</span> <span class="k2">(</span>pEnvironment-&gt;pLevel-&gt;world<span class="k2">)</span></td></tr><tr><td class="number">27</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">28</td><td>  <span class="k1">case</span> WORLD_FOREST_FALLS:</td></tr><tr><td class="number">29</td><td>    pEnvironment-&gt;foregroundTiles<span class="k3">=</span><a href="http://www.allegro.cc/manual/load_bitmap" target="_blank"><span class="a">load_bitmap</span></a><span class="k2">(</span><span class="s">"ffts.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">30</td><td>    </td></tr><tr><td class="number">31</td><td>    <span class="k1">for</span> <span class="k2">(</span>i<span class="k3">=</span><span class="n">0</span><span class="k2">;</span> i<span class="k3">&lt;</span><span class="n">8</span><span class="k2">;</span> i<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">32</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">33</td><td>      ApplyPalette<span class="k2">(</span>pEnvironment-&gt;foregroundTiles, palette<span class="k2">[</span><span class="n">1</span><span class="k2">]</span>, i, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">34</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">35</td><td>...</td></tr></tbody></table></div></div><p>

I&#39;m obliged to reverse the color to have the correct display on Windows and Mac OS.</p><p>Fred.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 16:52:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Right.<br />As said, this has nothing to do with Windows or MacOS X. The problem is that you hard-code the colour numbers in 16 bits, with a specific RGB ordering (say RGB). Allegro will use the system&#39;s native colour ordering, which may be RGB or BGR (or something else entirely). If you&#39;re lucky, the ordering you used to encode your colour constants and the one used by the system are the same. If not, you&#39;ll end upwith the wrong colours, as you have seen.</p><p>Solution: extract the components from your encoded numbers manually (it only takes a shift and a logical and), or store them as RGB triplets.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 29 Dec 2006 17:01:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>you mean that I should not use the getr15 getg15 and getb15 functions and I have to rewrite them???
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 17:07:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I meant what I wrote.<br />Phrased differently, no, you should not be using get[r,g,b]15 on the colour values you hard-coded <i>because you can&#39;t predict the order of RGB components on any system</i>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 29 Dec 2006 17:21:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Damned, these functions are so convinient.<br />How can I replace them?<br />I&#39;m a dumb with manipulating bits in C <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 17:22:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t know the GBA colour encoding, but if it&#39;s 15 bit then something like:</p><div class="source-code snippet"><div class="inner"><pre>... somewhere in your source before you use them ...
<span class="p">#define gba_getb(v) (v&amp;31)</span>
<span class="p">#define gba_getg(v) ((v &gt;&gt; 5)&amp;31)</span>
<span class="p">#define gba_getr(v) (v &gt;&gt; 10)</span>

... to use them ...
r <span class="k3">=</span> gba_getr<span class="k2">(</span>col<span class="k2">)</span><span class="k2">;</span>
g <span class="k3">=</span> gba_getg<span class="k2">(</span>col<span class="k2">)</span><span class="k2">;</span>
b <span class="k3">=</span> gba_getb<span class="k2">(</span>col<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Though I may have r, g and b the wrong way round. &quot;&amp;31&quot; effectively says &quot;throw away all but the lowest five bits&quot; and &quot;&gt;&gt; 5&quot; says &quot;move all the bits 5 positions to the right, throw away any that cross the decimal point&quot;.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Fri, 29 Dec 2006 17:36:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>the macros does not seem to work properly: all is almost black</p><p>GB&#39;s colors work like this:<br />  R     G     B<br />0 11111 00000 00000<br />15---------------&gt;0</p><p>As it is 5 bits per color, the MSB is ignored.</p><p>The goal is to transform 15 bits colors into 32 bits colors using the hardcoded palettes I shown.</p><p>As shown, the values of the palettes values are coded as a word (unsigned short) which is 16 bits wide.</p><p>I don&#39;t really know how to do that while Allegro does it I use the getr15, getg15 and getb15 functions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 18:58:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Harte&#39;s macros will do exactly that. <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Fri, 29 Dec 2006 19:18:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The colour values you get out are in the range 0-31, while Allegro&#39;s makcol function takes values in the range 0-255, so you&#39;ll need to scale them (by a factor 8 or so, though using 255./31. would give you a better result).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 29 Dec 2006 19:21:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>indeed, I get better results by multiply the composites by 8.<br />also, I have to use the makecol24 function instead of makecol and things seems to be ok on Windows.</p><p>I&#39;ll tell you tonight how it is on the Macintosh. If I understood well, normally, with this method, it should get the same display results no mater the platform and OS. right?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 19:36:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
also, I have to use the makecol24 function instead of makecol and things seems to be ok on Windows.
</p></div></div><p>

What? Why? Where are you calling it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Fri, 29 Dec 2006 20:15:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I call makecol24 after the extraction of the 15bits RGB values before applying the color to the pixel. Why?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Fri, 29 Dec 2006 20:18:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Because there&#39;s no reason makecol() should fail unless you&#39;re trying to use it before calling allegro_init() and set_gfx_mode() (Assuming you still have to do that).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Fri, 29 Dec 2006 20:26:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Any way, I have just tried on Mac OS X what we did today on Windows that is manully extracting the RGB composites and convert them manually to 32 bits colors.</p><p>While it is working on Windows, again, colors are still reverted on Mac OS.<br />I have tried on my Mac Pro with an nVidia video card and on my MacBook Pro with an ATI video card. Both give the same results on Mac OS X: colors are BGR, even when it is handly recoded.</p><p>That&#39;s really odd!!!</p><p>My goal is to have a unique source code based on allegro, no matter the OS it will run on.</p><p>For better results, I wish to keep the hard coded 15 bits colors in palettes that I apply to the tile sets when loading them.</p><p>I have supplied the ApplyPalette function to see how I apply the colors.</p><p>If you have any idea to solve this reversion problem, let me know, I&#39;m opened to any idea.</p><p>I&#39;m stucked!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Sat, 30 Dec 2006 01:16:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Post a <i>small</i> example program that reproduces the error. Not a section of code, but something we can compile and run.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 30 Dec 2006 01:33:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok,</p><p>I&#39;ll do a sample project that will run on both Mac OS X (via XCode) and Windows (via VS2005) tomorrow morning and post it as soon as possible.</p><p>Of course, to reflect the error, poeple will need a mac intel.</p><p>Maybe there is a problem in Allegro in  detecting little endian and big endian on Mac OS X. It happens only on this system.</p><p>Best regards.</p><p>Fred
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Sat, 30 Dec 2006 01:54:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nevermind, try the following program:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="p">#include &lt;allegro.h&gt;</span></td></tr><tr><td class="number">2</td><td>&#160;</td></tr><tr><td class="number">3</td><td><span class="c">/* Change this for testing */</span></td></tr><tr><td class="number">4</td><td><span class="k1">static</span> <span class="k1">int</span> rgb_colour_15 <span class="k3">=</span> <span class="n">0x7FFF</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td><span class="p">#define gba_getb(v) (v&amp;31)</span></td></tr><tr><td class="number">7</td><td><span class="p">#define gba_getg(v) ((v &gt;&gt; 5)&amp;31)</span></td></tr><tr><td class="number">8</td><td><span class="p">#define gba_getr(v) (v &gt;&gt; 10)</span></td></tr><tr><td class="number">9</td><td>&#160;</td></tr><tr><td class="number">10</td><td><span class="k1">int</span> main<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span></td></tr><tr><td class="number">11</td><td><span class="k2">{</span></td></tr><tr><td class="number">12</td><td>   <span class="k1">int</span> r, g, b<span class="k2">;</span></td></tr><tr><td class="number">13</td><td>&#160;</td></tr><tr><td class="number">14</td><td>   <a href="http://www.allegro.cc/manual/allegro_init" target="_blank"><span class="a">allegro_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>   <a href="http://www.allegro.cc/manual/install_keyboard" target="_blank"><span class="a">install_keyboard</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">16</td><td>   </td></tr><tr><td class="number">17</td><td>   <a href="http://www.allegro.cc/manual/set_color_depth" target="_blank"><span class="a">set_color_depth</span></a><span class="k2">(</span><span class="n">32</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>   <a href="http://www.allegro.cc/manual/set_gfx_mode" target="_blank"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>GFX_AUTODETECT, <span class="n">640</span>, <span class="n">480</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>   </td></tr><tr><td class="number">20</td><td>   r <span class="k3">=</span> gba_getr<span class="k2">(</span>rgb_colour_15<span class="k2">)</span> <span class="k3">*</span> <span class="n">255</span>.<span class="k3">/</span><span class="n">31</span>.<span class="k2">;</span></td></tr><tr><td class="number">21</td><td>   g <span class="k3">=</span> gba_getg<span class="k2">(</span>rgb_colour_15<span class="k2">)</span> <span class="k3">*</span> <span class="n">255</span>.<span class="k3">/</span><span class="n">31</span>.<span class="k2">;</span></td></tr><tr><td class="number">22</td><td>   b <span class="k3">=</span> gba_getb<span class="k2">(</span>rgb_colour_15<span class="k2">)</span> <span class="k3">*</span> <span class="n">255</span>.<span class="k3">/</span><span class="n">31</span>.<span class="k2">;</span></td></tr><tr><td class="number">23</td><td>   </td></tr><tr><td class="number">24</td><td>   <a href="http://www.allegro.cc/manual/rectfill" target="_blank"><span class="a">rectfill</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <span class="n">0</span>, <span class="n">0</span>, <a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a><span class="k3">/</span><span class="n">3</span>, SCREEN_H-1, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span>r, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>   </td></tr><tr><td class="number">25</td><td>   <a href="http://www.allegro.cc/manual/rectfill" target="_blank"><span class="a">rectfill</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a><span class="k3">/</span><span class="n">3</span>, <span class="n">0</span>, <span class="n">2</span><span class="k3">*</span><a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a><span class="k3">/</span><span class="n">3</span>, SCREEN_H-1, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">0</span>, g, <span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>   </td></tr><tr><td class="number">26</td><td>   <a href="http://www.allegro.cc/manual/rectfill" target="_blank"><span class="a">rectfill</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <span class="n">2</span><span class="k3">*</span><a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a><span class="k3">/</span><span class="n">3</span>, <span class="n">0</span>, SCREEN_W-1, SCREEN_H-1, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span><span class="n">0</span>, <span class="n">0</span>, b<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>   </td></tr><tr><td class="number">27</td><td>&#160;</td></tr><tr><td class="number">28</td><td>   <a href="http://www.allegro.cc/manual/rectfill" target="_blank"><span class="a">rectfill</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a><span class="k3">/</span><span class="n">6</span>, <a href="http://www.allegro.cc/manual/SCREEN_H" target="_blank"><span class="a">SCREEN_H</span></a><span class="k3">/</span><span class="n">3</span>, <span class="n">5</span><span class="k3">*</span><a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a><span class="k3">/</span><span class="n">6</span>, <span class="n">4</span><span class="k3">*</span><a href="http://www.allegro.cc/manual/SCREEN_H" target="_blank"><span class="a">SCREEN_H</span></a><span class="k3">/</span><span class="n">6</span>, <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a><span class="k2">(</span>r, g, b<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>   </td></tr><tr><td class="number">29</td><td>&#160;</td></tr><tr><td class="number">30</td><td>   <a href="http://www.allegro.cc/manual/readkey" target="_blank"><span class="a">readkey</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">31</td><td>&#160;</td></tr><tr><td class="number">32</td><td><span class="k2">}</span></td></tr><tr><td class="number">33</td><td><a href="http://www.allegro.cc/manual/END_OF_MAIN" target="_blank"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span></td></tr></tbody></table></div></div><p>
If that gives you the proper output on both systems (you&#39;ll need to change the number at the top) the problem is elsewhere.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 30 Dec 2006 02:33:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><p>I have the correct values:<br />Red Green Blue verticals rectangles and a white horizontal rectangle.</p><p>I have seen this:<br /><a href="https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/105/wo/m11Ev3fANuyw2NsPxNy1jFYVzsr/0.0.17.2.1.1.3.1.1.2.1.1.0">https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/105/wo/m11Ev3fANuyw2NsPxNy1jFYVzsr/0.0.17.2.1.1.3.1.1.2.1.1.0</a></p><p>where it says that values must be encoded in big endian when running on Mac OS no matter it is intel or ppc processors.</p><p>My project maybe gives a perfect illustration of the big endian/little endian.<br />While windows is little endian, Mac OS is big endian. That&#39;s maybe why compisites are reverted.</p><p>But... But... but...<br />Your sample code show me the exact opposit way: composites are correctly sorted!!! Thus even if I select a UB compilation.<br />I&#39;m stucked <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Sat, 30 Dec 2006 19:53:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Bit operations on integers do not depend on endianess, so the same code should work on each platform.<br />If the above code works and yours does not, you need to check what you do differently.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 30 Dec 2006 20:01:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>After deeper tests, I have tested with the 15 bits color 0x7249 which is an aquarel blue.</p><p>I have used the RGB coding and I get an aquarel orange.<br />When I reverse to BGR, I get the aquarel blue.</p><p>It&#39;s maybe due to the Big Endian encoding of Mac OS X.<br />While I have taken the 15bits values from Windows which is little endian encoded, when I use them on Mac OS X, it reverses the composites. That&#39;s the only explanation I have.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Sat, 30 Dec 2006 20:04:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t understand what you mean.<br />If your numbers store the colour values as BGR instead of RGB, you will need to swap the gba_getb and gba_getr macro&#39;s, but that <i>isn&#39;t</i> and endianesse issue.<br />If you have the hex number 0xfeef, the high (as in most significant) byte holds the value 0xfe, the low (as in least significant) byte holds 0xef. This is true independent of endianesse. Which of these is stored first in memory (at the lowest memory adress) is, but you don&#39;t need to care about that in this case.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
While I have taken the 15bits values from Windows which is little endian encoded, when I use them on Mac OS X, it reverses the composites.
</p></div></div><p>
I don&#39;t understand. What do you mean?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
That&#39;s the only explanation I have.
</p></div></div><p>
You lost me. Are you seeing a problem with my example program, or yours? How are you reading in the colour components? Are they hard-coded, or do you read them from disk?</p><p>EDIT: for the record, the code I posted produces identical results on my PC (running Linux) and my laptop (a G4 iBook).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 30 Dec 2006 20:18:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I see a problem with your sample too: use the color I told you (0x7249)<br />if you run your sample under windows, you&#39;ll get a blue color.<br />if you run your sample under mac os x, you&#39;ll get a orange color.</p><p>I have read the color values on a game boy emulator that runs under windows.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (boulifb)</author>
		<pubDate>Sat, 30 Dec 2006 20:26:06 +0000</pubDate>
	</item>
</rss>
