<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>transparency and scaling</title>
		<link>http://www.allegro.cc/forums/view/586629</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 26 Jul 2006 02:13:35 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I could&#39;ve sworn that I remember seeing this explained in a thread somewhere, but I can&#39;t think of the search word combo I used to get it when I was looking for something not even related to this. Of course. Does anyone know of any efficient ways to add transparency (or translucency, late night) and scaling to a sprite WITHOUT using OpenGL?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kevin Epps)</author>
		<pubDate>Sun, 23 Jul 2006 11:22:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>allegro has trans blender functions.</p><p>else make your own.<br />i&#39;ve written very effecient SSE2 blenders.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A J)</author>
		<pubDate>Sun, 23 Jul 2006 12:48:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>As far as I know, with allegro, you can either use rotate_sprite() or draw_trans_sprite() combined with set_trans_blender().<br />But you cannot display a transluent rotated sprite directly.<br />One solution is to prerender rotated sprites and keep them in memory as BITMAP*s  and then use draw_trans_sprite().
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anto80)</author>
		<pubDate>Sun, 23 Jul 2006 16:48:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>flbend has a faster transparency function, as far as scaling it does fast double scaling. But there&#39;s nothing stopping you mixing the two (scale using allegro then add transparency with fblend).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Sun, 23 Jul 2006 17:32:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I agree that Fblend tends to work faster. But is there a way to scale it first, then fblend_trans without using clear_to_color?</p><p>I would assume you would have to do something like this:
</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>sprite <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>whatever<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span>sprite_buffer <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><a href="http://www.allegro.cc/manual/SCREEN_W" target="_blank"><span class="a">SCREEN_W</span></a>, <a href="http://www.allegro.cc/manual/SCREEN_H" target="_blank"><span class="a">SCREEN_H</span></a><span class="k2">)</span><span class="k2">;</span>

<span class="c">//Drawing Loop</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>sprite_buffer,<span class="n">255</span>,<span class="n">0</span>,<span class="n">255</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/rotate_scaled_sprite" target="_blank"><span class="a">rotate_scaled_sprite</span></a><span class="k2">(</span>sprite_buffer, sprite, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a><span class="k2">(</span>scale<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
fblend_trans<span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, sprite_buffer, <span class="n">0</span>, <span class="n">0</span>, trans_value<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Am I wrong? Is there a more efficient way than that? I would MUCH rather not use the clear_to_color function inside the game loop because it slows down the FPS on older machine (PII, PIII) by 12 FPS.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kevin Epps)</author>
		<pubDate>Sun, 23 Jul 2006 20:10:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>well, you&#39;d be fblending your sprites to the backbuffer before the screen and just doing one blit to the screen, for starters.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Sun, 23 Jul 2006 22:16:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Oh well, yeah, I know about double buffering, etc. My main point of that post was to focus more on the calls to scale and trans the sprite than anything else. I didn&#39;t think that me putting &quot;screen&quot; vs &quot;buffer&quot; would make a difference in my post, since it&#39;s for hypothetical purposes only.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kevin Epps)</author>
		<pubDate>Mon, 24 Jul 2006 00:00:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok. but surely a clear_to_colour() can&#39;t be a bottleneck as it&#39;s just chucking a wad of data to a memory area.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Mon, 24 Jul 2006 03:35:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>BELIEVE ME. It makes a difference. On older computers anyway. My newer computers aren&#39;t affected by it. I&#39;m thinking of just clearing the sprite buffer before I even start the loop, I&#39;ll let you know how it works out.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kevin Epps)</author>
		<pubDate>Tue, 25 Jul 2006 06:15:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
ok. but surely a clear_to_colour() can&#39;t be a bottleneck as it&#39;s just chucking a wad of data to a memory area.
</p></div></div><p>

Nothing&#39;s free <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> Regardless, the clear and clear_to_color functions have an impact on performance depending on how often they are called, especially on older hardware, and for the sake of performance you don&#39;t want to call them when you don&#39;t have to. </p><p>Seriously, you wouldn&#39;t think it&#39;d make much of a difference, but if you&#39;re operating on a ton of sprites and calling the routine a couple hundred times a frame you&#39;ll see a significant improvement by eliminating it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sirocco)</author>
		<pubDate>Tue, 25 Jul 2006 19:46:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Alright, I have it handled. Since the sprite is actually getting larger in size, there&#39;s no need to clear_to_color inside the loop and it works perfectly.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kevin Epps)</author>
		<pubDate>Wed, 26 Jul 2006 02:13:35 +0000</pubDate>
	</item>
</rss>
