<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Rotate sprite while using alpha channel</title>
		<link>http://www.allegro.cc/forums/view/591315</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 08 May 2007 22:57:52 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m using Dev-C++ to create a small game, and I&#39;ve had a lil trouble finding out a <i>fast</i> way of rendering this.</p><p>I know that after using set_alpha_blender, I can draw a image onto the buffer with an alpha channel using draw_trans_sprite, but I wanna know if there is anyway of doing this with the rotate_/pivot_ sprite functions?</p><p>One idea I had was to draw to a third buffer the rotated sprite, then draw the alpha channel directly to that as well, but it&#39;s very slow and I can&#39;t use depth with that anymore...</p><p>Oh and hello btw, my first post here, ^_^</p><p> - Evilish
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evilish)</author>
		<pubDate>Tue, 08 May 2007 18:48:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You could create a temporary bitmap, rotate the original bitmap and blit it to the temporary one. Then draw the temporary bitmap onto your buffer with the specified blender.</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>original<span class="k3">=</span><a href="http://www.allegro.cc/manual/load_bitmap" target="_blank"><span class="a">load_bitmap</span></a><span class="k2">(</span>...<span class="k2">)</span><span class="k2">;</span> <span class="c">//15x38</span>
<a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>temp<span class="k3">=</span><a href="http://www.allegro.cc/manual/create_bitmap" target="_blank"><span class="a">create_bitmap</span></a><span class="k2">(</span>max<span class="k2">(</span>original-&gt;w,original-&gt;h<span class="k2">)</span>,
                           max<span class="k2">(</span>original-&gt;w,original-&gt;h<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span> <span class="c">//See below</span>
<a href="http://www.allegro.cc/manual/clear_to_color" target="_blank"><span class="a">clear_to_color</span></a><span class="k2">(</span>temp,<a href="http://www.allegro.cc/manual/bitmap_mask_color" target="_blank"><span class="a">bitmap_mask_color</span></a><span class="k2">(</span>temp<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/rotate_sprite" target="_blank"><span class="a">rotate_sprite</span></a><span class="k2">(</span>temp,original,<span class="n">0</span>,<span class="n">0</span>,angel<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/set_trans_blender" target="_blank"><span class="a">set_trans_blender</span></a><span class="k2">(</span>...<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/draw_trans_sprite" target="_blank"><span class="a">draw_trans_sprite</span></a><span class="k2">(</span>buffer,temp,...<span class="k2">)</span><span class="k2">;</span>

<span class="c">//*if you've never used max, it's just a function that returns</span>
<span class="c">//the higher value of two numbers. So, max(20,44), would return 40</span>
</pre></div></div><p>

For the note, OpenLayer does things like this verrry easily.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ceagon Xylas)</author>
		<pubDate>Tue, 08 May 2007 21:10:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t use max(). Instead, calculate the length of the diagonal of your sprite and use that. Otherwise you might clip the corners off depending on the shape of the sprite!</p><p><span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_738.html" target="_blank">sqrt</a><span class="k2">(</span>sprite-&gt;w<span class="k3">*</span>sprite-&gt;w<span class="k3">+</span>sprite-&gt;h<span class="k3">*</span>sprite-&gt;h<span class="k2">)</span></span></p><p>Then one method you can do is to pre-draw a set of rotations to a bunch of bitmaps, then all you do is choose which of those frames to draw mid-game. Sure, it doesn&#39;t look as smooth as doing the rotations on the fly, but to really get alpha-blended plus rotated quality you should be doing hardware acceleration, either yourself or with Openlayer or AllegroGL.</p><p>You also <u>must</u> be using 32-bit colour bitmaps. Allegro doesn&#39;t support alpha channels in any other colour depth. (However, you might still be able to get away with drawing a 32-bit alpha-blended sprite onto a 15/16/24-bit surface. Just make sure to disable colour conversions when you load the sprites you plan to draw in this fashion, otherwise they will be converted automatically to be 100% compatable with the current screen format, and thus might lose their alpha channel.)</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Tue, 08 May 2007 22:57:52 +0000</pubDate>
	</item>
</rss>
