<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>_al_wgl_get_display_mode not returning format</title>
		<link>http://www.allegro.cc/forums/view/611741</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 28 Jan 2013 17:52:56 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>During some implementation of enumerating display modes I accidentally found, that _al_wgl_get_display_mode does not set the format field in ALLEGRO_DISPLAY_MODE... which seems to be by design, but I would suggest to set the format at least to ALLEGRO_PIXEL_FORMAT_ANY to have the field be initialized. </p><p>I put in this code: 
</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="k1">switch</span><span class="k2">(</span>dm.dmBitsPerPel<span class="k2">)</span>
<span class="number">  2</span>   <span class="k2">{</span>
<span class="number">  3</span>   <span class="k1">case</span> <span class="n">32</span><span class="k2">:</span>
<span class="number">  4</span>       mode-&gt;format <span class="k3">=</span> ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA<span class="k2">;</span>
<span class="number">  5</span>       <span class="k1">break</span><span class="k2">;</span>
<span class="number">  6</span>   <span class="k1">case</span> <span class="n">24</span><span class="k2">:</span>
<span class="number">  7</span>       mode-&gt;format <span class="k3">=</span> ALLEGRO_PIXEL_FORMAT_ANY_24_NO_ALPHA<span class="k2">;</span>
<span class="number">  8</span>       <span class="k1">break</span><span class="k2">;</span>
<span class="number">  9</span>   <span class="k1">case</span> <span class="n">16</span><span class="k2">:</span>
<span class="number"> 10</span>       mode-&gt;format <span class="k3">=</span> ALLEGRO_PIXEL_FORMAT_ANY_16_WITH_ALPHA<span class="k2">;</span>
<span class="number"> 11</span>       <span class="k1">break</span><span class="k2">;</span>
<span class="number"> 12</span>   default:
<span class="number"> 13</span>       mode-&gt;format <span class="k3">=</span> format<span class="k2">;</span>
<span class="number"> 14</span>       <span class="k1">break</span><span class="k2">;</span>
<span class="number"> 15</span>   <span class="k2">}</span>
</div></div><p>
so the caller can at least identify the number of bits for the color values of the selected display format. The parameter format is the result of some routine trying to indentify the pixel format - in my case that value was 0, because the format couldn&#39;t be identified.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Thu, 03 Jan 2013 23:35:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just tried ex_display_options, it displays the correct color size (32 in my case). Is there another way to see the problem?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sat, 05 Jan 2013 22:20:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m using something like this
</p><div class="source-code snippet"><div class="inner"><pre>    <span class="k1">const</span> <span class="k1">int</span> n_display_modes <span class="k3">=</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="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>n_display_modes<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>
        <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="k2">;</span>
        <span class="k1">if</span><span class="k2">(</span>addElement<span class="k2">(</span>mode.width, mode.height<span class="k2">)</span><span class="k2">)</span>
        <span class="k2">{</span>
            <span class="k1">if</span><span class="k2">(</span>write_log<span class="k2">)</span>
                gfw_log<span class="k2">(</span><span class="n">2</span>,<span class="n">1</span>, <span class="s">"display mode %d: %d x %d at %d Hz, format %d = %d bits"</span>, i, mode.width, mode.height, mode.refresh_rate, mode.format, <span class="n">8</span><span class="k3">*</span><a href="http://www.allegro.cc/manual/al_get_pixel_size"><span class="a">al_get_pixel_size</span></a><span class="k2">(</span>mode.format<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
        <span class="k2">}</span>
    <span class="k2">}</span>
</pre></div></div><p>
and there it turns out that mode.format is uninitialized, if the current display was created with ALLEGRO_OPENGL. </p><p>Edit: I have modified the proposed change a bit, to only set a format when there&#39;s nothing else set. A patch is attached. </p><p>Another edit: I&#39;ll bump this a last time now, maybe someone is willing to look at it and add it, or tell me that it&#39;s not going to be added and maybe why. <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Thu, 24 Jan 2013 23:09:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey tobing, why don&#39;t you post your patch to the A5 mailing list? You&#39;ll probably get a better response. IDK, maybe, doesn&#39;t hurt.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 25 Jan 2013 01:06:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Maybe worth a try.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Fri, 25 Jan 2013 13:14:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The 24 bit case looks weird, doesn&#39;t it? I&#39;m not familiar with this part of the API though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Mon, 28 Jan 2013 05:30:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m not sure this is helpful, but I&#39;ll say something. When we were first implementing this stuff I noticed this too... IIRC the explanation I got from Milan and/or Elias was that OpenGL displays don&#39;t actually have a color depth (on Windows only?) or that you can&#39;t detect it. I didn&#39;t and still don&#39;t understand that... but I think that&#39;s why it is this way. Not sure if that&#39;s true or not, but it&#39;d be nice to find out so we can do what&#39;s appropriate.</p><p>Your patch seems fine to me but I&#39;m hesitant to apply it because I don&#39;t understand that &quot;doesn&#39;t have a color depth&quot; tidbit I got when I asked a few years ago.</p><p>EDIT: Ah, I think it&#39;s come back to me. They said you can&#39;t get a <i>pixel format</i>, not a color depth. So if that&#39;s the case the patch should be ok.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Mon, 28 Jan 2013 07:33:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, I have tried to find out from the documentation, you can find out the color depth but not the pixel format. That&#39;s where the constants with <u>ANY</u> come in handy. </p><p>Thanks for looking at this.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Mon, 28 Jan 2013 13:12:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve applied your patch. Thanks!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Mon, 28 Jan 2013 13:51:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks from my side. <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Mon, 28 Jan 2013 17:52:56 +0000</pubDate>
	</item>
</rss>
