<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Does Aal_convert_bitmaps Preserve Bitmap Flags?</title>
		<link>http://www.allegro.cc/forums/view/615520</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 09 Jul 2015 10:29:58 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I found a bug in Allegro when using OpenGL and this laptop I have with a GMA 4400 on Win8.</p><p>When I go from fullscreen window back to windowed, things mess up and it doesnt go back to windowed.</p><p>Even ex_fullscreen_window messes up if I tell it to use GL. Ofcourse D3D works fine. -_-</p><p>To try to address this, I tried to recreate the display instead of toggling the flag. This works. Only issue is now none of the bitmaps have mipmap, mag linear, etc.</p><div class="source-code snippet"><div class="inner"><pre>      m_sceneMessenger-&gt;sendContextWillChangedMessage<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
      Vec2 resolution <span class="k3">=</span> getResolution<span class="k2">(</span><span class="k2">)</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_OPENGL <span class="k3">|</span> ALLEGRO_PROGRAMMABLE_PIPELINE <span class="k3">|</span> ALLEGRO_WINDOWED<span class="k2">)</span><span class="k2">;</span>
      <a href="http://www.allegro.cc/manual/al_set_new_bitmap_flags"><span class="a">al_set_new_bitmap_flags</span></a><span class="k2">(</span>
        ALLEGRO_VIDEO_BITMAP <span class="k3">|</span> ALLEGRO_MIN_LINEAR <span class="k3">|</span> 
        ALLEGRO_MAG_LINEAR <span class="k3">|</span> ALLEGRO_MIPMAP <span class="k3">|</span> ALLEGRO_CONVERT_BITMAP<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>context<span class="k2">)</span><span class="k2">;</span>
      context <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>resolution.getX<span class="k2">(</span><span class="k2">)</span>,resolution.getY<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
      <a href="http://www.allegro.cc/manual/al_set_new_bitmap_flags"><span class="a">al_set_new_bitmap_flags</span></a><span class="k2">(</span>
        ALLEGRO_VIDEO_BITMAP <span class="k3">|</span> ALLEGRO_MIN_LINEAR <span class="k3">|</span> 
        ALLEGRO_MAG_LINEAR <span class="k3">|</span> ALLEGRO_MIPMAP <span class="k3">|</span> ALLEGRO_CONVERT_BITMAP<span class="k2">)</span><span class="k2">;</span>
      al_convert_bitmaps<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
      m_sceneMessenger-&gt;sendContextChangedMessage<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Is this normal or is al_convert_bitmaps supposed to restore mipmap, maglinear etc?</p><p>Using 5.1.10 on Windows 7/8
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sat, 04 Jul 2015 09:13:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve noticed that as well, if you try to un-fullscreen a fullscreen window in OpenGL mode it gets stuck in some sort of weird &quot;limbo&quot; state.  It only seems to happen on Intel cards though, on my AMD machine it works fine.</p><p>What&#39;s weird is that I also has a screenshot feature, and if I activate that while it&#39;s in &quot;limbo&quot;, the screenshot code cloning the backbuffer usually coaxes it the rest of the way out of fullscreen mode.</p><p>That might be a thing to try, actually: In your code that switches between fullscreen and windowed modes, what happens if you add this line after the switch:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_destroy_bitmap"><span class="a">al_destroy_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_clone_bitmap"><span class="a">al_clone_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_backbuffer"><span class="a">al_get_backbuffer</span></a><span class="k2">(</span>display<span class="k2">)</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Does that work around the issue?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Pascoe)</author>
		<pubDate>Sat, 04 Jul 2015 20:06:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Wow, that completely fixed it! Many thanks! <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sat, 04 Jul 2015 23:43:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I hereby dub this fix &quot;How I fixed Allegro fullscreen using this one weird trick&quot; <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Pascoe)</author>
		<pubDate>Sun, 05 Jul 2015 02:35:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>From what I understand, when bitmaps get converted, they all get their flags set to what is passed to <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_new_bitmap_flags"><span class="a">al_set_new_bitmap_flags</span></a></span>. It&#39;s not obvious how to get them to preserve flags, since if there&#39;s a memory bitmap in between conversions, it&#39;ll necessarily lose some flags.</p><p>As for the fullscreen toggling, I&#39;ll investigate it at some point.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sun, 05 Jul 2015 08:40:04 +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/615520/1014714#target">SiegeLord</a> said:</div><div class="quote"><p>
they all get their flags set to what is passed to al_set_new_bitmap_flags.
</p></div></div><p>

In this case that did not happen at all. I tried to shove calls to al_set_new_bitmap_flags with mipmap, mag linear etc before, after etc recreating the display but none of the bitmaps ever wound up having those attributes after conversion.</p><p>Maybe because Allegro notes that to have mipmap you need power of 2 textures and many of my textures are not power of 2 so maybe when they are converted they are not converted to power of 2?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sun, 05 Jul 2015 17:34:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I wonder if we should store the &quot;last_flags&quot; or something for a converted bitmap, so when its converted back it can keep its previous flags.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/615520/1014727#target">jmasterx</a> said:</div><div class="quote"><p>maybe when they are converted they are not converted to power of 2?</p></div></div><p>Hm, if allegro is actually turning your bitmaps into power of 2 textures, and isn&#39;t when its converting back, it probably should.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 06 Jul 2015 02:55:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Alright, so the situation somewhat different. Turns out <span class="source-code">al_convert_bitmaps</span> merely toggles whether the bitmap is memory or not, but otherwise it preserves the remaining flags. What was happening in your example was that when the display was destroyed, the flags were reset to just ALLEGRO_MEMORY_BITMAP. I&#39;ve now fixed it to preserve the bitmap flags upon destruction, so everything should be fine.</p><p>I&#39;m still investigating the toggling issue.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 09 Jul 2015 10:21:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Alright, good you&#39;re still looking into that issue, it&#39;s been plaguing me for a while.  It only seems to occur on machines with Intel graphics, my main development machine (AMD) doesn&#39;t exhibit it.</p><p>Regardless, the workaround I came up with above has to be my favorite fix of all time:
</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"> 513</span>    <span class="c">// strange but true: this fixes an Allegro bug where OpenGL displays get</span>
<span class="number"> 514</span>    <span class="c">// stuck in limbo when switching out of fullscreen.</span>
<span class="number"> 515</span>    <a href="http://www.allegro.cc/manual/al_destroy_bitmap"><span class="a">al_destroy_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_clone_bitmap"><span class="a">al_clone_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_backbuffer"><span class="a">al_get_backbuffer</span></a><span class="k2">(</span>g_display<span class="k2">)</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</div></div><p>

<img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Pascoe)</author>
		<pubDate>Thu, 09 Jul 2015 10:29:58 +0000</pubDate>
	</item>
</rss>
