<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>maximum size to al_create_bitmap</title>
		<link>http://www.allegro.cc/forums/view/607150</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 01 May 2011 11:49:59 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Allegro5 question:</p><p>I&#39;m working on loading a tile set into a single bitmap, and then drawing regions of this bitmap as required. It was the simplest and most straightforward approach.</p><p>But I seem to be having a problem. I&#39;ve saved the tile set into a custom format made with TileStudio (which is awesome by the way), and so I&#39;ve written code that loads it into an Allegro5 bitmap structure. I do this by creating a new bitmap, and then loading the pixel colour components from the file and using al_put_pixel. Now I know this all works, because I&#39;ve seen it.</p><p>But it gets to when I&#39;m actually creating the bitmap. Sometimes (most of the time but not all) al_create_bitmap will cause a weird exception to be thrown elsewhere in the program. That is, the code will execute until al_create_bitmap, and then it&#39;ll throw an exception. But the call stack will in fact point to a different part of the program (some where inside the NSApplication object - I&#39;m using Mac OS X).</p><p>I&#39;ve concluded, but I&#39;m not entirely sure, that this is being caused by me asking for a massive bitmap. 48 tiles, each tile 32x32x32bits. So I was curious if there is an upper limit on the permitted size of a bitmap (independent of the available memory).</p><p>Let me know <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (The Master)</author>
		<pubDate>Thu, 28 Apr 2011 19:11:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607150/914993#target">The Master</a> said:</div><div class="quote"><p>That is, the code will execute until al_create_bitmap, and then it&#39;ll throw an exception. But the call stack will in fact point to a different part of the program (some where inside the NSApplication object - I&#39;m using Mac OS X).</p></div></div><p>
That&#39;s the main thread, but your program runs from a secondary thread. You need to switch to one of the other threads to find the correct point where the program crashes (I can never quite remember which thread I want, but you can easily tell by trying them all because most of the tracebacks will not make sence).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>I&#39;ve concluded, but I&#39;m not entirely sure, that this is being caused by me asking for a massive bitmap. 48 tiles, each tile 32x32x32bits. So I was curious if there is an upper limit on the permitted size of a bitmap (independent of the available memory).</p></div></div><p>
Yes, if it&#39;s a video bitmap, it must be smaller than the largest texture size. If you do a 32 by 48*32 bitmap, you may overrun that. This is less likely if you do 3*32 by 16*32.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Thu, 28 Apr 2011 19:26:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can query the maximum size allowed via <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_new_display_option"><span class="a">al_get_new_display_option</span></a></span> with <span class="source-code">ALLEGRO_MAX_BITMAP_SIZE</span>.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607150/914995#target">Evert</a> said:</div><div class="quote"><p> if you do a 32 by 48*32 bitmap, you may overrun that. This is less likely if you do 3*32 by 16*32.
</p></div></div><p>In other words, make your tile bitmap square. The longest side is what determines whether or not it will fit into a video bitmap. The same card that doesn&#39;t support 1025x32 might support 1024x1024.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 28 Apr 2011 21:09:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, i think this is worthy of a bug report in the MacOSX port. i&#39;m still having this problem.</p><p>[EDIT] it&#39;s not just appearing in al_create_bitmap. sometimes it shows up in al_set_target_bitmap. sometimes it shows up in al_fclose.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (The Master)</author>
		<pubDate>Sat, 30 Apr 2011 15:31:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Post backtraces of when it occurs, and try examining local variables in the line of code that crashes. Also, run a debug version of your program linked to the debugging version of Allegro. That will create an allegro.log file that may have some clues as well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sat, 30 Apr 2011 15:48:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607150/915421#target">The Master</a> said:</div><div class="quote"><p>Well, i think this is worthy of a bug report in the MacOSX port. i&#39;m still having this problem.</p></div></div><p>
There&#39;s no OS X specific code in <span class="source-code"><a href="http://www.allegro.cc/manual/al_create_bitmap"><span class="a">al_create_bitmap</span></a><span class="k2">(</span><span class="k2">)</span></span>, it&#39;s the same code used on other OpenGL-based ports. So if there is a problem with it, it should show up there too.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>it&#39;s not just appearing in al_create_bitmap. sometimes it shows up in al_set_target_bitmap. sometimes it shows up in al_fclose.</p></div></div><p>
That sounds like you are overwriting memory that you shouldn&#39;t due to a bad pointer.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 30 Apr 2011 15:58:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok, i&#39;ll triple check my loading and allocation. might use vectors or something instead of the new operator</p><p>[EDIT] Now this is freaking weird. I changed my data allocation methods from &#39;new&#39; to &#39;std::vector&#39;. and it still shows the same bad alloc error: exact same line number, different code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (The Master)</author>
		<pubDate>Sun, 01 May 2011 11:39:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Why don&#39;t you post the code you are using? We can&#39;t find any errors you might be making without seeing the code you are using. If your code is throwing a std::bad_alloc exception, you are asking for too much memory. Show code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 01 May 2011 11:49:59 +0000</pubDate>
	</item>
</rss>
