<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Can&#39;t enumerate fullscreen modes before a display is created</title>
		<link>http://www.allegro.cc/forums/view/615361</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 17 May 2015 00:55:59 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am doing a little testing of some stuff, and I can&#39;t enumerate the fullscreen display modes on my laptop before creating a display. If I call this code after I create a display it runs fine no problem.
</p><div class="source-code snippet"><div class="inner"><pre>   <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"Fullscreen modes :\n"</span><span class="k2">)</span><span class="k2">;</span>
   <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> i <span class="k3">=</span> <span class="n">0</span> <span class="k2">;</span> i <span class="k3">&lt;</span> <a href="http://www.allegro.cc/manual/al_get_num_display_modes"><span class="a">al_get_num_display_modes</span></a><span class="k2">(</span><span class="k2">)</span> <span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>i<span class="k2">)</span> <span class="k2">{</span>
      <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY_MODE"><span class="a">ALLEGRO_DISPLAY_MODE</span></a> mode<span class="k2">;</span>
      <span class="k1">if</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_display_mode"><span class="a">al_get_display_mode</span></a><span class="k2">(</span>i , <span class="k3">&amp;</span>mode<span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="k3">&amp;</span>mode<span class="k2">)</span> <span class="k2">{</span>
         <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"Mode #%i w,h = %d , %d , format = %d , refresh_rate = %d\n"</span> ,
                i , mode.width , mode.height , mode.format , mode.refresh_rate<span class="k2">)</span><span class="k2">;</span>
      <span class="k2">}</span>
   <span class="k2">}</span>
</pre></div></div><p>

Debugging session :
</p><div class="source-code snippet"><div class="inner"><pre>c:\ctwoplus\progcode\allegro5\test\Multisampling&gt;gdb minfo.exe
Program received <a href="http://www.delorie.com/djgpp/doc/libc/libc_724.html" target="_blank">signal</a> SIGSEGV, Segmentation fault.
<span class="n">0x6f128abe</span> in _al_d3d_get_num_display_modes <span class="k2">(</span>format<span class="k3">=</span>format@entry<span class="k3">=</span><span class="n">0</span>, refresh_rate<span class="k3">=</span>refresh_rate@entry<span class="k3">=</span><span class="n">0</span>, flags<span class="k3">=</span><span class="n">0</span><span class="k2">)</span> at C:\mingw\LIBS\A5GIT\allegro\src\win\d3d_disp.cpp:2896
<span class="n">2896</span>          num_modes <span class="k3">=</span> _al_d3d-&gt;GetAdapterModeCount<span class="k2">(</span>adapter, <span class="k2">(</span>D3DFORMAT<span class="k2">)</span>d3d_formats<span class="k2">[</span>j<span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">(</span>gdb<span class="k2">)</span> p _al_d3d
$<span class="n">1</span> <span class="k3">=</span> <span class="k2">(</span>LPDIRECT3D9<span class="k2">)</span> <span class="n">0x0</span>
<span class="k2">(</span>gdb<span class="k2">)</span> bt
<span class="p">#0  0x6f128abe in _al_d3d_get_num_display_modes (format=format@entry=0, refresh_rate=refresh_rate@entry=0, flags=0) at C:\mingw\LIBS\A5GIT\allegro\src\win\d3d_disp.cpp:2896</span>
<span class="p">#1  0x6f11de54 in win_get_num_display_modes () at C:\mingw\LIBS\A5GIT\allegro\src\win\wsystem.c:394</span>
<span class="p">#2  0x0040392e in main ()</span>
<span class="k2">(</span>gdb<span class="k2">)</span>
</pre></div></div><p>

A display hasn&#39;t been created, so the d3d or opengl driver hasn&#39;t been setup yet, but it calls the _al_d3d driver while it is still null and crashes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sat, 09 May 2015 05:03:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ooohh... that&#39;s a nasty regression. Sorry about that... 5.1.11 might come sooner than usual <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sat, 09 May 2015 07:29:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hasn&#39;t this sort of been a lingering design issue? If the driver isn&#39;t set up before creating the display then any functions that rely on it will fail. Which driver to set up though? DX or OGL? That isn&#39;t determined until the display is created, currently.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sat, 09 May 2015 08:36:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think what used to happen is that D3D code would get initialized no matter what, so that function worked for D3D. For OpenGL, no initialization is necessary as far as I can tell.</p><p>The fix for this is to just add a call to the necessary initialization function (or encapsulate it in a singleton-like function call).</p><p>EDIT: Should be fixed as of <a href="http://sourceforge.net/p/alleg/allegro/ci/e0e4c27">http://sourceforge.net/p/alleg/allegro/ci/e0e4c27</a>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 13 May 2015 09:38:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is D3D required then on Windows?</p><p>Here&#39;s another issue - take a look at what happens if I then create an OpenGL window :</p><pre class="terminal scroll">
c:\ctwoplus\progcode\allegro5\test\Multisampling&gt;ms.exe
Monitor info :
Adapter #0 : x1 y1 x2 y2 = 0 0 1280 800
Fullscreen modes :
Mode #0 w,h = 640 , 480 , format = 23 , refresh_rate = 60
Mode #1 w,h = 800 , 600 , format = 23 , refresh_rate = 60
Mode #2 w,h = 1024 , 768 , format = 23 , refresh_rate = 60
Mode #3 w,h = 1280 , 800 , format = 23 , refresh_rate = 60
Mode #4 w,h = 640 , 480 , format = 13 , refresh_rate = 60
Mode #5 w,h = 800 , 600 , format = 13 , refresh_rate = 60
Mode #6 w,h = 1024 , 768 , format = 13 , refresh_rate = 60
Mode #7 w,h = 1280 , 800 , format = 13 , refresh_rate = 60
New window x,y = 2147483647,2147483647
INT_MAX = 2147483647
Fullscreen modes after setting OpenGL display :
Mode #0 w,h = 640 , 480 , format = 0 , refresh_rate = 60
Mode #1 w,h = 640 , 480 , format = 0 , refresh_rate = 60
Mode #2 w,h = 640 , 480 , format = 5 , refresh_rate = 60
Mode #3 w,h = 640 , 480 , format = 5 , refresh_rate = 60
Mode #4 w,h = 640 , 480 , format = 8 , refresh_rate = 60
Mode #5 w,h = 640 , 480 , format = 8 , refresh_rate = 60
Mode #6 w,h = 800 , 600 , format = 0 , refresh_rate = 60
Mode #7 w,h = 800 , 600 , format = 0 , refresh_rate = 60
Mode #8 w,h = 800 , 600 , format = 5 , refresh_rate = 60
Mode #9 w,h = 800 , 600 , format = 5 , refresh_rate = 60
Mode #10 w,h = 800 , 600 , format = 8 , refresh_rate = 60
Mode #11 w,h = 800 , 600 , format = 8 , refresh_rate = 60
Mode #12 w,h = 1024 , 768 , format = 0 , refresh_rate = 60
Mode #13 w,h = 1024 , 768 , format = 0 , refresh_rate = 60
Mode #14 w,h = 1024 , 768 , format = 5 , refresh_rate = 60
Mode #15 w,h = 1024 , 768 , format = 5 , refresh_rate = 60
Mode #16 w,h = 1024 , 768 , format = 8 , refresh_rate = 60
Mode #17 w,h = 1024 , 768 , format = 8 , refresh_rate = 60
Mode #18 w,h = 1280 , 800 , format = 0 , refresh_rate = 60
Mode #19 w,h = 1280 , 800 , format = 5 , refresh_rate = 60
Mode #20 w,h = 1280 , 800 , format = 8 , refresh_rate = 60

c:\ctwoplus\progcode\allegro5\test\Multisampling&gt;</pre><p>

The modes returned by the driver change.</p><p>Edit<br />Oh yeah, and today I was messin around and I managed to come up with an invisible allegro window using <span class="source-code">ALLEGRO_FRAMELESS</span> and <span class="source-code"><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">0</span>,<span class="n">0</span><span class="k2">)</span></span>. It worked with D3D anyway, didn&#39;t try OpenGL, but it could be used to setup a window (and the driver) so you could enumerate the modes available for your intended driver before displaying anything.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sat, 16 May 2015 11:11:51 +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/615361/1013278#target">Edgar Reynaldo</a> said:</div><div class="quote"><p> Is D3D required then on Windows?</p></div></div><p>You can call <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_display_mode"><span class="a">al_get_display_mode</span></a></span> without D3D. If your Allegro comes with both you can force OpenGL via <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_new_display_flags"><span class="a">al_set_new_display_flags</span></a></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sat, 16 May 2015 11:18:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Oh, okay. Wasn&#39;t thinking that <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_new_display_flags"><span class="a">al_set_new_display_flags</span></a></span> could be used to alter the results of <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_display_mode"><span class="a">al_get_display_mode</span></a></span>.</p><p>Edit<br />Yeah, that works.</p><p>How could I compile allegro without DX? Ie, say I wanted to trim down my libs and programs by removing it, how do I do that?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sat, 16 May 2015 11:22:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><span class="k3">-</span>DWANT_D3D<span class="k3">=</span>off</span> should do the trick. Also, just to be clear... what&#39;s wrong with the display modes you&#39;re finding (it&#39;s a bit early here so I&#39;m not quite seeing it)?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sat, 16 May 2015 22:03:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry, miscommunication. All I meant to say is that the number and format of modes differs whether you use D3D or OpenGL to enumerate it. So that makes a difference as to which driver should be in use before a display is created. But as you said, enumerating modes for a specific backend is as simple as calling al_set_new_display_flags. That is not intuitive to me. It seems like more global mystery state.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 17 May 2015 00:23:02 +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/615361/1013295#target">Edgar Reynaldo</a> said:</div><div class="quote"><p> It seems like more global mystery state. </p></div></div><p>In many ways, it is <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />. Anyway, I added a note to the documentation about this.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sun, 17 May 2015 00:55:59 +0000</pubDate>
	</item>
</rss>
