<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>blit crash!</title>
		<link>http://www.allegro.cc/forums/view/579399</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 16 Apr 2006 02:15:45 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have this piece of code:
</p><div class="source-code snippet"><div class="inner"><pre>            <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>graphicpack.background<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>,drawto.drawon<span class="k2">(</span><span class="k2">)</span>,
            <span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">800</span>,<span class="n">600</span><span class="k2">)</span><span class="k2">;</span><span class="c">//draw demon background.</span>
</pre></div></div><p>
it crashes at this point.<br />graphicpack.background[0] is loaded up in memory.  the bitmap returned by drawto.drawon() is allocated in video memory space.</p><p>what could I be doing wrong to cause allegro to crash?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (khristina yer)</author>
		<pubDate>Sat, 15 Apr 2006 19:26:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Post more background information. More code, circumstances in which it happens, etc...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 15 Apr 2006 19:28:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>this is where graphicpack.background[0] gets loaded.<br /><span class="source-code">        background<span class="k2">[</span>go<span class="k2">]</span><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>filename,NULL<span class="k2">)</span><span class="k2">;</span></span><br />this is what drawto.drawon() returns
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> DrawEngine::drawon<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
    <span class="k1">return</span> drawimage<span class="k2">[</span>which<span class="k2">]</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
This is where drawimage[which] gets created.
</p><div class="source-code snippet"><div class="inner"><pre>    drawimage<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k3">=</span><a href="http://www.allegro.cc/manual/create_video_bitmap" target="_blank"><span class="a">create_video_bitmap</span></a><span class="k2">(</span>x,y<span class="k2">)</span><span class="k2">;</span>
    drawimage<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k3">=</span><a href="http://www.allegro.cc/manual/create_video_bitmap" target="_blank"><span class="a">create_video_bitmap</span></a><span class="k2">(</span>x,y<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

of course I did do error checking so I know they are there.</p><p>I really don&#39;t know what other details I can post, without handing out the src code.</p><p>it crashes at the blit.  It sets the video mode, loads the graphics, reserves video memory, and then when I try to do the blit, it will crash.</p><p>would blitting from a memory bitmap to a video memory bitmap cause this problem?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (khristina yer)</author>
		<pubDate>Sat, 15 Apr 2006 19:39:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
would blitting from a memory bitmap to a video memory bitmap cause this problem?
</p></div></div><p>
I don&#39;t think so. Blit crashing usually indicates that there&#39;s something wrong with at least one of the bitmaps in question.</p><p>What are the values of x and y in create_video_bitmap()? Do you set the colour depth after setting the gfx mode? Do you load the background and/or create the video pages before setting the gfx mode? Does the same happen if you use memory back buffer?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 15 Apr 2006 19:46:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
What are the values of x and y in create_video_bitmap()?
</p></div></div><p>
800 x 600 y in this test run.
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Do you set the colour depth before setting the gfx mode?
</p></div></div><p>
yes I set it to 16
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Do you load the background and create the video pages after setting the gfx mode?
</p></div></div><p>
yes it sets the resolution and then I load the background and create the video pages.</p><p>I don&#39;t know whats wrong.</p><p>[edit]<br />I blitted from the screen to the video buffer.  And that did not crash.  So I&#39;m guessing something is wrong with my picture.  But what could that be?</p><p>Also I saved grahpicpack.background[0] to a file, and it looked fine.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (khristina yer)</author>
		<pubDate>Sat, 15 Apr 2006 19:54:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Try to create a <b>minimal</b> example that shows the problem and post the code (all of it, with main() and everything). Should be around 20 lines.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 15 Apr 2006 20:03:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><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="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argv,<span class="k1">char</span><span class="k3">*</span> argc<span class="k2">[</span><span class="k2">]</span><span class="k2">)</span></td></tr><tr><td class="number">4</td><td><span class="k2">{</span></td></tr><tr><td class="number">5</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">6</td><td>    <a href="http://www.allegro.cc/manual/install_timer" target="_blank"><span class="a">install_timer</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td>    </td></tr><tr><td class="number">8</td><td>    <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> background<span class="k2">;</span></td></tr><tr><td class="number">9</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><span class="n">2</span><span class="k2">]</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>    </td></tr><tr><td class="number">11</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">16</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</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_WINDOWED,<span class="n">800</span>,<span class="n">600</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">13</td><td>    </td></tr><tr><td class="number">14</td><td>    background<span class="k3">=</span><a href="http://www.allegro.cc/manual/load_bmp" target="_blank"><span class="a">load_bmp</span></a><span class="k2">(</span><span class="s">"background.bmp"</span>,NULL<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>    buffer<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k3">=</span><a href="http://www.allegro.cc/manual/create_video_bitmap" target="_blank"><span class="a">create_video_bitmap</span></a><span class="k2">(</span><span class="n">800</span>,<span class="n">600</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">16</td><td>    buffer<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k3">=</span><a href="http://www.allegro.cc/manual/create_video_bitmap" target="_blank"><span class="a">create_video_bitmap</span></a><span class="k2">(</span><span class="n">800</span>,<span class="n">600</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>    <span class="k1">int</span> which<span class="k3">=</span><span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>    </td></tr><tr><td class="number">19</td><td>    <span class="k1">while</span><span class="k2">(</span>TRUE<span class="k2">)</span></td></tr><tr><td class="number">20</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">21</td><td>        <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>background,buffer<span class="k2">[</span>which<span class="k2">]</span>,</td></tr><tr><td class="number">22</td><td>        <span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">800</span>,<span class="n">600</span><span class="k2">)</span><span class="k2">;</span><span class="c">//draw demon background.</span></td></tr><tr><td class="number">23</td><td>        <a href="http://www.allegro.cc/manual/show_video_bitmap" target="_blank"><span class="a">show_video_bitmap</span></a><span class="k2">(</span>buffer<span class="k2">[</span>which<span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td>        <span class="k1">if</span><span class="k2">(</span>which<span class="k3">=</span><span class="k3">=</span><span class="n">0</span><span class="k2">)</span><span class="k2">{</span>which<span class="k3">=</span><span class="n">1</span><span class="k2">;</span><span class="k2">}</span><span class="k1">else</span> <span class="k2">{</span>which<span class="k3">=</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>&#160;</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> </td></tr><tr><td class="number">30</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><span class="k2">;</span></td></tr></tbody></table></div></div><p>

I compiled and tested this code.  It did not crash.  It did just what I wanted it to do.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (khristina yer)</author>
		<pubDate>Sat, 15 Apr 2006 20:17:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If your code is not secret, nor very long maybe you could try posting it, so we can give a debug at it.</p><p>I know it&#39;s not the problem, but I prefer the following:</p><div class="source-code snippet"><div class="inner"><pre>which <span class="k3">=</span> <span class="n">1</span> <span class="k3">-</span> which<span class="k2">;</span>
</pre></div></div><p>

which is cleaner.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (umperio)</author>
		<pubDate>Sat, 15 Apr 2006 20:30:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The code is very long, but I&#39;ll make a attachment.</p><p>Please be gentle with the criticism.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (khristina yer)</author>
		<pubDate>Sat, 15 Apr 2006 20:35:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>EDIT: Posted before the last post <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" /></p><p>That only shows the problem is not with blitting the background to a video bitmap but somewhere else. Try to create a minimal example that <b>shows the problem</b> and post the code.</p><p>---------<br />EDIT:<br />I didn&#39;t compile the code <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" />, but I noticed that background0.bmp isn&#39;t an 800x600 bitmap. It&#39;s 800x54...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 15 Apr 2006 20:36:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I noticed that background0.bmp isn&#39;t an 800x600 bitmap. It&#39;s 800x54...
</p></div></div><p>
Thats strange!  All of my programs report it as 800x600.  I used gimp to make it.  Do you think gimp has it messed up somehow?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (khristina yer)</author>
		<pubDate>Sat, 15 Apr 2006 20:57:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry, my mistake. I&#39;m having problems with my image viewer program... <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Sat, 15 Apr 2006 21:09:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>At first, the problem seems to be related to graphicpack.background[0] not being loaded correctly, in fact blitting a loaded bitmap to drawto.drawon() works perfectly, but saving graphicpack.background[0], gave an image which cannot be open. I wonder how you managed to save it.<br />Anyway that&#39;s not the only problem since removing the blitting code still crashes the whole thing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (umperio)</author>
		<pubDate>Sat, 15 Apr 2006 22:07:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The next crash would probably be another blit.</p><p>Well I can&#39;t find out whats wrong.  I&#39;ve checked the address of background it self, It looks like it loaded.  The background isn&#39;t loading correctly.  But why is everthing reporting that its fine?  Is it getting lost somewhere?  I&#39;m going to try and blit the freshly loaded image before that function ends.</p><p>[REPORT]<br />Ok it blitted the freshly loaded image.  And it worked fine.  I checked the address in that spot with the address on the outside where it crashes.  They have the same address, So what could cause it to be unloaded?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (khristina yer)</author>
		<pubDate>Sun, 16 Apr 2006 02:15:45 +0000</pubDate>
	</item>
</rss>
