<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>How to make a loading screen?</title>
		<link>http://www.allegro.cc/forums/view/609387</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 30 Jan 2012 16:29:42 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m making an RPG game and the map is 10000 pixels by 10000 pixels(One of the maps I should say) and on my computer it takes about 1-3 seconds to load, but on my girlfriends laptop it takes about 6-8 seconds and I was just wondering if it was able to make a loading screen. So that you didn&#39;t just have to look at black, I did think of other ways of doing it, like only loading 640, 480 pixels around you as you walk but I just thought that it would be nice to learn something new today if it&#39;s not to much trouble for you to explain how I would go about doing that.<br />Thank-you <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (wolf_wolf17)</author>
		<pubDate>Wed, 25 Jan 2012 08:48:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Threads. Main thread displays loading animation. Second thread loads image. When second thread finishes, it signals main thread and loading screen completes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 25 Jan 2012 09:53:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It can be done even without I suppose, although depending on the loading method. You may split loading work to multiple smaller ones and update the animation in between them.</p><p>However, majority of simple applications just show a loading image for that purpose. This way you just first load &amp; display small image and then load the heavy stuff.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (type568)</author>
		<pubDate>Wed, 25 Jan 2012 10:09:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Could any of you give me some example code, or point me to a web site that teaches me what I need to know. It would be much appreciated <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (wolf_wolf17)</author>
		<pubDate>Sat, 28 Jan 2012 11:18:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>With Allegro 5.0:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="c">// mark as volatile so that the compiler knows it may unexpectedly change</span>
<span class="number">  2</span><span class="k1">volatile</span> <span class="k1">bool</span> done_loading <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span> 
<span class="number">  3</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>my_bitmap<span class="k2">;</span>
<span class="number">  4</span>
<span class="number">  5</span><span class="k1">void</span> <span class="k3">*</span>my_thread<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_THREAD"><span class="a">ALLEGRO_THREAD</span></a> <span class="k3">*</span>me, <span class="k1">void</span> <span class="k3">*</span>data<span class="k2">)</span>
<span class="number">  6</span><span class="k2">{</span>
<span class="number">  7</span>  <span class="k2">(</span><span class="k1">void</span><span class="k2">)</span> data<span class="k2">;</span> <span class="c">// aren't using this. this is the NULL parameter from below</span>
<span class="number">  8</span>
<span class="number">  9</span>  my_bitmap <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_load_bitmap"><span class="a">al_load_bitmap</span></a><span class="k2">(</span><span class="s">"foo.bmp"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 10</span>  <span class="c">// load other bitmaps</span>
<span class="number"> 11</span>
<span class="number"> 12</span>  done_loading <span class="k3">=</span> <span class="k1">true</span><span class="k2">;</span>
<span class="number"> 13</span>
<span class="number"> 14</span>  <span class="c">// when running an attached thread, the following is the return value to</span>
<span class="number"> 15</span>  <span class="c">// al_join_thread(), which we are not using here.</span>
<span class="number"> 16</span>  <span class="k1">return</span> NULL<span class="k2">;</span> 
<span class="number"> 17</span><span class="k2">}</span>
<span class="number"> 18</span>
<span class="number"> 19</span><span class="c">// starts the loading thread</span>
<span class="number"> 20</span><a href="http://www.allegro.cc/manual/al_run_detached_thread"><span class="a">al_run_detached_thread</span></a><span class="k2">(</span>my_thread, NULL<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 21</span>
<span class="number"> 22</span><span class="c">// this code will execute while the above function is running</span>
<span class="number"> 23</span>
<span class="number"> 24</span><span class="k1">while</span> <span class="k2">(</span><span class="k3">!</span>done_loading<span class="k2">)</span>
<span class="number"> 25</span><span class="k2">{</span>
<span class="number"> 26</span>  <span class="c">// show loading page, etc</span>
<span class="number"> 27</span><span class="k2">}</span>
</div></div><p>
Normally you&#39;d need to convert the bitmap to video after that while loop is over because the loader thread will create it as memory. However, in your case, the video card is not going to support a video bitmap of that size, so it doesn&#39;t matter. (But if you are loading smaller bitmaps, you&#39;d need to convert them to video.)</p><p>Threading can get complex because you normally don&#39;t want two threads reading and writing the same data at the same time. However in this case, since one thread is writing a boolean that the other thread only reads, it will be safe. For more complex interaction, you need to use mutexes and condition variables.</p><p>Anyway, all that said, the real solution is not to use a bitmap that large...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Sat, 28 Jan 2012 11:38:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Agreed there, I think  you should look into using tile maps, in stead of using such a huge background image.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (beoran)</author>
		<pubDate>Mon, 30 Jan 2012 16:29:42 +0000</pubDate>
	</item>
</rss>
