<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[Allegro 5] How to return the current target bitmap?</title>
		<link>http://www.allegro.cc/forums/view/611973</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 02 Feb 2013 02:45:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am making a function which is creating a new bitmap with circle on it, and returning that bitmap. Something like this:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number"> 1</span>function<span class="k2">(</span><span class="k1">int</span> w,<span class="k1">int</span> h,<a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color<span class="k2">)</span>
<span class="number"> 2</span><span class="k2">{</span>
<span class="number"> 3</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> temp <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_bitmap"><span class="a">al_create_bitmap</span></a><span class="k2">(</span>w,h<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 4</span><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span>temp<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 5</span>al_draw_filled_ball<span class="k2">(</span>w<span class="k3">/</span><span class="n">2</span>,h<span class="k3">/</span><span class="n">2</span>,<span class="k2">(</span>w&gt;h<span class="k2">)</span>?<span class="k2">(</span>w<span class="k3">/</span><span class="n">2</span><span class="k2">)</span><span class="k2">:</span><span class="k2">(</span>h<span class="k3">/</span><span class="n">2</span><span class="k2">)</span>,color<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 6</span><span class="k1">return</span> temp<span class="k2">;</span> 
<span class="number"> 7</span><span class="k2">}</span>
</div></div><p>
But then i have an error, because and after i called this function target is non-exciting local bitmap &quot;temp&quot;. I thought of it, and i had an idea. Is there a function which return pointer to current bitmap? Like this:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>function<span class="k2">(</span><span class="k1">int</span> w,<span class="k1">int</span> h,<a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> color<span class="k2">)</span>
<span class="number">  2</span><span class="k2">{</span>
<span class="number">  3</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> current_target_bitmap <span class="k3">=</span> al_magic_function<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> temp <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_bitmap"><span class="a">al_create_bitmap</span></a><span class="k2">(</span>w,h<span class="k2">)</span><span class="k2">;</span>
<span class="number">  5</span><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span>temp<span class="k2">)</span><span class="k2">;</span>
<span class="number">  6</span><span class="k2">(</span>...<span class="k2">)</span>
<span class="number">  7</span><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span>current_target_bitmap<span class="k2">)</span><span class="k2">;</span>
<span class="number">  8</span><span class="k1">return</span> temp<span class="k2">;</span>
</div></div><p>

I couldn&#39;t find that sort of function. Maybe there is other way? The sending display to function is the last help, i really wanna this function to be self-sufficient. <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (mzg147)</author>
		<pubDate>Fri, 01 Feb 2013 23:47:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_get_target_bitmap"><span class="a">al_get_target_bitmap</span></a>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Sat, 02 Feb 2013 00:13:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I call for a vote. I think we should add <span class="source-code">al_magic_function<span class="k2">(</span><span class="k2">)</span></span> to the api.</p><p>What does it/should it do? MAGIC!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sat, 02 Feb 2013 00:58:31 +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/611973/975952#target">mzg147</a> said:</div><div class="quote"><p> <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span>current_target_bitmap<span class="k2">)</span><span class="k2">;</span></span></p></div></div><p>Not sure of I missunderstood something, but doesn&#39;t this do nothing at all?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Sat, 02 Feb 2013 01:43:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="https://www.allegro.cc/forums/thread/611973/975959#target">RPG Hacker</a> said:</div><div class="quote"><p>
Not sure of I missunderstood something, but doesn&#39;t this do nothing at all?
</p></div></div><p>
It is perhaps named poorly. Basically he is making a backup copy of the current target bitmap (pointer), modifying the target bitmap temporarily, and then restoring it to the original form. You need to do this because Allegro 5 doesn&#39;t let you specify the bitmap to draw onto in the same call as you draw. You have to first &quot;select&quot; a bitmap and then draw. This basically means that you either have to always select a target before you draw anywhere, or when you do change the target you have to always make a backup and restore it when you&#39;re finished. <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Sat, 02 Feb 2013 02:32:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, now I see! Stupid me. I completely overlooked the decleration. Thought he did something like</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_target_bitmap"><span class="a">al_get_target_bitmap</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Sat, 02 Feb 2013 02:45:02 +0000</pubDate>
	</item>
</rss>
