<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Fullscreen toggle laggy?</title>
		<link>http://www.allegro.cc/forums/view/609200</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 06 Jan 2012 03:48:42 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Using the following code in the main loop:</p><p>if (keysDown[ALLEGRO_KEY_F4]) {<br />		if (al_get_display_flags(display) &amp; ALLEGRO_FULLSCREEN)<br />			al_set_new_display_flags(0);<br />		else<br />			al_set_new_display_flags(ALLEGRO_FULLSCREEN);<br />		al_destroy_display(display);<br />		display = al_create_display(640,480);<br />		<br />		cdecl::al_set_target_backbuffer(display);<br />		keysDown[ALLEGRO_KEY_F4] = false;<br />	}</p><p>I am able to toggle fullscreen on and off.  However, while the game runs fine normally in the (initial) windowed mode, when I toggle to fullscreen, it lags badly, and then upon toggling it back the lag remains.  What am I doing wrong?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DaGamesta)</author>
		<pubDate>Wed, 04 Jan 2012 10:23:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just guessing, but did you mean this?</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span> <span class="k2">(</span>keysDown<span class="k2">[</span>ALLEGRO_KEY_F4<span class="k2">]</span><span class="k2">)</span> <span class="k2">{</span>
    <span class="k1">if</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_display_flags"><span class="a">al_get_display_flags</span></a><span class="k2">(</span>display<span class="k2">)</span> <span class="k3">&amp;</span> ALLEGRO_FULLSCREEN<span class="k2">)</span>
      <a href="http://www.allegro.cc/manual/al_set_new_display_flags"><span class="a">al_set_new_display_flags</span></a><span class="k2">(</span><span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
                <span class="k2">}</span>
    <span class="k1">else</span><span class="k2">{</span>
      <a href="http://www.allegro.cc/manual/al_set_new_display_flags"><span class="a">al_set_new_display_flags</span></a><span class="k2">(</span>ALLEGRO_FULLSCREEN<span class="k2">)</span><span class="k2">;</span>
      <a href="http://www.allegro.cc/manual/al_destroy_display"><span class="a">al_destroy_display</span></a><span class="k2">(</span>display<span class="k2">)</span><span class="k2">;</span>
      display <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_display"><span class="a">al_create_display</span></a><span class="k2">(</span><span class="n">640</span>,<span class="n">480</span><span class="k2">)</span><span class="k2">;</span>
    <span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 04 Jan 2012 10:26:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Recreate all your bitmaps after changing modes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 04 Jan 2012 10:26:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There was a thread about this recently :<br /><a href="http://www.allegro.cc/forums/thread/609132/941627#target">http://www.allegro.cc/forums/thread/609132/941627#target</a></p><p>It turned out for him, it was because the bitmaps became memory bitmaps, or else they were incompatible with the new display somehow.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 04 Jan 2012 10:27:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Problem here is, I&#39;m using Allegro 5.0.5, which doesn&#39;t have al_convert_bitmap.  Also, I store all of my bitmaps in separate &quot;sprite&quot; classes, they&#39;d be a major pain to keep track of separately.  Is my only option to compile allegro 5.1 elsewise, though?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DaGamesta)</author>
		<pubDate>Wed, 04 Jan 2012 12:21:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You should be able to do this as a temporary work around:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> fix_bmp<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span><span class="k3">*</span>bmp<span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">if</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_bitmap_flags"><span class="a">al_get_bitmap_flags</span></a><span class="k2">(</span><span class="k3">*</span>bmp<span class="k2">)</span> <span class="k3">&amp;</span> ALLEGRO_MEMORY_BITMAP<span class="k2">)</span>
  <span class="k2">{</span>
    <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>tmp <span class="k3">=</span> <span class="k3">*</span>bmp<span class="k2">;</span>
    <span class="k3">*</span>bmp <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_clone_bitmap"><span class="a">al_clone_bitmap</span></a><span class="k2">(</span><span class="k3">*</span>bmp<span class="k2">)</span><span class="k2">;</span> <span class="c">/* converts to video */</span>
    <a href="http://www.allegro.cc/manual/al_destroy_bitmap"><span class="a">al_destroy_bitmap</span></a><span class="k2">(</span>tmp<span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
<span class="k2">}</span>

fix_bmp<span class="k2">(</span><span class="k3">&amp;</span>sprite-&gt;bmp<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_draw_bitmap"><span class="a">al_draw_bitmap</span></a><span class="k2">(</span>sprite-&gt;bmp, x, y, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 04 Jan 2012 12:30:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I feel very stupid for not thinking of that, or rather noticing that that function existed.  Thank you very much for the help.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DaGamesta)</author>
		<pubDate>Wed, 04 Jan 2012 13:23:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If I&#39;m using A4 and I toggle fullscreen dynamically would I also need to refresh my bitmaps?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Thu, 05 Jan 2012 05:23:21 +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/609200/942693#target">Felix-The-Ghost</a> said:</div><div class="quote"><p>If I&#39;m using A4 and I toggle fullscreen dynamically would I also need to refresh my bitmaps?</p></div></div><p>Only if they are video bitmaps. Or possibly system bitmaps. If they were created via create_bitmap, you&#39;re fine.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 05 Jan 2012 05:28:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ahh okay. And load_bitmap I assume. Is there anything else I&#39;d need to do (aside from the different drawing code)</p><p>I made a fullscreen toggle test waaaay back, ~A4.2 and I forgot what I did <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" /><br />Don&#39;t you have to allegro_exit() and reinitialize or something before another set_gfx_mode() call?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Thu, 05 Jan 2012 05:33:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Seems to me you had to do a set_gfx_mode(GFX_TEXT,0,0,0,0); then you could reset a graphic mode.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Thu, 05 Jan 2012 05:35:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If I don&#39;t do :
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>GFX_TEXT , <span class="n">0</span> , <span class="n">0</span> , <span class="n">0</span> , <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/allegro_message"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"blah"</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>NEW_MODE , W , H , <span class="n">0</span> , <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
then the screen goes pink or doesn&#39;t display right on Windows. That&#39;s just what works for me. The problems were especially bad going from fullscreen to windowed mode.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 05 Jan 2012 05:38:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmm. What you two are saying is about the same. Is the message output necessary for it to work? If not it&#39;s good for at least telling the player what&#39;s going on.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Thu, 05 Jan 2012 05:59:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;d say the only purpose it serves is putting a delay between the two calls. Some glitch in allegro or the OS/drivers might not like it when the mode is changed too fast.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 05 Jan 2012 06:04:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, at least for me, the allegro message bit was necessary to properly change resolutions. I just use it to output the new resolution to the user.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 05 Jan 2012 06:04:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Interesting. So a rest() call or timer probably wouldn&#39;t do it? I think allegro_message() is kinda ugly... but if it works...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Thu, 05 Jan 2012 10:05:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If it is just a timing issue, a rest should work.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 05 Jan 2012 10:27:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Any magic numbers? <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" /><br />Would it vary from OS to OS? <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Thu, 05 Jan 2012 10:34:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;d imagine a full second delay should work for anything.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Thu, 05 Jan 2012 10:38:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, alright. Sometimes I&#39;m impressed with the speed of computers. I get awed when I make a function that loops a lot of y/x pixels and does something with them and the program still runs at dozens/frames/second <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Thu, 05 Jan 2012 10:43:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nobody noticed that putting that in your main loop would try to create a new display for the number of times you check the keyboard while F4 is pressed down? (Or would the actual switch pause the program long enough to let you lift your finger?) And what does cdecl do?!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (weapon_S)</author>
		<pubDate>Thu, 05 Jan 2012 23:27:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Looks like <i>cdecl</i> is a name-space -- user defined or otherwise.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/609200/942759#target">weapon_S</a> said:</div><div class="quote"><p>Nobody noticed that putting that in your main loop would try to create a new display for the number of times you check the keyboard while F4 is pressed down?</p></div></div><p>
I assume this does something about it:
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p><span class="source-code">keysDown<span class="k3">&lt;</span>ALLEGRO_KEY_F4&gt; <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span></span></p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Felix-The-Ghost)</author>
		<pubDate>Fri, 06 Jan 2012 03:48:42 +0000</pubDate>
	</item>
</rss>
