<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Performance plummets after changing screen mode</title>
		<link>http://www.allegro.cc/forums/view/618255</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 04 Oct 2020 16:36:18 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>After I destroy and recreate the display, my game&#39;s performance goes from about 2 ms per frame to 15+. In the menus, performance drops to around 10 seconds per frame. This made me wonder if it&#39;s the text drawing that has become slow, but increasing the amount of text drawn during the game only has a moderate, rather than disastrous, effect on frame rate.</p><p>I&#39;m reloading all sprites and fonts after each screen mode change. Is there anything else I should be doing?</p><p>Resizing instead of recreating the display does not cause this problem.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Andrew Gillett)</author>
		<pubDate>Fri, 02 Oct 2020 17:18:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Reloading ought to create bitmaps as video bitmaps on the new current display, but my guess is it isn&#39;t for some reason. Can you try <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_bitmap_flags"><span class="a">al_get_bitmap_flags</span></a></span> on any of your bitmaps to check if they are indeed video and not memory bitmaps.<br />Also, as I understand it, <span class="source-code">al_convert_memory_bitmaps</span> should do the conversion without requiring you to reload at all.<br />Finally check that the new display is current when bitmaps are loaded - it should be made current when it is created (remember current display is per-thread) but you could use <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_target_backbuffer"><span class="a">al_set_target_backbuffer</span></a></span> to be sure.<br />If you could create a minimal example that would be useful!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Fri, 02 Oct 2020 17:46:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_convert_memory_bitmaps() isn&#39;t working. Some (or all?) bitmaps remain as memory bitmaps. If I call al_convert_bitmap each time I try to draw a memory bitmap, those bitmaps are converted, but the issue remains.</p><p>EDIT<br />I realised I don&#39;t need to re-create the display to change mode, I just need to call al_resize_display and/or al_set_display_flag(screen, ALLEGRO_FULLSCREEN_WINDOW, !windowed).</p><p>Would I be right in thinking that requesting a particular refresh rate is meaningless for windowed or fullscreen windowed modes?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Andrew Gillett)</author>
		<pubDate>Fri, 02 Oct 2020 18:46:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Does the resizing thing fix your problem now?<br />I don&#39;t know about refresh - it used to be relevant for CRT but modern displays don&#39;t have variable refresh rates?</p><p>I made this little prog:
</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="p">#include &lt;allegro5/allegro.h&gt;</span>
<span class="number">  2</span><span class="p">#include &lt;allegro5/allegro_image.h&gt;</span>
<span class="number">  3</span><span class="p">#include &lt;stdio.h&gt;</span>
<span class="number">  4</span>
<span class="number">  5</span><span class="k1">void</span> wot<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>b<span class="k2">)</span> <span class="k2">{</span>
<span class="number">  6</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>b<span class="k2">)</span> <span class="k3">&amp;</span> ALLEGRO_MEMORY_BITMAP<span class="k2">)</span> <span class="k2">{</span>
<span class="number">  7</span>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"It is a memory bitmap, "</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  8</span>  <span class="k2">}</span> <span class="k1">else</span> <span class="k2">{</span>
<span class="number">  9</span>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"It is not a memory bitmap, "</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 10</span>  <span class="k2">}</span>
<span class="number"> 11</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>b<span class="k2">)</span> <span class="k3">&amp;</span> ALLEGRO_VIDEO_BITMAP<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 12</span>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_631.html" target="_blank">puts</a><span class="k2">(</span><span class="s">"it is a video bitmap"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>  <span class="k2">}</span> <span class="k1">else</span> <span class="k2">{</span>
<span class="number"> 14</span>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_631.html" target="_blank">puts</a><span class="k2">(</span><span class="s">"it is not a video bitmap"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>  <span class="k2">}</span>
<span class="number"> 16</span><span class="k2">}</span>
<span class="number"> 17</span><span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 18</span>  <a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 19</span>  <a href="http://www.allegro.cc/manual/al_init_image_addon"><span class="a">al_init_image_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 20</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>d1 <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="number"> 21</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>b <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">"b.png"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 22</span>  wot<span class="k2">(</span>b<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>  <a href="http://www.allegro.cc/manual/al_destroy_display"><span class="a">al_destroy_display</span></a><span class="k2">(</span>d1<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 24</span>  wot<span class="k2">(</span>b<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 25</span>  d1 <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">320</span>, <span class="n">240</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 26</span>  wot<span class="k2">(</span>b<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 27</span>  <a href="http://www.allegro.cc/manual/al_destroy_bitmap"><span class="a">al_destroy_bitmap</span></a><span class="k2">(</span>b<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 28</span>  <a href="http://www.allegro.cc/manual/al_destroy_display"><span class="a">al_destroy_display</span></a><span class="k2">(</span>d1<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 29</span>
<span class="number"> 30</span>  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 31</span><span class="k2">}</span>
</div></div><p>
on mac this does convert the bitmap to a memory bitmap and back. Does it work for you?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Sat, 03 Oct 2020 19:24:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, resizing the window or switching between window and fullscreen window fixes the issue. Your code example works. However, I&#39;m not sure the issue I was having has anything to do with any bitmaps I&#39;ve created myself, as it only manifested in the menus, where only text is being drawn.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Andrew Gillett)</author>
		<pubDate>Sun, 04 Oct 2020 16:36:18 +0000</pubDate>
	</item>
</rss>
