<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro 5.2.x and Raspberry Pi - failed to create display</title>
		<link>http://www.allegro.cc/forums/view/616797</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 16 Mar 2017 14:55:27 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><p>In my Rasperry Pi project, I&#39;ve just updated from Allegro version 5.1.13 to 5.2.2.  Now however, whenever I call al_create_display() it always returns null.  I also noticed that al_get_num_display_modes() returns 0, not 1 as in version 5.1.13.</p><p>It also fails for allegro 5.2.1.  When I revert to 5.1.13, and rebuild my code, it magically works again (i.e. al_create_display() returns a non-null value and my program can continue ok with it&#39;s graphics output), so I reckon it&#39;s a reasonable assumption that it&#39;s something to do with the Allegro version and not my program or the OS?</p><p>I have tried even with a very simple program (al_init() followed by al_create_display()) and it still doesn&#39;t work.</p><p>I&#39;m using the very latest raspian image from the Raspberry Pi website.</p><p>Anyone else have this problem?</p><p>Thanks in advance,<br />Mike
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (chundermike)</author>
		<pubDate>Wed, 15 Mar 2017 02:56:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Check to make sure the LIBRARY, DLL/SO, and include files are all the same version. It might be using a library in your user folder that you don&#39;t realize. Such as the symbolic links for &quot;Allegro&quot; link to &quot;Allegro 5.1.x&quot;, which is why your old version still works.</p><p>I ran into this issue when trying DAllegro, and I think I&#39;ve hit it before upgrading Allegro minor versions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Wed, 15 Mar 2017 03:16:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><p>Thanks for the response.  I don&#39;t think this is my issue, however - I am working with a completely fresh install (new SD card with latest raspbian, and allegro 5.2.2.0 install), so no old versions of allegro files kicking about...</p><p>The only common files are my program source code, but it&#39;s just cpp, hpp and the Makefile, and again, I&#39;m building from scratch.</p><p>As I said, I then installed and built with Allegro 5.1.13 and it works fine.</p><p>Mike
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (chundermike)</author>
		<pubDate>Wed, 15 Mar 2017 18:44:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Check to see if <span class="source-code"><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> is failing. If it is, you&#39;ve got a library mismatch most likely.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 15 Mar 2017 19:03:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_init() is ok (it&#39;s returning a non-zero value)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (chundermike)</author>
		<pubDate>Wed, 15 Mar 2017 19:38:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What parameters are you passing to al_create_display? By default it creates a window. You may need to pass ALLEGRO_FULLSCREEN or ALLEGRO_FULLSCREEN_WINDOW in order to properly create a screen.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 15 Mar 2017 19:55:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Code snippet attached.  The output I get is...</p><p>al_get_num_display_modes=0<br />Failed to create 1024 x 768 display</p><p>So al_get_monitor_info() fails, presumably because al_get_num_display_modes had returned zero?</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">bool</span> InitAllegro<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number">  2</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</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> Message-&gt;Print<span class="k2">(</span>FATAL, <span class="s">"Failed to initialize Allegro"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  3</span>  <a href="http://www.allegro.cc/manual/al_init_font_addon"><span class="a">al_init_font_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_init_primitives_addon"><span class="a">al_init_primitives_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span> Message-&gt;Print<span class="k2">(</span>FATAL, <span class="s">"Failed to initialize Allegro Primitives addon"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  5</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_init_ttf_addon"><span class="a">al_init_ttf_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span> Message-&gt;Print<span class="k2">(</span>FATAL, <span class="s">"Failed to initialize Allegro TTF addon"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  6</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</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> Message-&gt;Print<span class="k2">(</span>FATAL, <span class="s">"Failed to initialize Allegro Images addon"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  7</span>  myprog_logo_f <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_open_memfile"><span class="a">al_open_memfile</span></a><span class="k2">(</span>myprog_logo_data, MYPROG_LOGO_LEN, <span class="s">"rb"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  8</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>myprog_logo_f<span class="k2">)</span> Message-&gt;Print<span class="k2">(</span>FATAL, <span class="s">"Failed to load logo mem file"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  9</span>
<span class="number"> 10</span>  myprog_font_f <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_open_memfile"><span class="a">al_open_memfile</span></a><span class="k2">(</span>myprog_font_data, MYPROG_FONT_LEN, <span class="s">"rb"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 11</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>myprog_font_f<span class="k2">)</span> Message-&gt;Print<span class="k2">(</span>FATAL, <span class="s">"Failed to load font mem file"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>  
<span class="number"> 13</span>  myprog_font_size <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 14</span>
<span class="number"> 15</span>  <span class="c">// default width and height...</span>
<span class="number"> 16</span>  display_width  <span class="k3">=</span> <span class="n">1024</span><span class="k2">;</span>
<span class="number"> 17</span>  display_height <span class="k3">=</span> <span class="n">768</span><span class="k2">;</span>
<span class="number"> 18</span>
<span class="number"> 19</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_MONITOR_INFO"><span class="a">ALLEGRO_MONITOR_INFO</span></a> monitor<span class="k2">;</span>
<span class="number"> 20</span>  Message-&gt;Print<span class="k2">(</span>DEBUG, <span class="s">"al_get_num_display_modes=%d"</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="k2">;</span>
<span class="number"> 21</span>  <span class="k1">if</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_monitor_info"><span class="a">al_get_monitor_info</span></a><span class="k2">(</span><span class="n">0</span>, <span class="k3">&amp;</span>monitor<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span> <span class="c">// find out current monitor resolution</span>
<span class="number"> 22</span>    display_width  <span class="k3">=</span> monitor.x2 <span class="k3">-</span> monitor.x1<span class="k2">;</span>
<span class="number"> 23</span>    display_height <span class="k3">=</span> monitor.y2 <span class="k3">-</span> monitor.y1<span class="k2">;</span>
<span class="number"> 24</span>    Message-&gt;Print<span class="k2">(</span>NOTE, <span class="s">"Detected display monitor size %dx%d"</span>, display_width, display_height<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 25</span>  <span class="k2">}</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="c">// al_set_new_display_flags(ALLEGRO_FULLSCREEN);</span>
<span class="number"> 29</span>  myprog_display <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="k2">(</span><span class="k1">int</span><span class="k2">)</span>display_width, <span class="k2">(</span><span class="k1">int</span><span class="k2">)</span>display_height<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 30</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>myprog_display<span class="k2">)</span> Message-&gt;Print<span class="k2">(</span>FATAL, <span class="s">"Failed to create %d x %d display"</span>, display_width, display_height<span class="k2">)</span><span class="k2">;</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (chundermike)</author>
		<pubDate>Wed, 15 Mar 2017 20:02:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Pretty sure you can&#39;t get monitor info until you create a display. It&#39;s a quirk of how all operating systems work. The display (a window handle) is how you communicate with all graphics related requests. (Unless you want to support two APIs, one using the display handle, and one using other system calls. IIRC.)</p><p>Maybe I&#39;m wrong.</p><p>[edit] Yep, looks like I&#39;m wrong.</p><p>How about trying this:</p><p>What does:
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/616797/1029002#target">chundermike</a> said:</div><div class="quote"><p>
Detected display monitor size %dx%d
</p></div></div><p>
Output?</p><p>Try adding +1 to each of those width/height values.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Wed, 15 Mar 2017 20:37:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It works fine with Allegro 5.1.13...and also if the get monitor info call fails it doesn&#39;t really matter - it then just tries to create a display with the default values (1024x768), but that fails all the time.</p><p>I&#39;ve tried changing the default values to different numbers (including the actual size of the raspberry pi display given by tvservice) and it still doesn&#39;t work <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" /></p><p>I get none of these issues with allegro 5.1.13.</p><p>If I cahnage the above code to print the detected monitor size regardless of the return value, it says &quot;Detected monitor size 0x0&quot;.</p><p>Adding +1 to the width and height when trying to create the display makes no difference
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (chundermike)</author>
		<pubDate>Wed, 15 Mar 2017 20:43:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just tried your code on my RaspberryPi, and everything worked fine.</p><p>There a few things to note. First, it doesn&#39;t matter what you pass to <span class="source-code"><a href="http://www.allegro.cc/manual/al_create_display"><span class="a">al_create_display</span></a></span> on RaspberryPi, as it will ignore it and simply create a full-screen window with the current mode. There are no windowed displays on RaspberryPi (maybe one day).</p><p>Second, <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_num_display_modes"><span class="a">al_get_num_display_modes</span></a></span> is hardcoded to return 1 on RaspberryPi (<a href="https://github.com/liballeg/allegro5/blob/master/src/raspberrypi/pisystem.c#L136">source</a>). It&#39;s impossible for that backend to return 0.</p><p>It seems like you might have compiled Allegro in its regular Linux mode, did you follow the instructions here: <a href="https://github.com/liballeg/allegro5/blob/master/README_raspberrypi.txt">https://github.com/liballeg/allegro5/blob/master/README_raspberrypi.txt</a> ?.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 16 Mar 2017 08:13:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><p>So if al_get_num_display_modes is hard-coded to return 1, then something is seriously wrong!  I&#39;m 99.9% sure I built the allegro libraries correctly using the correct raspberrypi toolchain file for cmake, but I will try again from scratch; I&#39;ve obviously messed up somewhere.</p><p>Thanks for your help.  I&#39;ll let you know how I get on.</p><p>...all good now - reinstalled everything from scratch and it&#39;s now working.  Not sure why I had problems before.</p><p>Thanks for your help - sorry to waste your time on a problem that didn&#39;t exist...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (chundermike)</author>
		<pubDate>Thu, 16 Mar 2017 14:55:27 +0000</pubDate>
	</item>
</rss>
