<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Smooth lines using Primitives addon</title>
		<link>http://www.allegro.cc/forums/view/609347</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 24 Jan 2012 07:01:09 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I need to draw some rounded rectangles and the primitives addon can do that using <b>al_draw_rounded_rectangle</b>. However, the rounded lines are all jagged and not anti-aliased. I have found out that one solution is to enable full-screen anti-aliasing aka multisampling, but that is just not an option for me (other parts of the application need jagged things like for font glyphs and I never draw primitives directly to backbuffer).</p><p>What else can be done? Note, that I can actually do primitive line drawing and anti-aliasing using software/CPU if required, thus using something like Cairo lib is an option, but that would give me quite a large lib just for anti-aliased line support..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (simast)</author>
		<pubDate>Sat, 21 Jan 2012 14:59:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>One option is to offset the coordinates of your rounded rectangle by (+0.5, +0.5), assuming that the coordinates are presumed to be whole numbers.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Sat, 21 Jan 2012 15:05:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If its using OpenGL to render the rounded rectangle, it should be possible to enable anti-aliasing.  Otherwise if its old-style allegro, and just rendering to a bitmap, then you could do your own supersampling on the rounded rectangle only (i.e. render to a larger bitmap, then downscale this in software using a high quality scaling algorithm - though you won&#39;t want to be doing this every frame).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (james_lohr)</author>
		<pubDate>Sat, 21 Jan 2012 18:27: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/609347/945032#target">Mark Oates</a> said:</div><div class="quote"><p>One option is to offset the coordinates of your rounded rectangle by (+0.5, +0.5), assuming that the coordinates are presumed to be whole numbers.</p></div></div><p>

If he disables multi-sampling that wouldn&#39;t help.</p><p>[edit:]</p><p>But what should work is enable multisampling, then draw the things you want to have sharp edges on integer positions only.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sat, 21 Jan 2012 20:11:59 +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/609347/945044#target">Elias</a> said:</div><div class="quote"><p>If he disables multi-sampling that wouldn&#39;t help.</p></div></div><p>Assuming multi-sampling is off, here&#39;s what I&#39;m looking at:</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_rounded_rectangle"><span class="a">al_draw_rounded_rectangle</span></a><span class="k2">(</span><span class="n">100</span>, <span class="n">100</span>, <span class="n">220</span>, <span class="n">180</span>, <span class="n">7</span>, <span class="n">7</span>, <a href="http://www.allegro.cc/manual/al_color_name"><span class="a">al_color_name</span></a><span class="k2">(</span><span class="s">"black"</span><span class="k2">)</span>, <span class="n">1</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">;</span></span><br /><span class="remote-thumbnail"><span class="json">{"name":"605440","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/a\/1ad0bc37de2f717543cb37771e0eb1ec.png","w":266,"h":207,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/a\/1ad0bc37de2f717543cb37771e0eb1ec"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/1/a/1ad0bc37de2f717543cb37771e0eb1ec-240.jpg" alt="605440" width="240" height="186" /></span>
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_draw_rounded_rectangle"><span class="a">al_draw_rounded_rectangle</span></a><span class="k2">(</span><span class="n">100</span><span class="k3">+</span><span class="n">0</span>.<span class="n">5</span>, <span class="n">100</span><span class="k3">+</span><span class="n">0</span>.<span class="n">5</span>, <span class="n">220</span><span class="k3">+</span><span class="n">0</span>.<span class="n">5</span>, <span class="n">180</span><span class="k3">+</span><span class="n">0</span>.<span class="n">5</span>, <span class="n">7</span>, <span class="n">7</span>, <a href="http://www.allegro.cc/manual/al_color_name"><span class="a">al_color_name</span></a><span class="k2">(</span><span class="s">"black"</span><span class="k2">)</span>, <span class="n">1</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
<span class="remote-thumbnail"><span class="json">{"name":"605441","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/3\/b36ae9349539be0a8762b5b7cee73dc2.png","w":266,"h":199,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/3\/b36ae9349539be0a8762b5b7cee73dc2"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/b/3/b36ae9349539be0a8762b5b7cee73dc2-240.jpg" alt="605441" width="240" height="179" /></span></p><p>I interpreted &quot;the rounded lines are all jagged&quot; to mean the jagged roundness of the first one.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Sun, 22 Jan 2012 09:29:06 +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/609347/945031#target">simast</a> said:</div><div class="quote"><p> like for font glyphs
</p></div></div><p>I think you can explicitly turn off loading ttf fonts with anti-aliasing. (Bitmap fonts shouldn&#39;t be a problem.) Draw on &#39;integer positions<span class="ref"><sup>[<a href="#">1</a>]</sup></span>&#39; only, and it should be &#39;hard edge&#39;.
</p><div class="ref-block"><h2>References</h2><ol><li>Whole numbers with an offset of 0.5 to draw in the center of the pixels.</li></ol></div></div>]]>
		</description>
		<author>no-reply@allegro.cc (weapon_S)</author>
		<pubDate>Mon, 23 Jan 2012 01:36:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think the latter one of Mark&#39;s rectangles looks very good. If you want something smoother, try to draw such rectangle with any graphic editor and show us how you like it to be.</p><p>I&#39;ve drawn smooth circles and arcs like this:<br /><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/b/c/bcf39de89e6f46791923f0c828c76bd8.png" alt="605447" width="112" height="106" /><br />The routine goes through all pixels in the bounding square of a circle (or an arc) and measures the distance to the center. The blackness or opacity of the contour is determined by how much it&#39;s off the radius.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Mon, 23 Jan 2012 03:43:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the feedback guys,</p><p>Mark Oates suggestion of 0.5 offsets does help with making the rectangle a bit more rounded (as illustrated). As for line anti-aliasing, I am kind of postponing the idea until I really need this done and, instead of Cairo, I was thinking maybe it&#39;s worth going for platform specific code - like Win32 GDI+ line drawing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (simast)</author>
		<pubDate>Mon, 23 Jan 2012 16:34:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I do want to reiterate this, if this works for you:</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/609347/945035#target">James Lohr</a> said:</div><div class="quote"><p> If its using OpenGL to render the rounded rectangle, it should be possible to enable anti-aliasing.</p></div></div><p>You&#39;d do:</p><div class="source-code snippet"><div class="inner"><pre>glEnable<span class="k2">(</span>GL_LINE_SMOOTH<span class="k2">)</span><span class="k2">;</span>
glEnable<span class="k2">(</span>GL_POLYGON_SMOOTH<span class="k2">)</span><span class="k2">;</span>

<span class="c">//Draw primitives</span>

glDisable<span class="k2">(</span>GL_LINE_SMOOTH<span class="k2">)</span><span class="k2">;</span>
glDisable<span class="k2">(</span>GL_POLYGON_SMOOTH<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 24 Jan 2012 07:01:09 +0000</pubDate>
	</item>
</rss>
