<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Info for docs - Vsync in different situations with ALLEGRO_SINGLE_BUFFER</title>
		<link>http://www.allegro.cc/forums/view/613908</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 18 Feb 2014 20:31:43 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Because I wanted less latency between user input and displayed changes, I am using ALLEGRO_SINGLE_BUFFER asa new display option.</p><p>On one computer, it worked great (an old intel video card) but on another (an old nvidia card - both in Linux) my program did not work smoothly because al_flip_display() was not waiting for vsync, and my fps was going at over 2000, and this was causing mouse movement events to be delayed/lost.</p><p>Upon further investigation, I found that ALLEGRO_VSYNC,1,ALLEGRO_REQUIRE would fail, however if I used _SUGGEST then it would run, but without vsync holdoff.</p><p>OK - so my video card driver doesn&#39;t support vsync waiting for al_flip_display().</p><p>So then I tried al_wait_for_vsync() just before al_flip_display() then my program runs nice again.</p><p>So I guess my suggested improvements to the documentation would be along these lines:</p><p>Some video card drivers will not allow you to set ALLEGRO_VSYNC as a new display option, in which case al_flip_display() will not wait for vsync but run as fast as your computer can, which can cause lost/delayed allegro events and cpu hogging..</p><p>At current time of this posting, there does not seem to be a way to determine cause of display creation failure, and no way to determine whether the request for ALLEGRO_VSYNC was honored. At some point al_get_display_option(display,ALLEGRO_VSYNC) may be able to be called after the display is created to see if the request was honored.</p><p>So at present there are two approaches: One is to just set ALLEGRO_VSYNC to 2 (disabled) and always call al_wait_for_vsync() before al_flip_display(). The other method is to attempt to create the display  with ALLEGRO_VSYNC,1,ALLEGRO_REQUIRE, and if that fails, then try again with ALLEGRO_VSYNC,2,ALLEGRO_REQUIRE(vsync holdoff disabled) -- and if it succeeds the second time, then your program knows that it needs to call al_wait_for_vsync() before al_flip_display().</p><p>Thanks,</p><p>~Jesse
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jesse Gordon)</author>
		<pubDate>Sat, 15 Feb 2014 07:33:02 +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/613908/996409#target">Jesse Gordon</a> said:</div><div class="quote"><p> Some video card drivers will not allow you to set ALLEGRO_VSYNC as a new display option, in which case al_flip_display() will not wait for vsync but run as fast as your computer can, which can cause lost/delayed allegro events and cpu hogging..</p></div></div><p>Structure your main loop in such a way that you&#39;ll only render when there are no events left to be processed and the viewable state updated. It&#39;s not hard, all the beginner tutorials I&#39;ve seen so far teach you how to. Use <span class="source-code"><a href="http://www.allegro.cc/manual/al_wait_for_event"><span class="a">al_wait_for_event</span></a></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (l j)</author>
		<pubDate>Tue, 18 Feb 2014 11:25: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/613908/996519#target">taron </a> said:</div><div class="quote"><p> It&#39;s not hard, all the beginner tutorials I&#39;ve seen so far teach you how to. Use al_wait_for_event. </p></div></div><p>That type of loop is notable because it&#39;s simple to set up and always works, but it&#39;s not the end-all and be-all of game loops. A loop based on vsync&#39;ing will produce smoother output, but requires gymnastics like the OP described due to hardware differences/Allegro bugs.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 18 Feb 2014 19:24:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A little bit off topic but...are the display properties tustably &quot;inquirable&quot; (is that even a word?) once the window is created? </p><p>I mean, the docs for <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_display_option"><span class="a">al_get_display_option</span></a></span> seem to imply that regarding VSYNC you should not rely on this option alone to tell if Vsyncing is on or off....</p><p>In other words is this following statement true?</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/613908/996409#target">Jesse Gordon</a> said:</div><div class="quote"><p> At some point al_get_display_option(display,ALLEGRO_VSYNC) may be able to be called after the display is created to see if the request was honored.</p></div></div><p>Will and ALLEGRO_REQUIRE always fail if the video card driver overrides the vsync setting?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Tue, 18 Feb 2014 20:31:43 +0000</pubDate>
	</item>
</rss>
