<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>speeding up mandelbrot fractal creation</title>
		<link>http://www.allegro.cc/forums/view/615551</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 17 Jul 2015 19:12:44 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am using Allegro 5 on Ubuntu 14.04. I am creating the Mandelbrot fractal on a 1333 x 1000 display, and a bitmap of the same size.  I lock the bitmap, issue 273248 calls to al_put_pixel with color black (background is white), unlock the bitmap, and flip the display.  The resulting display is fine, but the timing is not so good compared to SDL2:</p><p>time on Allegro 5:  3.8 seconds<br />time on SDL2     :  0.15 seconds</p><p>I would appreciate advice on how to speed up the Allegro version, and also can Allegro take advantage of my Nvidia Fermi architecture graphics card?</p><p>Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dougt719)</author>
		<pubDate>Thu, 16 Jul 2015 21:16:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There are several techniques that allow you to speed up allegro drawing.</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_lock_bitmap"><span class="a">al_lock_bitmap</span></a></span><br />1. Lock your target bitmap before drawing to it, and unlock it when done.<br />   A. Lock only the region you need. The smaller the better.<br />   B. Lock it write only if you can. This prevents the download of the texture from the gpu</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_prim"><span class="a">al_draw_prim</span></a></span><br />2. Draw using the primitives addon. Depends on what you&#39;re doing, but batch drawing helps speed things up for example if you have an <span class="source-code">ALLEGRO_PRIM_POINT_LIST</span>.</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_hold_bitmap_drawing"><span class="a">al_hold_bitmap_drawing</span></a></span><br />3. Hold your bitmap drawing. This is useful when all graphics being drawn are on the same texture in the gpu.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 17 Jul 2015 00:40:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the reply.  I am using al_lock_bitmap, and will try the other suggestions soon.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dougt719)</author>
		<pubDate>Fri, 17 Jul 2015 02:34:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>mandelbrot is computed per-pixel, thus a shader would probably be the fastest way.</p><p><a href="http://learningwebgl.com/lessons/example01/">http://learningwebgl.com/lessons/example01/</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Fri, 17 Jul 2015 04:37:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There are two ways to do it using <span class="source-code"><a href="http://www.allegro.cc/manual/al_lock_bitmap"><span class="a">al_lock_bitmap</span></a></span> as well.</p><p>1. Lock bitmap in desired format</p><p>2. Option A. Let allegro draw using <span class="source-code"><a href="http://www.allegro.cc/manual/al_put_pixel"><span class="a">al_put_pixel</span></a></span> or <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_pixel"><span class="a">al_draw_pixel</span></a></span>.</p><p>2. Option B. Draw directly to the locked bitmap using memory access through <span class="source-code">locked_region-&gt;data</span>. See <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_LOCKED_REGION"><span class="a">ALLEGRO_LOCKED_REGION</span></a></span> and <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_PIXEL_FORMAT"><span class="a">ALLEGRO_PIXEL_FORMAT</span></a></span>.</p><p>3. Unlock bitmap
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 17 Jul 2015 04:49:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_draw_pixel() is generally the faster of the two, I&#39;ve found.</p><p>al_draw_prim() is the best option here though.  This lets you build up the points in memory and send them to the GPU all at once so the whole thing is blazing fast.</p><p>Directly working with the screen at the pixel level is a thing of the past.  You need different techniques with modern hardware. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Pascoe)</author>
		<pubDate>Fri, 17 Jul 2015 19:12:44 +0000</pubDate>
	</item>
</rss>
