<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_flip_display() forces 60fps?</title>
		<link>http://www.allegro.cc/forums/view/614545</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 12 Aug 2014 22:56:17 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So when I ran the piece of code below I noticed that the fps is locked at 60.<br />And I tried forcing vsync off, but it still remained at 60. I know there&#39;s no point in having an fps higher than your refresh rate, but I&#39;m still curious why this happens.</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;allegro5/allegro.h&gt;</span>
<span class="number">  3</span><span class="p">#include &lt;allegro5/allegro_primitives.h&gt;&gt;</span>
<span class="number">  4</span>
<span class="number">  5</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><span class="k3">*</span>argv<span class="k2">)</span> 
<span class="number">  6</span><span class="k2">{</span>
<span class="number">  7</span>    <span class="k1">int</span> frames<span class="k2">;</span>
<span class="number">  8</span>    <span class="k1">double</span> fps, startTime, elapsedTime<span class="k2">;</span>
<span class="number">  9</span>    
<span class="number"> 10</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"> 11</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>
<span class="number"> 12</span>    
<span class="number"> 13</span>    <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>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="n">800</span>, <span class="n">600</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 14</span>    <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> black <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a><span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>
<span class="number"> 16</span>    startTime <span class="k3">=</span> elapsedTime <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_time"><span class="a">al_get_time</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 17</span>    fps <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 18</span>    frames <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 19</span>    
<span class="number"> 20</span>    <span class="k1">while</span><span class="k2">(</span><span class="k1">true</span><span class="k2">)</span>
<span class="number"> 21</span>    <span class="k2">{</span>
<span class="number"> 22</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>black<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</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"> 24</span>      
<span class="number"> 25</span>      frames<span class="k3">+</span><span class="k3">+</span><span class="k2">;</span>
<span class="number"> 26</span>      elapsedTime <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_time"><span class="a">al_get_time</span></a><span class="k2">(</span><span class="k2">)</span> <span class="k3">-</span> startTime<span class="k2">;</span>
<span class="number"> 27</span>      
<span class="number"> 28</span>      fps <span class="k3">=</span> frames<span class="k3">/</span>elapsedTime<span class="k2">;</span>
<span class="number"> 29</span>      std::cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"FPS: "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> fps <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\n"</span><span class="k2">;</span>
<span class="number"> 30</span>    <span class="k2">}</span>
<span class="number"> 31</span>    <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 32</span><span class="k2">}</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gnamra)</author>
		<pubDate>Mon, 11 Aug 2014 23:54:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>1) Where do you set ALLEGRO_VSYNC?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
void al_set_new_display_option(int option, int value, int importance)</p><p>ALLEGRO_VSYNC: Set to <b>1</b> to tell the driver to wait for vsync in al_flip_display, or to <b>2 to force vsync off.</b> The default of <b>0</b> means that Allegro does not try to modify the vsync behavior so it may be on or off.
</p></div></div><p>

2) Is your videocard driver set to force vsync?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Tue, 12 Aug 2014 00:23:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I set al_set_new_display_option(ALLEGRO_VSYNC, 2, ALLEGRO_REQUIRE) before creating the display.</p><p>I&#39;m on kubuntu, I haven&#39;t installed any drivers yet so I&#39;m using &quot;X.Org X server -- Nouveau display driver&quot; whatever that is, and I have no idea how to check if it&#39;s forcing vsync.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gnamra)</author>
		<pubDate>Tue, 12 Aug 2014 00:31:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>According to the source code you just showed us, you are not setting the vsync at all.</p><p>I have used Allegro 5 in my own game and gotten much higher than 60FPS.  Things that have effected it are the event timer settings (or any timer settings which effect speed), and system driver default settings.</p><p>Personally, I usually have my event timer set to 60FPS so it never goes higher, but I have experimented and gotten much more, so in answer to your question, no, <span class="source-code"><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> does not force 60FPS.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Roy)</author>
		<pubDate>Tue, 12 Aug 2014 08:32:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I was just googling it, and it looks like you can enable/disable vsync on nouveau by editing your xorg.conf file.</p><pre>
Section &quot;Device&quot;
    Identifier &quot;nvidia card&quot;
    Driver &quot;nouveau&quot;
    Option &quot;GLXVBlank&quot; &quot;true&quot;
EndSection
</pre><p>

AFAICS, set the fourth line to say
</p><pre>Option &quot;GLXVBlank&quot; &quot;false&quot;</pre><p> (or possibly &quot;off&quot;).</p><p>This xorg.conf file is found in various places, in slackware it&#39;s /etc/X11/xorg.conf, Debian (and possibly xubuntu) has it in </p><pre>/etc/X11/xorg.conf.d/20-nouveau.conf</pre><p>

BTW, could you try the build/examples/ex_gldepth to see if A5 works correctly with the depth buffer yet?  It was messing up a few years ago.</p><p><span class="remote-thumbnail"><span class="json">{"name":"956181f2a4816479000cccded84c63b3.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/5\/956181f2a4816479000cccded84c63b3.png","w":651,"h":505,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/5\/956181f2a4816479000cccded84c63b3"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/9/5/956181f2a4816479000cccded84c63b3-240.jpg" alt="956181f2a4816479000cccded84c63b3.png" width="240" height="186" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Tue, 12 Aug 2014 10:47:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry for the slow reply, I had surgery today and had my gallbladder removed because of gallstones. (I had 9 of them :O)</p><p>@NiteHackr<br />I know I&#39;m not forcing vsync in the piece of code I showed. But like I said earlier I have tried forcing it with al_set_new_display_option(ALLEGRO_VSYNC, 2, ALLEGRO_REQUIRE)</p><p>@Arthur Kalliokoski</p><p>Sure thing, I&#39;ll try to run it a bit later today.</p><p>edit: I ran ex_gldepth and here&#39;s the result:<br /><span class="remote-thumbnail"><span class="json">{"name":"Ed2rN3u.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/3\/931d0037ae3d62dfe2b6393a2a31fdf5.png","w":724,"h":587,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/3\/931d0037ae3d62dfe2b6393a2a31fdf5"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/9/3/931d0037ae3d62dfe2b6393a2a31fdf5-240.jpg" alt="Ed2rN3u.png" width="240" height="194" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gnamra)</author>
		<pubDate>Tue, 12 Aug 2014 22:56:17 +0000</pubDate>
	</item>
</rss>
