<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>A5 setting color depth problem (Linux)</title>
		<link>http://www.allegro.cc/forums/view/614091</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 26 Mar 2014 17:34:20 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m trying to set up a fullscreen mode with the following code:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// Create the display.</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<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_set_new_display_option"><span class="a">al_set_new_display_option</span></a><span class="k2">(</span>ALLEGRO_COLOR_SIZE, bpp, ALLEGRO_REQUIRE<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a><span class="k3">*</span> dpy <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>width, height<span class="k2">)</span><span class="k2">;</span>
<span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>dpy<span class="k2">)</span> <span class="k2">{</span>
  cerr <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\n\nERROR: Couldn't create display!\n"</span><span class="k2">;</span>
  <span class="k1">return</span> <span class="k3">-</span><span class="n">1</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

But it seems to work only when <tt>bpp</tt> is set to 24, and fails for 8 or 16 bits per pixel. I don&#39;t know why, since my graphics card supports 8 &amp; 16 bpp modes and I can run games using these modes. (I&#39;m on Linux BTW.)</p><p>Also when I try to list available modes with Allegro 5 using this code:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// Get the number of available modes.</span>
<span class="k1">int</span> numDisplayModes <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>
cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\nThere are "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> numDisplayModes <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">" modes available:"</span><span class="k2">;</span>

<span class="c">// List them all.</span>
<span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> n <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> n <span class="k3">&lt;</span> numDpyModes<span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>n<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>n, <span class="k3">&amp;</span>mode<span class="k2">)</span><span class="k2">;</span>
  cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\nMode "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> n <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">": "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> mode.width <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">'x'</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> mode.height
       <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">", "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> mode.format <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">" bpp, "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> mode.refresh_rate <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">" Hz"</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

It shows just this:</p><pre>There are 8 modes available:
Mode 0: 1280x800, 0 bpp, 60 Hz
Mode 1: 1280x720, 0 bpp, 59 Hz
Mode 2: 1152x768, 0 bpp, 59 Hz
Mode 3: 1024x768, 0 bpp, 59 Hz
Mode 4: 800x600, 0 bpp, 59 Hz
Mode 5: 848x480, 0 bpp, 59 Hz
Mode 6: 720x480, 0 bpp, 59 Hz
Mode 7: 640x480, 0 bpp, 59 Hz</pre><p>

which is very strange, since all <tt>bpp</tt>s (<tt>format</tt>s) are set to 0.</p><p>What I do wrong? Why cannot Allegro see my bit depths?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (_SasQ_)</author>
		<pubDate>Wed, 26 Mar 2014 14:30:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m not positive, but some video cards will only <i>accelerate</i> graphics in certain color depths.  I used to have an old card with an Intel chip that would only do OpenGL accelerated in 16 bit depth.  X11 doesn&#39;t &quot;have&quot; 32bpp (although the screen does, but X11 won&#39;t admit it) but since it&#39;s only the screen it doesn&#39;t matter for alpha etc.  Maybe Allegro recognizes this and says zero bits per pixel as a default?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 26 Mar 2014 14:38:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, when I ask X11 about available bit depths through Xlib&#39;s <tt>XListDepths</tt> function, it shows &quot;24 1 2 4 8 15 16&quot;. Also when I use games written for SDL or other similar libraries, they offer non-24-bpp color depths without any problem. So I guess this is something specific to Allegro alone.</p><p>What technique does Allegro use to retrieve &amp; change display modes?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (_SasQ_)</author>
		<pubDate>Wed, 26 Mar 2014 14:43:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just looked, and <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> just doesn&#39;t report the format in at all on Linux. That&#39;s just a bit embarrassing.</p><p>In terms of setting the color depth... Allegro uses OpenGL... do the other games you try also use OpenGL?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 26 Mar 2014 16:35:56 +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/614091/998447#target">SiegeLord</a> said:</div><div class="quote"><p>I just looked, and <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> just doesn&#39;t report the format in at all on Linux. That&#39;s just a bit embarrassing.</p></div></div><p>

Yeah... <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>Can you tell me the &quot;coordinates&quot; of where is this function definition in the sources? (filename:line). I&#39;d like to take a look at it too.</p><div class="quote_container"><div class="title">SiegeLord said:</div><div class="quote"><p>Allegro uses OpenGL... do the other games you try also use OpenGL?</p></div></div><p>

Some of them, but not all.<br />I heard that OpenGL can work only with A8R8G8B8 pixels, so it perhaps won&#39;t work with 8 bpp, but I also heard that it can work with 16-bit R5G6B5 pixels (though I might be wrong).</p><p>But isn&#39;t Allegro supposed to be general-purpose graphics library with OpenGL being optional? I remember using some old Allegro version long time ago which wasn&#39;t using OpenGL yet, and it offered different color depths and direct access to video memory buffers (it was on Windows back then, though, so I don&#39;t know how it applied to Linux).</p><p>Suppose I don&#39;t need OpenGL, but simple mode switching, double-buffering, and direct access to video framebuffer pixels to draw something procedurally (where 8-bit pixels with color palette are used for performance reasons). Is Allegro still capable of that? Or should I use some other library?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (_SasQ_)</author>
		<pubDate>Wed, 26 Mar 2014 17:07:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>IIRC, this is a limitation of X Windows. On most X Windows implementations, in general, switching color depths is not possible on a per program basis. The whole X server needs to be restarted.</p><p>In other words, for your game to be portable, it&#39;s better not to ALLEGRO_REQUIRE on the color depth. Don&#39;t worry too much about performance Allegro will convert all bitmaps you load after opening the screen to the screen color depth automagically.</p><p>Also, Allegro 5 is hardware accellerated so you do need either opengl or direct3d to get decent performance.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (beoran)</author>
		<pubDate>Wed, 26 Mar 2014 17:27:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There are a few places the function is implemented. For X11, these are:</p><p>src/x/xfullscreen.c:332<br />src/x/xrandr.c:441</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/614091/998449#target">_SasQ_</a> said:</div><div class="quote"><p> But isn&#39;t Allegro supposed to be general-purpose graphics library with OpenGL being optional?</p></div></div><p>Allegro5 only works with OpenGL and Direct3D. OpenGL is only optional on Windows.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 26 Mar 2014 17:34:20 +0000</pubDate>
	</item>
</rss>
