<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[A5] al_draw_bitmap() vs al_draw_rotated_bitmap()</title>
		<link>http://www.allegro.cc/forums/view/611303</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 27 Oct 2012 01:58:47 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is drawing a bitmap with al_draw_rotated_bitmap() with rotation 0 as &quot;expensive&quot; as drawing a bitmap with al_draw_bitmap()?</p><p>Same with drawing a scaled bitmap with 1:1 scale factor, is that the same thing as drawing just the bitmap or is it more expensive since scale calculations are made?</p><p>Or short question: Could we always use al_draw_tinted_scaled_rotated_bitmap_region() or should we ONLY use that when we want to draw a tinted, scaled, rotated section of a bitmap? <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeaRDoWN)</author>
		<pubDate>Mon, 22 Oct 2012 18:02:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;d say the difference isn&#39;t noticeable (all those functions internally call the same function).</p><p>If you need something faster you&#39;d use al_draw_prim and draw all your bitmaps with a single call - that can skip a few steps.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 22 Oct 2012 19:36:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So one could use any of the draw bitmap functions to draw a not tinted, rotated scaled region bitmap? Extra calculation time is &quot;nothing&quot; compared with using the simpliest draw bitmap function?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeaRDoWN)</author>
		<pubDate>Mon, 22 Oct 2012 21:08:35 +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/611303/968652#target">TeaRDoWN</a> said:</div><div class="quote"><p> Extra calculation time is &quot;nothing&quot; compared with using the simpliest draw bitmap function?</p></div></div><p>A couple billionths of a second here, a few billionths of a second there, after a hundred of these it adds up to a microsecond every frame!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 22 Oct 2012 21:13:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, so there is a difference. I just thought that if we say used draw_rotated_bitmap with rotation 0 it just did a normal draw_bitmap. But then I&#39;ll keep using all the different draw bitmap function as before.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeaRDoWN)</author>
		<pubDate>Mon, 22 Oct 2012 21:18: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/611303/968654#target">TeaRDoWN</a> said:</div><div class="quote"><p> Ok, so there is a difference.</p></div></div><p>I didn&#39;t look at the source, for all I know the unrotated et. al. functions just stick in some immediate zeros.  My point was that the time it takes is insignificant, being that A5 doesn&#39;t run on 4.77Mhz 8088&#39;s.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 22 Oct 2012 21:20:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Last I heard, <i>all</i> of the al_draw_bitmap variants were implemented with the same underlying &quot;do it all&quot; function.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 23 Oct 2012 04:20:21 +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/611303/968649#target">Elias</a> said:</div><div class="quote"><p>If you need something faster you&#39;d use al_draw_prim and draw all your bitmaps with a single call - that can skip a few steps.</p></div></div><p>
So you&#39;d have a: single sprite sheet, and a whole bunch of ALLEGRO_VERTEX&#39;es, whose u and v are based on the spritesheet? And then you call al_draw_prim with ALLEGRO_PRIM_TRIANGLE_LIST? I guess you would have two triangles per sprite to make a rectangle (and not for example a single triangle encompassing the whole sprite).<br />Sounds like someone should write a library/add-on for that <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (weapon_S)</author>
		<pubDate>Tue, 23 Oct 2012 11:26:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In my experience, there is essentially no <i>noticeable</i> difference in optimization with switching out to the different specific drawing functions or just going with al_draw_tinted_scaled_rotated_bitmap all the time, assuming you&#39;re using hardware acceleration.  At one point I did some profiling and the results supported my hunch.</p><p>In other words, if you&#39;re making a bitmap class, just go straight to al_draw_tinted_scaled_rotated_bitmap, or al_draw_tinted_bitmap wrapped in a transform.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611303/968653#target">Arthur Kalliokoski</a> said:</div><div class="quote"><p>A couple billionths of a second here, a few billionths of a second there, after a hundred of these it adds up to a microsecond every frame!</p></div></div><p>I think the differences are significantly smaller than that.  In fact, I don&#39;t think there are any relevant differences.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611303/968665#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p>Last I heard, all of the al_draw_bitmap variants were implemented with the same underlying &quot;do it all&quot; function.</p></div></div><p>I think this is true.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Tue, 23 Oct 2012 12:48:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No noticeable difference, in fact in theory the &quot;short-hand&quot; should be slower <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /><br />If somebody feels like rewriting the code, there is IIRC one part that is redundant in the unrotated unscaled version and could be removed to &quot;be faster&quot;. It goes something like this:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_identity_transform"><span class="a">al_identity_transform</span></a><span class="k2">(</span>temp<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_rotate_transform"><span class="a">al_rotate_transform</span></a><span class="k2">(</span>temp, rotation<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_scale_transform"><span class="a">al_scale_transform</span></a><span class="k2">(</span>temp, scale<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_compose_transform"><span class="a">al_compose_transform</span></a><span class="k2">(</span>temp, current_transformation<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
But I believe SiegeLord had experimented with something similar with disappointing results (from one perspective <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> ).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (weapon_S)</author>
		<pubDate>Tue, 23 Oct 2012 20:09:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I looked into the sources, and yes, it&#39;s all done through the same function. The underlying is done with two matrix-transformed glTriangles with texture coordinates and color data in them that would form a sprite, hardware accelerated case. So my guess is that it&#39;s just for the sake of convenience. Default arguments or not, for most of the cases you will need to specify most of the arguments if you stick to one single master function. It doesn&#39;t help if you just use 0 or 1 with anything you don&#39;t currently need if there&#39;s like dozen arguments to pass, which is the case.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raidho36)</author>
		<pubDate>Sat, 27 Oct 2012 01:58:47 +0000</pubDate>
	</item>
</rss>
