<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>masked_blit(); problem</title>
		<link>http://www.allegro.cc/forums/view/590041</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 19 Feb 2007 10:32:16 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve been trying to get masked_blit to work and having problem as shown in the screenshots. </p><p><span class="remote-thumbnail"><span class="json">{"name":"591204","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/9\/79cfdd4324691597e95b7cb2e6b14fec.jpg","w":646,"h":512,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/9\/79cfdd4324691597e95b7cb2e6b14fec"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/7/9/79cfdd4324691597e95b7cb2e6b14fec-240.jpg" alt="591204" width="240" height="190" /></span><br /><span class="remote-thumbnail"><span class="json">{"name":"591205","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/5\/05980b83476c03fb74aebbd6bf06fe99.jpg","w":646,"h":512,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/5\/05980b83476c03fb74aebbd6bf06fe99"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/0/5/05980b83476c03fb74aebbd6bf06fe99-240.jpg" alt="591205" width="240" height="190" /></span></p><p>The 1st image is all blit(...);<br />The 2nd image is using masked_blit(...); and blit(...) for the background image which shows up clear. Does anyone have an suggestions on how to get this to work?</p><p>My transparent color is (255, 0, 255).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Tue, 13 Feb 2007 10:16:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Uh, I&#39;m not sure whats going on. What color depth are the pictures? What color depth are you setting when you start allegro( set_color_depth )? Are you loading the pictures before you call set_gfx_mode ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Tue, 13 Feb 2007 10:17:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>set_color_depth(32);</p><p>And I am setting it before I call </p><p>int ret = set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);</p><p>And I load the graphics after this setup. In fact the icons that are loading are the same for those using blut() and those using masked_blit()
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Tue, 13 Feb 2007 10:40:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Can you attach the original sprites themselves? What version of Allegro are you using?</p><p>Can you paste the exact code you used when you call blit and masked_blit?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Tue, 13 Feb 2007 10:45:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve attached the 24bit tank.bmp icon created in MS Paint. </p><p>As for my blit / masked_blit code..(buffer is my backbuffer which writes to the screen, same buffer that is used for blit(), which works fine.)</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> drawPlayer<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">if</span><span class="k2">(</span>Player.alive<span class="k2">)</span>
  <span class="k2">{</span>
    <span class="k1">int</span> x <span class="k3">=</span> Player.x<span class="k2">;</span>
    <span class="k1">int</span> y <span class="k3">=</span> Player.y<span class="k2">;</span>
    <span class="k1">if</span><span class="k2">(</span>MASKED<span class="k2">)</span>
      <a href="http://www.allegro.cc/manual/masked_blit" target="_blank"><span class="a">masked_blit</span></a><span class="k2">(</span>player_bmp, buffer, <span class="n">0</span>, <span class="n">0</span>, x, y, PLAYER_SIZE, PLAYER_SIZE<span class="k2">)</span><span class="k2">;</span>
    <span class="k1">else</span>
            <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>player_bmp, buffer, <span class="n">0</span>, <span class="n">0</span>, x, y, PLAYER_SIZE, PLAYER_SIZE<span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

<b>EDIT: I&#39;m using Allegro 4.2</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Tue, 13 Feb 2007 11:30:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You have (255, 0, 128)rgb on that tank bitmap. Also for masked_blit to work, the source and the target bitmap have to have the same color depth, though if you load the bitmap after setting the gfx mode it should be automatically converted to the set color depth. If it still doesn&#39;t work after changing the (not quite)bright pink to (255, 0, 255)rgb, try saving your sprites in 32bpp.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dennis)</author>
		<pubDate>Tue, 13 Feb 2007 11:49:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The loaded images have a different color depth than the buffer. Make sure you load/create them all after setting the gfx mode (which you do after setting the color depth).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Tue, 13 Feb 2007 13:04:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Whys your project called Week 5?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Tue, 13 Feb 2007 13:22:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The only image that didn&#39;t have a 255, 0, 255 background was the one I picked to post here. Glad I found that error. I changed the background for the tank image to 255, 0, 255 and still no go. I also have a background that loads when Masking is turned on. It appears something is forcing my color depth to go 256-pal mode from the look of the background. Also to note, each image is loaded from a 24-bit BMP that is not animated. Is it still required to use create the images after loading? If so, how would I create a static image from one that is been loaded and to ensure the 24 - 36 bit colors are retained?</p><p>I call it Week 5, because I&#39;m making a game a week in class. This project has already been completed and turned in. But, I need to clear up my masking problem for future projects, which will heavily depend upon masked sprites.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Wed, 14 Feb 2007 01:47:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Post the smallest code sample the duplicates the problem and we&#39;ll tell you what&#39;s wrong with it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 14 Feb 2007 02:15:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Here is my game setup function. </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> setupGame<span class="k2">(</span><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="c">// set video mode</span></td></tr><tr><td class="number">4</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">24</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td>  <span class="c">// init video mode to 640x480</span></td></tr><tr><td class="number">6</td><td>  <span class="k1">int</span> ret <span class="k3">=</span> <a href="http://www.allegro.cc/manual/set_gfx_mode" target="_blank"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>MODE, WIDTH, HEIGHT, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td>  <span class="k1">if</span><span class="k2">(</span>ret <span class="k3">!</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">8</td><td>    <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/allegro_error" target="_blank"><span class="a">allegro_error</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>    <span class="k1">return</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">11</td><td>  <span class="c">// install a digital sound driver</span></td></tr><tr><td class="number">12</td><td>  <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/install_sound" target="_blank"><span class="a">install_sound</span></a><span class="k2">(</span>DIGI_AUTODETECT, MIDI_NONE, <span class="s">""</span><span class="k2">)</span> <span class="k3">!</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">13</td><td>    <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"Error initializing sound system"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>    <span class="k1">return</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>&#160;</td></tr><tr><td class="number">17</td><td>  <span class="c">// load background</span></td></tr><tr><td class="number">18</td><td>  <span class="k1">if</span><span class="k2">(</span>MASKED<span class="k2">)</span></td></tr><tr><td class="number">19</td><td>        background_bmp <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">"gfx/background.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>&#160;</td></tr><tr><td class="number">21</td><td>  <span class="c">// load sounds</span></td></tr><tr><td class="number">22</td><td>  tank_snd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_sample" target="_blank"><span class="a">load_sample</span></a><span class="k2">(</span><span class="s">"sound/tank.wav"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td>  invader_snd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_sample" target="_blank"><span class="a">load_sample</span></a><span class="k2">(</span><span class="s">"sound/invader.wav"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td>  rocket_snd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_sample" target="_blank"><span class="a">load_sample</span></a><span class="k2">(</span><span class="s">"sound/rocket.wav"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">25</td><td>  ufo_snd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_sample" target="_blank"><span class="a">load_sample</span></a><span class="k2">(</span><span class="s">"sound/ufo.wav"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">26</td><td>  gameover_snd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_sample" target="_blank"><span class="a">load_sample</span></a><span class="k2">(</span><span class="s">"sound/gameover.wav"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">27</td><td>  invadersMove_snd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_sample" target="_blank"><span class="a">load_sample</span></a><span class="k2">(</span><span class="s">"sound/invadersMove.wav"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">28</td><td>&#160;</td></tr><tr><td class="number">29</td><td>  <span class="c">// Grab High score</span></td></tr><tr><td class="number">30</td><td>  ifstream file<span class="k2">(</span><span class="s">"highscore.dat"</span>, ios_base::binary<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">31</td><td>  <span class="k1">if</span><span class="k2">(</span>file.is_open<span class="k2">(</span><span class="k2">)</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>    file <span class="k3">&gt;</span><span class="k3">&gt;</span> highscore<span class="k2">;</span></td></tr><tr><td class="number">34</td><td>    file.close<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">35</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">36</td><td>  <span class="k1">else</span></td></tr><tr><td class="number">37</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">38</td><td>    ofstream outfile<span class="k2">(</span><span class="s">"highscore.dat"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">39</td><td>    outfile <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="k2">(</span><span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">40</td><td>    highscore <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">41</td><td>    outfile.close<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">42</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">43</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

This is how I&#39;m loading the player bitmap</p><div class="source-code snippet"><div class="inner"><pre>  player_bmp <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">"gfx/tank.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

And this is the code that draws the player to the screen</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> drawPlayer<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">if</span><span class="k2">(</span>Player.alive<span class="k2">)</span>
  <span class="k2">{</span>
    <span class="k1">int</span> x <span class="k3">=</span> Player.x<span class="k2">;</span>
    <span class="k1">int</span> y <span class="k3">=</span> Player.y<span class="k2">;</span>
    <span class="k1">if</span><span class="k2">(</span>MASKED<span class="k2">)</span>
      <a href="http://www.allegro.cc/manual/masked_blit" target="_blank"><span class="a">masked_blit</span></a><span class="k2">(</span>player_bmp, buffer, <span class="n">0</span>, <span class="n">0</span>, x, y, PLAYER_SIZE, PLAYER_SIZE<span class="k2">)</span><span class="k2">;</span>
    <span class="k1">else</span>
            <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>player_bmp, buffer, <span class="n">0</span>, <span class="n">0</span>, x, y, PLAYER_SIZE, PLAYER_SIZE<span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

Keep in mind that the MASKED is a #define that makes it easier to turn masking on/off.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Wed, 14 Feb 2007 02:34:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That isn&#39;t the smallest code sample.<br />Let me rephrase my request. Post the smallest example program (<i>ie</i>, code that compiles on its own) along with the graphics that reproduces the problem.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 14 Feb 2007 02:44:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When you boot up your graphics mode, add a textout or textprintf line to show you the results of a get_color_depth() call. It sounds to me that your computer doesn&#39;t like 24-Bit or 32-Bit graphics modes. (Which can sometimes be caused by incorrect video or monitor drivers.)</p><p>In 8-bit mode, the background colour needs to be palette entry 0, which would be one way to explain why the magic pink isn&#39;t disappearing.</p><p>Also, if it isn&#39;t liking 24-Bit or 32-Bit colour, try running the program in a window and you may have better luck.</p><p><b>EDIT:</b> Oh wait... you are, aren&#39;t you? Maybe you should try full-screen then...</p><p><b>EDIT:</b> Waitaminute... I think I recognize this problem. I believe masked_blit() requires that the bitmaps and the screen be the same colour depth... the images look as though you&#39;re trying to blit 32-Bit data onto an 8 or 16-bit surface. Is your desktop colour depth set to 8 or 16-Bit?</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Wed, 14 Feb 2007 22:54:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve ensured all graphics I&#39;m using are set to 24bit RGB color mode. The effects on the star background are not there originally as it should be blended better as a 24bit color image. This caused me to think even though I&#39;m setting the color mode its not taking it. </p><p>I&#39;ve tested the binary on 2 other computers and all of them come up with the same 2nd image when I use masked_blit();</p><p>I&#39;ll give you textout idea a try and see what I get. </p><p><b>I just added the textout and it comes back as 24 mode, however, still getting the same issue. 24bit mode is also what I&#39;m setting it at.

In addition, I noticed from reading around that there may be a problem with using backbuffer with masked_blit. Has anyone else heard of this issue?
</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Thu, 15 Feb 2007 07:50:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Does draw_sprite() do the same thing as masked_blit() when you use it instead? (The two functions are almost identical in functionality.)</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Fri, 16 Feb 2007 11:02:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nope. draw_sprite doesn&#39;t do any magical conversions of the source bitmap.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Fri, 16 Feb 2007 11:12:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>As an update, I was testing out various things and decided to set it to 8-bit 256-pal mode. I also took the non-animated sprite and converted it to an 8bit image with 0 for the masking. Surprisingly, the masking worked fine, however, the image itself was still distorted. </p><p>Someone suggested I try to set color to 32bit and use TGA instead of BMP. I&#39;m going to give this a try later tonight. </p><p>Just wanted to mention the 8bit test in case this clues anyone in to what my problem may be. It really seems like something is force me into 8bit PAL mode, but I have set everything to 24bit / 32bit and pass NULL for the PAL info.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Fri, 16 Feb 2007 11:59:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How&#39;s that small test program coming along that we can run to duplicate the problem?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 16 Feb 2007 12:21:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok Mr. Evert,</p><p>I&#39;ve gotten around to making a Test program and got it working, but the masking is not. <br /><span class="remote-thumbnail"><span class="json">{"name":"591228","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/7\/a71b1e85f28e77601db624ee5a17ea47.jpg","w":641,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/7\/a71b1e85f28e77601db624ee5a17ea47"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/a/7/a71b1e85f28e77601db624ee5a17ea47-240.jpg" alt="591228" width="240" height="179" /></span></p><p>As you can see, the problem is still there. It should be the tank icon over a green field. Everything is grey. </p><p><span class="remote-thumbnail"><span class="json">{"name":"591229","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/7\/676c9e9f40766c305cc403d79f7c0f5e.png","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/7\/676c9e9f40766c305cc403d79f7c0f5e"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/6/7/676c9e9f40766c305cc403d79f7c0f5e-240.jpg" alt="591229" width="240" height="180" /></span> <a href="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/c/7/c7fac7b218e9a04c5e1f1ae0adb51bf5.bmp">591230</a></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="c">// main.cpp</span></td></tr><tr><td class="number">2</td><td><span class="c">// Test project to determine why Masking is not working</span></td></tr><tr><td class="number">3</td><td><span class="c">// for my images.</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td><span class="p">#include "allegro.h"</span></td></tr><tr><td class="number">6</td><td>&#160;</td></tr><tr><td class="number">7</td><td><span class="p">#define MODE GFX_AUTODETECT_WINDOWED</span></td></tr><tr><td class="number">8</td><td><span class="p">#define WIDTH 640</span></td></tr><tr><td class="number">9</td><td><span class="p">#define HEIGHT 480</span></td></tr><tr><td class="number">10</td><td><span class="p">#define PLAYER_SIZE 32</span></td></tr><tr><td class="number">11</td><td><span class="p">#define BLACK makecol(0,0,0)</span></td></tr><tr><td class="number">12</td><td><span class="p">#define BACKGROUND "gfx/background.bmp"</span></td></tr><tr><td class="number">13</td><td><span class="p">#define TANK "gfx/tank.bmp"</span></td></tr><tr><td class="number">14</td><td>&#160;</td></tr><tr><td class="number">15</td><td><span class="c">// BackBuffer</span></td></tr><tr><td class="number">16</td><td><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>buffer<span class="k2">;</span></td></tr><tr><td class="number">17</td><td>&#160;</td></tr><tr><td class="number">18</td><td><span class="c">// Sprite Maps</span></td></tr><tr><td class="number">19</td><td><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>background_bmp<span class="k2">;</span></td></tr><tr><td class="number">20</td><td><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>player_bmp<span class="k2">;</span></td></tr><tr><td class="number">21</td><td>&#160;</td></tr><tr><td class="number">22</td><td><span class="k1">void</span> setupGame<span class="k2">(</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="c">// set video mode</span></td></tr><tr><td class="number">25</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">26</td><td>  <span class="c">// init video mode to 640x480</span></td></tr><tr><td class="number">27</td><td>  <span class="k1">int</span> ret <span class="k3">=</span> <a href="http://www.allegro.cc/manual/set_gfx_mode" target="_blank"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>MODE, WIDTH, HEIGHT, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">28</td><td>  <span class="k1">if</span><span class="k2">(</span>ret <span class="k3">!</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">29</td><td>    <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/allegro_error" target="_blank"><span class="a">allegro_error</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">30</td><td>    <span class="k1">return</span><span class="k2">;</span></td></tr><tr><td class="number">31</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">32</td><td>  <span class="c">// load background</span></td></tr><tr><td class="number">33</td><td>  background_bmp <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>BACKGROUND, NULL<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><span class="k1">void</span> setupPlayer<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">36</td><td><span class="k2">{</span></td></tr><tr><td class="number">37</td><td>  player_bmp <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>TANK, NULL<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">38</td><td><span class="k2">}</span></td></tr><tr><td class="number">39</td><td><span class="k1">void</span> drawPlayer<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>  <a href="http://www.allegro.cc/manual/masked_blit" target="_blank"><span class="a">masked_blit</span></a><span class="k2">(</span>player_bmp, buffer, <span class="n">0</span>, <span class="n">0</span>, <span class="n">320</span>, <span class="n">240</span>, PLAYER_SIZE, PLAYER_SIZE<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">42</td><td><span class="k2">}</span></td></tr><tr><td class="number">43</td><td><span class="k1">void</span> clearScreen<span class="k2">(</span><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>  <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>background_bmp, buffer, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, WIDTH <span class="k3">-</span> <span class="n">1</span>, HEIGHT <span class="k3">-</span> <span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">46</td><td><span class="k2">}</span></td></tr><tr><td class="number">47</td><td><span class="k1">void</span> cleanUp<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">48</td><td><span class="k2">{</span></td></tr><tr><td class="number">49</td><td>  <span class="k1">void</span> <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>background_bmp<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">50</td><td>  <span class="k1">void</span> <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>player_bmp<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">51</td><td>  <span class="k1">void</span> <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>buffer<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">52</td><td><span class="k2">}</span></td></tr><tr><td class="number">53</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">54</td><td><span class="k2">{</span></td></tr><tr><td class="number">55</td><td>  <span class="c">// init Allegro</span></td></tr><tr><td class="number">56</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">57</td><td>  <span class="c">// init keyboard</span></td></tr><tr><td class="number">58</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">59</td><td>  buffer <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_bitmap" target="_blank"><span class="a">create_bitmap</span></a><span class="k2">(</span>WIDTH <span class="k3">-</span> <span class="n">1</span>, HEIGHT <span class="k3">-</span> <span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">60</td><td>  <span class="c">// game setup</span></td></tr><tr><td class="number">61</td><td>  setupGame<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">62</td><td>  setupPlayer<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">63</td><td>  </td></tr><tr><td class="number">64</td><td>  <span class="c">// game loop</span></td></tr><tr><td class="number">65</td><td>  <span class="k1">while</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_ESC<span class="k2">]</span><span class="k2">)</span></td></tr><tr><td class="number">66</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">67</td><td>    <span class="c">// clear screen / update text</span></td></tr><tr><td class="number">68</td><td>    clearScreen<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">69</td><td>    drawPlayer<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">70</td><td>    <span class="c">// update screen</span></td></tr><tr><td class="number">71</td><td>    <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>buffer, <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>,<span class="n">0</span>,<span class="n">0</span>,WIDTH <span class="k3">-</span> <span class="n">1</span>,HEIGHT <span class="k3">-</span> <span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">72</td><td>&#160;</td></tr><tr><td class="number">73</td><td>    <a href="http://www.allegro.cc/manual/rest" target="_blank"><span class="a">rest</span></a><span class="k2">(</span><span class="n">5</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">74</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">75</td><td>  <span class="c">// end program</span></td></tr><tr><td class="number">76</td><td>  cleanUp<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">77</td><td>  <a href="http://www.allegro.cc/manual/allegro_exit" target="_blank"><span class="a">allegro_exit</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">78</td><td>  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">79</td><td><span class="k2">}</span></td></tr><tr><td class="number">80</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>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Sat, 17 Feb 2007 14:42:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
</p><div class="source-code snippet"><div class="inner"><pre>buffer <span class="k3">=</span> <a href="http://www.allegro.cc/manual/create_bitmap" target="_blank"><span class="a">create_bitmap</span></a><span class="k2">(</span>WIDTH <span class="k3">-</span> <span class="n">1</span>, HEIGHT <span class="k3">-</span> <span class="n">1</span><span class="k2">)</span><span class="k2">;</span>
<span class="c">// game setup</span>
setupGame<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div></div><p>
</p><div class="quote_container"><div class="title">I said:</div><div class="quote"><p>
Make sure you load/create them all <b>after setting the gfx mode</b>
</p></div></div><p>
<img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Sat, 17 Feb 2007 15:08:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There, see? Didn&#39;t take long, did it?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Ok Mr. Evert,
</p></div></div><p>
Watch it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 17 Feb 2007 16:35:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Watch it.
</p></div></div><p>Low self esteem, or do you just not like being called Mr.?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sat, 17 Feb 2007 18:44:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is Mr an insult these days? <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kentl)</author>
		<pubDate>Sat, 17 Feb 2007 18:47:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre>
<span class="p">#define BLACK makecol(0,0,0)</span>
</pre></div></div><p>

 Is it okay to call allegro functions before allegro_init() ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (William Labbett)</author>
		<pubDate>Sat, 17 Feb 2007 19:20:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Functions placed in macros aren&#39;t called until the macro is used.</p><p>Think of the preprocessor as a big search and replace engine. The compiler only sees what happens after the search and replace takes place.</p><p>So &quot;BLACK&quot; gets translated into makecol(0,0,0) where ever its used, before it hits the compiler, thus, the compiler only sees a bunch of makecol calls.</p><p>edit, but to answer your question, generally no, things wont work if allegro hasn&#39;t been initialized.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sat, 17 Feb 2007 19:47:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Low self esteem, or do you just not like being called Mr.?
</p></div></div><p>
On the conterary on both parts. However, I felt the response in this case to be unjustly sarcastic.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 17 Feb 2007 20:21:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I didn&#39;t think there was enough context to tell if it was sarcastic at all.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sat, 17 Feb 2007 20:26:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>And for the last <span class="cuss"><span>goddamn</span></span> time, BMP IS NOT A WEB-APPROPRIATE IMAGE FORMAT.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Sat, 17 Feb 2007 20:33:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I didn&#39;t think there was enough context to tell if it was sarcastic at all.
</p></div></div><p>
I did. How would you take suddenly being called &quot;Mr. Fjellstrom&quot;?<br />Not that it matters much either way; the important things is that he posted the example program and got an answer to what was wrong with it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 17 Feb 2007 21:37:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
How would you take suddenly being called &quot;Mr. Fjellstrom&quot;?
</p></div></div><p>I dunno, I don&#39;t think I&#39;d think it was sarcasm right away. the tone in the rest of the message would tell me either way.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sat, 17 Feb 2007 21:53:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, the rest of the message was fine. The opening ticked me off a little. Meh, never mind.</p><p>EDIT: I should perhaps mention, the change that Kitty Cat pointed out does actually fix the problem.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 17 Feb 2007 22:26:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Kitty Cat&#39;s got it right. You can&#39;t call create_bitmap() until <u>after</u> you have selected a video mode, otherwise the colour depth of the bitmap might not match the colour depth of the screen.</p><p>If you want to, you can get around this using create_bitmap_ex() which allows you to specify the colour depth of any bitmap you create.</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Sun, 18 Feb 2007 00:13:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If you want to, you can get around this using create_bitmap_ex() which allows you to specify the colour depth of any bitmap you create.
</p></div></div><p>That still might not do it. Allegro creates bitmaps in the same ordering (BGR RGB) as the card uses, and the default before a mode it set is BGR iirc, so if a card uses RGB, you&#39;ll have a BGR bitmap and a RGB screen.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 18 Feb 2007 01:13:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks Kitty Cat and Evert for the suggestion (so hard feelings mate)!!!</p><p>Something so easy too.. got it to work.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Sun, 18 Feb 2007 02:12:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I mentioned the solution in the first post. Oh wel :-p
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Sun, 18 Feb 2007 02:29:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>kazzmir,</p><p>Sorry.. I guess you can give the man an answer, but if he doesn&#39;t know the language, its pointless..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jon Ray)</author>
		<pubDate>Sun, 18 Feb 2007 02:31:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>To build upon Thomas&#39;s reply regarding makecol before allegro_init(), it&#39;s also worth noting you may run into issues if you use makecol, load_bitmap, etc before setting the color depth and/or graphics mode.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Sun, 18 Feb 2007 03:55:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Maybe it&#39;d be worth mentioning that in the docs.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (William Labbett)</author>
		<pubDate>Mon, 19 Feb 2007 10:22:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">The Manual said:</div><div class="quote"><p>
 Initialises the Allegro library. You must call either this or allegro_init() before doing anything other than using the Unicode routines. If you want to use a text mode other than UTF-8, you can set it with set_uformat() before you call this. The other functions that can be called before this one will be marked explicitly in the documentation, like set_config_file().
</p></div></div><p>

<a href="http://www.allegro.cc/manual/api/using-allegro/install_allegro">http://www.allegro.cc/manual/api/using-allegro/install_allegro</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 19 Feb 2007 10:32:16 +0000</pubDate>
	</item>
</rss>
