<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>SWITCH_BACKGROUND hangs</title>
		<link>http://www.allegro.cc/forums/view/587627</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 19 Sep 2006 23:58:33 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My application, which is normally very stable, tends to hang when not the active window whenever I run with set_display_switch_mode(SWITCH_BACKGROUND). I am calling acquire_screen() and release_screen() before and after any writes to the screen, but this doesn&#39;t seem to help. </p><p>I&#39;m using Allegro 4.2.0 under Windows 2000 professional and Visual Studio 2005.</p><p>Can anyone get SWITCH_BACKGROUND to work?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (locksleyu)</author>
		<pubDate>Tue, 19 Sep 2006 19:45:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I am calling acquire_screen() and release_screen() before and after any writes to the screen, but this doesn&#39;t seem to help.
</p></div></div><p>
You&#39;re not doing anything else except blitting operations to the screen between those calls are you?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Tue, 19 Sep 2006 19:49:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am only doing circle(), line(), rect() and draw_sprite() between the acquire and the release. I am using double buffering so I do most of the normal drawing to my active page, and then I call draw_sprite(screen, active_page, ..)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (locksleyu)</author>
		<pubDate>Tue, 19 Sep 2006 19:58:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I take it you know switch_background doesn&#39;t actually work in windows fullscreen mode?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Tue, 19 Sep 2006 20:38:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m running in windowed mode with videomode GFX_GDI. SWITCH_BACKGROUND works in this mode, right?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (locksleyu)</author>
		<pubDate>Tue, 19 Sep 2006 22:46:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I can only imagine so, but you should always test the return value. In my code I allow swapping between windowed/fullscreen and various other modes so I simply code for the bare minimum that should work for windows and other o/s&#39;s, as in:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td>  <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/set_display_switch_mode" target="_blank"><span class="a">set_display_switch_mode</span></a><span class="k2">(</span>SWITCH_PAUSE<span class="k2">)</span><span class="k3">=</span><span class="k3">=</span><span class="n">0</span><span class="k2">)</span></td></tr><tr><td class="number">2</td><td>    Configuration::LogEntry<span class="k2">(</span><span class="s">"Switch mode set to PAUSE"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">3</td><td>  <span class="k1">else</span></td></tr><tr><td class="number">4</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">5</td><td>    Configuration::LogEntry<span class="k2">(</span><span class="s">"Failed. Trying SWITCH_AMNESIA"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">6</td><td>    <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/set_display_switch_mode" target="_blank"><span class="a">set_display_switch_mode</span></a><span class="k2">(</span>SWITCH_AMNESIA<span class="k2">)</span><span class="k3">=</span><span class="k3">=</span><span class="n">0</span><span class="k2">)</span></td></tr><tr><td class="number">7</td><td>      Configuration::LogEntry<span class="k2">(</span><span class="s">"Switch mode set to SWITCH_AMNESIA - pause/resume but buffer needs refreshing on focus"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">8</td><td>    <span class="k1">else</span></td></tr><tr><td class="number">9</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">10</td><td>      Configuration::LogEntry<span class="k2">(</span><span class="s">"Failed. Trying SWITCH_BACKAMNESIA"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>      <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/set_display_switch_mode" target="_blank"><span class="a">set_display_switch_mode</span></a><span class="k2">(</span>SWITCH_BACKAMNESIA<span class="k2">)</span><span class="k3">=</span><span class="k3">=</span><span class="n">0</span><span class="k2">)</span></td></tr><tr><td class="number">12</td><td>        Configuration::LogEntry<span class="k2">(</span><span class="s">"Switch mode set to SWITCH_AMNESIA - run in background but buffer needs refreshing on focus"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>      <span class="k1">else</span></td></tr><tr><td class="number">14</td><td>        Configuration::LogEntry<span class="k2">(</span><span class="s">"Switch mode failed to set SWITCH_BACKAMNESIA. Nothing Done!"</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="k2">}</span></td></tr></tbody></table></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Tue, 19 Sep 2006 22:48:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
set_display_switch_mode(SWITCH_BACKGROUND)
</p></div></div><p>
You did remember to checkthereturn value, right?<br />If that doesn&#39;t work (but BACK_AMNESIA does), you probably should not be writing to screen when your program is swapped out.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
SWITCH_BACKGROUND works in this mode, right?
</p></div></div><p>
I wouldn&#39;t know, but why don&#39;t you check the return value and find out?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Tue, 19 Sep 2006 22:49:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I changed my video mode from GFX_GDI to GFX_DIRECTX_WIN and the hangs have stopped. </p><p>By the way, the call to set_display_switch_mode(SWITCH_BACKGROUND) was returning 0. </p><p>Thanks for the help everyone!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (locksleyu)</author>
		<pubDate>Tue, 19 Sep 2006 23:38:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I changed my video mode from GFX_GDI to GFX_DIRECTX_WIN and the hangs have stopped.
</p></div></div><p>
Any particular reason you&#39;re not using GFX_AUTODETECT_WINDOWED? If not, you should use that instead of any other driver.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Tue, 19 Sep 2006 23:58:33 +0000</pubDate>
	</item>
</rss>
