<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>display adapter #s are different with ALLEGRO_FULLSCREEN_WINDOW</title>
		<link>http://www.allegro.cc/forums/view/612027</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 12 Feb 2013 15:55:35 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have a dual-monitor configuration like this (#s are labeled by Windows and I&#39;m in extended mode).</p><p><span class="remote-thumbnail"><span class="json">{"name":"607222","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/8\/c82e29c2b77b0e33ac259c13aeec3669.png","w":540,"h":263,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/8\/c82e29c2b77b0e33ac259c13aeec3669"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/c/8/c82e29c2b77b0e33ac259c13aeec3669-240.jpg" alt="607222" width="240" height="116" /></span></p><p>When using this layout, ALLEGRO_FULLSCREEN for both monitors flat-out fails. The program goes into some bizarre loop where the screens flicker, then it shows the desktop with the mouse cursor showing loading, and nothing responding to mouse movement.  Then, about every 5 seconds another program/window with &quot;Allegro&quot; appears on the task bar.  This process continues until I abort it.</p><p>Using ALLEGRO_FULLSCREEN_WINDOW on both dispays, the screens flicker from black to desktop about 4 times, and the ALLEGRO_DISPLAY designated for Display 1 (with al_set_new_display_adapter(0)) is on Display 2, and the ALLEGRO_DISPLAY designated for Display 2 (with al_set_new_display_adapter(1)) is on Display 1.</p><p>Is it supposed to do that?  I think there are a few issues happening at the same time, and I&#39;m not isolating things well.  I&#39;m using 5.1.4.  Here&#39;s the basic example code I&#39;m playing around with:</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;iostream&gt;</span>
<span class="number">  3</span>
<span class="number">  4</span>
<span class="number">  5</span><span class="k1">void</span> set_as_target<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>display<span class="k2">)</span>
<span class="number">  6</span><span class="k2">{</span>
<span class="number">  7</span>  <a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_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="number">  8</span><span class="k2">}</span>
<span class="number">  9</span>
<span class="number"> 10</span>
<span class="number"> 11</span><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span> <span class="k3">*</span>argv<span class="k2">[</span><span class="k2">]</span><span class="k2">)</span>
<span class="number"> 12</span><span class="k2">{</span>
<span class="number"> 13</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"> 14</span>
<span class="number"> 15</span>  std::cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <a href="http://www.allegro.cc/manual/al_get_num_video_adapters"><span class="a">al_get_num_video_adapters</span></a><span class="k2">(</span><span class="k2">)</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> std::endl<span class="k2">;</span>
<span class="number"> 16</span>
<span class="number"> 17</span>
<span class="number"> 18</span>
<span class="number"> 19</span>
<span class="number"> 20</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_FULLSCREEN_WINDOW<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 21</span>
<span class="number"> 22</span>  <a href="http://www.allegro.cc/manual/al_set_new_display_adapter"><span class="a">al_set_new_display_adapter</span></a><span class="k2">(</span><span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>display1 <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">1920</span>, <span class="n">1080</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 24</span>
<span class="number"> 25</span>
<span class="number"> 26</span>
<span class="number"> 27</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_FULLSCREEN_WINDOW<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 28</span>
<span class="number"> 29</span>  <a href="http://www.allegro.cc/manual/al_set_new_display_adapter"><span class="a">al_set_new_display_adapter</span></a><span class="k2">(</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 30</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>display2 <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">1920</span>, <span class="n">1080</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 31</span>  <a href="http://www.allegro.cc/manual/al_hide_mouse_cursor"><span class="a">al_hide_mouse_cursor</span></a><span class="k2">(</span>display2<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 32</span>
<span class="number"> 33</span>
<span class="number"> 34</span>
<span class="number"> 35</span>  set_as_target<span class="k2">(</span>display1<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 36</span>  <a href="http://www.allegro.cc/manual/al_clear_to_color"><span class="a">al_clear_to_color</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a><span class="k2">(</span><span class="n">0</span>.<span class="n">1</span>, <span class="n">0</span>.<span class="n">3</span>, <span class="n">0</span>.<span class="n">1</span>, <span class="n">1</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 37</span>  <a href="http://www.allegro.cc/manual/al_flip_display"><span class="a">al_flip_display</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 38</span>
<span class="number"> 39</span>  set_as_target<span class="k2">(</span>display2<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 40</span>  <a href="http://www.allegro.cc/manual/al_clear_to_color"><span class="a">al_clear_to_color</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a><span class="k2">(</span><span class="n">0</span>.<span class="n">1</span>, <span class="n">0</span>.<span class="n">1</span>, <span class="n">0</span>.<span class="n">3</span>, <span class="n">1</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 41</span>  <a href="http://www.allegro.cc/manual/al_flip_display"><span class="a">al_flip_display</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 42</span>
<span class="number"> 43</span>
<span class="number"> 44</span>
<span class="number"> 45</span>  <span class="k1">int</span> i<span class="k2">;</span>
<span class="number"> 46</span>  std::cin <span class="k3">&gt;</span><span class="k3">&gt;</span> i<span class="k2">;</span>
<span class="number"> 47</span><span class="k2">}</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Mon, 11 Feb 2013 12:09:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The allegro display adapter numbers do not necessarily map to the platform&#39;s own display number. But I can probably say that there is <i>something</i> wrong with the windows multimonitor code, I just don&#39;t have a clue what it is. I really don&#39;t know much about that code at all.</p><p>Just because I&#39;m curious, get the geometry for each monitor (location and size) and see if it matches up with what you&#39;re expecting.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 11 Feb 2013 12:29:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For ALLEGRO_FULLSCREEN you must have built Allegro with -DWANT_D3D9EX as a CMake option and must be running Vista or later.</p><p>For the fullscreen windows, I don&#39;t think we&#39;ve come up with anything that detects the display layout properly yet. If you can figure it out, send a patch. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>Also, is it the same thing if you use OpenGL?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Mon, 11 Feb 2013 12:32: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/612027/976610#target">Trent Gamblin</a> said:</div><div class="quote"><p>For the fullscreen windows, I don&#39;t think we&#39;ve come up with anything that detects the display layout properly yet.</p></div></div><p>I&#39;m not sure its doable in a sane way. You can try and guestimate the physical layout, but the hints we&#39;re given by the os just don&#39;t mean a whole heck of a lot. Unless there&#39;s an API I don&#39;t know about that can tell you that Monitor 1 is physically left of Monitor 2. On X with XRandR you can get a monitor&#39;s virtual geometry, but just because it has positive or negative coordinates doesn&#39;t say anything reliable about its real world physical location.</p><p>The most I&#39;ve seen in games is they put the main window on the primary screen (or potentially the screen it was on when it was full-screened), and when you enable multi monitor it lets you configure what goes where.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 11 Feb 2013 14:56:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m not sure if this is at all helpful but a quick Google search brought me to <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162610%28v=vs.85%29.aspx">EnumDisplayMonitors</a>. I have a test coming up so I don&#39;t have a lot of time to mess around, but the following 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="p">#include &lt;iostream&gt;</span>
<span class="number">  2</span><span class="p">#include &lt;Windows.h&gt;</span>
<span class="number">  3</span><span class="p">#include &lt;WinDef.h&gt;</span>
<span class="number">  4</span>
<span class="number">  5</span>BOOL
<span class="number">  6</span>CALLBACK
<span class="number">  7</span>EnumCallback<span class="k2">(</span>
<span class="number">  8</span>    _In_  HMONITOR hMonitor,
<span class="number">  9</span>    _In_  HDC hdcMonitor,
<span class="number"> 10</span>    _In_  LPRECT lprcMonitor,
<span class="number"> 11</span>    _In_  LPARAM dwData
<span class="number"> 12</span><span class="k2">)</span>
<span class="number"> 13</span><span class="k2">{</span>
<span class="number"> 14</span>    std::cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="k2">(</span>DWORD<span class="k2">)</span>hMonitor<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">": Left "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>lprcMonitor-&gt;left<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">" Right "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>lprcMonitor-&gt;right<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">" Top "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>lprcMonitor-&gt;top<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">" Bottom "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>lprcMonitor-&gt;bottom<span class="k3">&lt;</span><span class="k3">&lt;</span>std::endl<span class="k2">;</span>
<span class="number"> 15</span>    <span class="k1">return</span> TRUE<span class="k2">;</span>
<span class="number"> 16</span><span class="k2">}</span>
<span class="number"> 17</span>
<span class="number"> 18</span>
<span class="number"> 19</span><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span> argv<span class="k2">)</span>
<span class="number"> 20</span><span class="k2">{</span>
<span class="number"> 21</span>    EnumDisplayMonitors<span class="k2">(</span>NULL, NULL, EnumCallback, NULL<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 22</span>    <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 23</span><span class="k2">}</span>
</div></div><p>

Generates the output:
</p><div class="source-code snippet"><div class="inner"><pre><span class="n">65537</span><span class="k2">:</span> Left <span class="n">0</span> Right <span class="n">1920</span> Top <span class="n">0</span> Bottom <span class="n">1200</span>
<span class="n">65539</span><span class="k2">:</span> Left <span class="n">1920</span> Right <span class="n">3120</span> Top <span class="k3">-</span><span class="n">470</span> Bottom <span class="n">1450</span>
</pre></div></div><p>
I was hoping that hMonitor is related to the monitor number, but I&#39;m not sure how. Otherwise the rectangles are accurate (I have a primary monitor to the left that is 1920x1200 and one to the right that is 1200x1920 and its top edge is indeed 470 pixels above the other monitor)</p><p>I&#39;ll reiterate and say that I&#39;m not sure if this is at all helpful :X</p><p>EDIT: Out of curiosity I switched the primary monitor to be the one on the right and then I got
</p><div class="source-code snippet"><div class="inner"><pre><span class="n">65537</span><span class="k2">:</span> Left <span class="k3">-</span><span class="n">1920</span> Right <span class="n">0</span> Top <span class="n">470</span> Bottom <span class="n">1670</span>
<span class="n">65539</span><span class="k2">:</span> Left <span class="n">0</span> Right <span class="n">1200</span> Top <span class="n">0</span> Bottom <span class="n">1920</span>
</pre></div></div><p>
So the hMonitor is indeed unrelated to display number, however it appears to still correctly identify the relative location of the displays and their sizes.</p><p>EDIT2: Using the same method Allegro uses (EnumDisplayDevices+EnumDisplaySettings) I&#39;m getting identical results. I&#39;m not really sure if a display device is equivalent to a monitor, but I&#39;m not really sure if that matters. Maybe someone with a problematic system should see if using this alternative method is better? I&#39;m not really sure what the problematic symptoms are.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Slartibartfast)</author>
		<pubDate>Mon, 11 Feb 2013 17:46:44 +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/612027/976612#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p> I don&#39;t know about that can tell you that Monitor 1 is physically left of Monitor 2</p></div></div><p>But is the guestimating done on the &quot;OS-perceived&quot; physical layout? </p><p>I mean...if x-origin of diplay 1 is lower than x-origin of diplay 2 one should quite safely assume that 1 is left of 2. ...the other way around is not really what one should expect.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Mon, 11 Feb 2013 18:33:42 +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/612027/976619#target">Slartibartfast</a> said:</div><div class="quote"><p>So the hMonitor is indeed unrelated to display number, however it appears to still correctly identify the relative location of the displays and their sizes.</p></div></div><p>Only in the virtual screen space. A user could have their actual screens in any location they want.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/612027/976621#target">pkrcel</a> said:</div><div class="quote"><p>But is the guestimating done on the &quot;OS-perceived&quot; physical layout?</p></div></div><p>That is what you&#39;d have to do, as its the only information you have. But Allegro doesn&#39;t do any guestimating afaik.</p><p>The X code just enumerates the displays, and assigns each one an index from an incrementing variable. Each display will get a per session unique index/id, including any hot plugged displays. No single index/id should have been assigned to more than one unique display in a given session.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>I mean...if x-origin of diplay 1 is lower than x-origin of diplay 2 one should quite safely assume that 1 is left of 2. ...the other way around is not really what one should expect.</p></div></div><p>That&#39;s reality for you. The screen space is a virtual space. It bears no relation to reality at all. It may attempt to, but there&#39;s no guarantee it does. We can ignore the fact that it may sometimes not relate to reality, if thats what people want. But of course, users of allegro can do that themselves since we provide display geometry.</p><p>In the past I have setup X display settings where a screen with negative coords was on the right. And similar things.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 12 Feb 2013 06:17:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>But if the monitor is to the right virtually but to the left in reality, won&#39;t that mean that the screen wraps around wrong? So that if I were to move my mouse all the way to the right of the right screen it would come back from the left side of the left screen? That sounds like a very twisted setup.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Slartibartfast)</author>
		<pubDate>Tue, 12 Feb 2013 11:59:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, you can put your earphones on backwards too.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Tue, 12 Feb 2013 13:30:53 +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/612027/976646#target">Slartibartfast</a> said:</div><div class="quote"><p>But if the monitor is to the right virtually but to the left in reality, won&#39;t that mean that the screen wraps around wrong? So that if I were to move my mouse all the way to the right of the right screen it would come back from the left side of the left screen? That sounds like a very twisted setup.</p></div></div><p>It is.</p><p>That said, we don&#39;t really need to care about that case. And looking at the XRandR code (that I wrote a while back), it actually does use the monitor&#39;s reported geometry to calculate positions and sizes when doing modesets, and even has its own notion of RightOf/LeftOf/Above/Below, etc. Something we could potentially export if there was a higher level api for it.</p><p>But yeah. Allegro adapter IDs in X will not match up with X/XRandR display IDs what so ever, for a number of reasons (clones, xrandr using non 0 based identifiers, hotplug, etc). About all we can guarantee there is adapter id&#39;s are unique per session.</p><p>I really don&#39;t know how the windows code works, and in general, (directx) fullscreen modes on windows tend to mess with how things work, so directx&#39;s notion of displays may not match up with windows&#39;s view.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 12 Feb 2013 15:55:35 +0000</pubDate>
	</item>
</rss>
