<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro Linux slower than Allegro Windows?</title>
		<link>http://www.allegro.cc/forums/view/585958</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 21 Jun 2006 06:13:18 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi all,</p><p>I&#39;ve been writing a simple Space Invaders game in Allegro and managed it perfectly under Linux. It runs at a respectable pace and is fairly bug free.</p><p>When I tried to compile it under Windows however, it runs at a blinding, unplayable speed. The thing I tried first of all was to see if this problem reproduces itself under Linux, by removing the vsync() from the game loop. Nope - the game runs at exactly the same speed.</p><p>I&#39;ve tried a number of solutions for controlling the speed of the game (including install_int(60,game_display); install_int(60, update_logic); ) which does absolutely nothing under Windows and SEGFAULTs under Linux.</p><p>Is Allegro Linux generally slower than the Windows version? Funny, because the opposite is true for SDL, where the Windows version is chronically slow!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jamyskis)</author>
		<pubDate>Fri, 16 Jun 2006 18:08:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think you should look at your timer code again...  I&#39;m using windows and timers control the speed of my stuff just fine <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BrknPhoenix)</author>
		<pubDate>Fri, 16 Jun 2006 18:12:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
When I tried to compile it under Windows however, it runs at a blinding, unplayable speed.
</p></div></div><p>
Post the smallest sample program that reproduces the behavior.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I&#39;ve tried a number of solutions for controlling the speed of the game (including install_int(60,game_display); install_int(60, update_logic); ) which does absolutely nothing under Windows and SEGFAULTs under Linux.
</p></div></div><p>
Then you are definately doing it incorrectly. Post your code.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Is Allegro Linux generally slower than the Windows version?
</p></div></div><p>
No, but you do not get hardware acceleration using X11. This can reduce your framerate.<br />However, if you do everything in memory, then there should be no difference (actually, I remember things being a bit faster in Linux, but that was a while ago and the difference was mostly irrelevant).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 16 Jun 2006 18:12:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Show us your code. Your timing code, for example.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Fri, 16 Jun 2006 18:12:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>in windows allegro uses directx in linux isn&#39;t such a thing.<br />this is why for example in my game you get only half perfomance in linux.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Frank Drebin)</author>
		<pubDate>Sat, 17 Jun 2006 15:48:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s fair enough, the speed of the Linux version is fine for me anyway, although it   strikes me as odd that the game always runs at the same speed whether it&#39;s chucking around 50-60 sprites or just 3. It also doesn&#39;t get affected by vsync(), as I&#39;ve discovered from commenting it out in the code. Does Linux Allegro automatically vsync() regardless?</p><p>Anyway, the code, including modifications to the Windows version was thus.</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td>  intro_sequence<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">2</td><td>  </td></tr><tr><td class="number">3</td><td>  <span class="k1">while</span><span class="k2">(</span>program_still_active<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>    title_screen<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">6</td><td>    predefine_variables<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td>    reset_enemies_position<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">8</td><td>    reset_enemies_state<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>    initialise_ingame_music<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>&#160;</td></tr><tr><td class="number">11</td><td>    <a href="http://www.allegro.cc/manual/install_int" target="_blank"><span class="a">install_int</span></a><span class="k2">(</span>update_logic,<span class="n">6</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/install_int" target="_blank"><span class="a">install_int</span></a><span class="k2">(</span>game_display,<span class="n">6</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>    <span class="k1">while</span><span class="k2">(</span>game_still_active<span class="k2">(</span><span class="k2">)</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="c">//game_still_active() returns 0 based on actions within interrupts</span></td></tr><tr><td class="number">17</td><td>    <span class="k2">}</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>&#160;</td></tr><tr><td class="number">19</td><td>    <a href="http://www.allegro.cc/manual/remove_int" target="_blank"><span class="a">remove_int</span></a><span class="k2">(</span>update_logic<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>    <a href="http://www.allegro.cc/manual/remove_int" target="_blank"><span class="a">remove_int</span></a><span class="k2">(</span>game_display<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">21</td><td>  <span class="k2">}</span><span class="k2">;</span></td></tr></tbody></table></div></div><p>

I know the code is extremely untidy and very amateurish, but then I am still quite newbie in these things.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jamyskis)</author>
		<pubDate>Tue, 20 Jun 2006 01:10:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I&#39;ve tried a number of solutions for controlling the speed of the game (including install_int(60,game_display); install_int(60, update_logic); ) which does absolutely nothing under Windows and SEGFAULTs under Linux.
</p></div></div><p>
It would sound like you&#39;re putting a heap of coding in your timer functions and then calling them. You&#39;ll have troubles if the computer can&#39;t compute all of the calcultions in time for the function to be called again.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
install_int(update_logic,6);<br />install_int(game_display,6);
</p></div></div><p>
Why do you have 2 timers? You just need 1 for the entire game!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Tue, 20 Jun 2006 07:52:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are the timers really running at 6 msecs = 167  per second ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (hazul)</author>
		<pubDate>Tue, 20 Jun 2006 15:22:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>you should never, ever, EVER put anything more than just a simple interger increment or similar in your timer functions. It is not multithreading, just a function that is called on a regular basis. (which will die if you try to call it again before it is done)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Tue, 20 Jun 2006 15:58:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So basically the best way is to use the interrupts to change a bool variable from false to true and then call update_logic()/game_display() while the variable is true, changing it to false right at the end?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jamyskis)</author>
		<pubDate>Tue, 20 Jun 2006 22:38:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, you just increment a integer, and then follow the many examples of how to regulate the main loop execution..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 21 Jun 2006 01:58:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
So basically the best way is to use the interrupts to change a bool variable from false to true and then call update_logic()/game_display() while the variable is true, changing it to false right at the end?
</p></div></div><p>
Use an integer to count how many &#39;ticks&#39; you have missed, and then update_logic() that many times until there are none left, then draw the game. If your update_logic is too slow and that the ticks never reach 0, then you&#39;ve got a problem...</p><p>Also, you should probably have a maximum number of times the update_logic will execute before you force a redraw on the screen (in case there are say, 30 logic updates) you don&#39;t want to miss an entire second of the game - or maybe you do - it depends on the game.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Wed, 21 Jun 2006 06:13:18 +0000</pubDate>
	</item>
</rss>
