<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Draw to second screen to ZOOM 2X</title>
		<link>http://www.allegro.cc/forums/view/611785</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 11 Jan 2013 20:50:09 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I want to draw everything to a non-screen ALLEGRO_BITMAP, then blit it to the screen at twice the size (stretched). How?</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>dpy<span class="k2">;</span>
dpy <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_display"><span class="a">al_create_display</span></a><span class="k2">(</span><span class="n">800</span>, <span class="n">480</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">/* Doen't always actually make it this size... weird bug*/</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>zoom<span class="k2">;</span>
zoom <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_display"><span class="a">al_create_display</span></a><span class="k2">(</span><span class="n">400</span>, <span class="n">240</span><span class="k2">)</span><span class="k2">;</span>

<span class="c">//...</span>
<span class="c">/* blit(source, dest,0,0,0,0,w,h); */</span>
<a href="http://www.allegro.cc/manual/al_draw_bitmap"><span class="a">al_draw_bitmap</span></a><span class="k2">(</span>source,<span class="c">/*NO DEST ,*/</span> w, h,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="c">//...</span>

<a href="http://www.allegro.cc/manual/al_flip_display"><span class="a">al_flip_display</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (No God Mode Required)</author>
		<pubDate>Tue, 08 Jan 2013 19:53:13 +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/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>source <span class="k3">=</span> <span class="c">/* get the bitmap */</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>target <span class="k3">=</span> <span class="c">/* create the bitmap */</span><span class="k2">;</span>

<span class="c">/* blit source to target */</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>target<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_draw_bitmap"><span class="a">al_draw_bitmap</span></a><span class="k2">(</span>source, pointOnTargetX, pointOnTargetY, <span class="n">0</span><span class="k2">)</span><span class="k2">;</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>NULL<span class="k2">)</span><span class="k2">;</span>

<span class="c">/* blit target to screen, stretched */</span>
<a href="http://www.allegro.cc/manual/al_draw_scaled_bitmap"><span class="a">al_draw_scaled_bitmap</span></a><span class="k2">(</span>target, <span class="n">0</span>, <span class="n">0</span>, <a href="http://www.allegro.cc/manual/al_get_bitmap_width"><span class="a">al_get_bitmap_width</span></a><span class="k2">(</span>target<span class="k2">)</span>, <a href="http://www.allegro.cc/manual/al_get_bitmap_height"><span class="a">al_get_bitmap_height</span></a><span class="k2">(</span>target<span class="k2">)</span>, pointOnScreenX, pointOnScreenY, stretchedWidth, stretchedHeight, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Luiji99)</author>
		<pubDate>Tue, 08 Jan 2013 20:48:58 +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/611785/973994#target">Luiji99</a> said:</div><div class="quote"><p>
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span>NULL<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div></div><p>
Don&#39;t you mean <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_backbuffer"><span class="a">al_get_backbuffer</span></a><span class="k2">(</span>display<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></span><img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 08 Jan 2013 22:20:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you really need to draw to the non-screen bitmap first? Its easier (and better) to set up a transformation on the screen and just do normal drawing. If you draw to a different bitmap you will be using FBO&#39;s which is not always the best idea.</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_TRANSFORM"><span class="a">ALLEGRO_TRANSFORM</span></a> transform<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_identity_transform"><span class="a">al_identity_transform</span></a><span class="k2">(</span><span class="k3">&amp;</span>transform<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><span class="k3">&amp;</span>transform, <span class="n">2</span>, <span class="n">2</span><span class="k2">)</span><span class="k2">;</span> <span class="c">// scale x and y by 2</span>
<a href="http://www.allegro.cc/manual/al_use_transform"><span class="a">al_use_transform</span></a><span class="k2">(</span><span class="k3">&amp;</span>transform<span class="k2">)</span><span class="k2">;</span>
.. <span class="k1">do</span> normal drawing ..
</pre></div></div><p>

&lt;edit&gt; Ok I see you want to draw to two screens. It might be simpler just to draw with the identity transform on screen 1 and with a scaled transform on screen 2.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Wed, 09 Jan 2013 01:21:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I want to do two things:</p><p>(1) Make everything 2X as big (16x16 pixel blocks should be 32x32)<br />(2) Have resolution independence (Additional zooming as needed)</p><p>Program LOTS of BITMAPS and zero primitives. I tried the second part of <a href="http://wiki.allegro.cc/index.php?title=Achieving_Resolution_Independence">http://wiki.allegro.cc/index.php?title=Achieving_Resolution_Independence</a> but it just turns the full screen black.</p><p>I thought transforming was bad if not a lot of primitives were used.</p><p>Luiji99&#39;s original code doesn&#39;t work, I will try re-putting it in with Edgar Reynaldo&#39;s addition.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (No God Mode Required)</author>
		<pubDate>Wed, 09 Jan 2013 02:27:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>From talking with other people I think that transformations are the way to go. They are not slower for bitmaps. I recommend it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Wed, 09 Jan 2013 03:06:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, I will use transforms then, they seem to be working.</p><p>How do you get the transformed Screen dimensions from Allegro, or must I have some global variables?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (No God Mode Required)</author>
		<pubDate>Wed, 09 Jan 2013 03:47:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can get the screen dimensions by calling al_get_bitmap_width/height on the current backbuffer.</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span> backbuffer <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_backbuffer"><span class="a">al_get_backbuffer</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_current_display"><span class="a">al_get_current_display</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Wed, 09 Jan 2013 04:13:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There are some advantages to using an explicit secondary buffer instead of transformations. Firstly, primitives will use the correct size pixels. Secondly, if you use fractional positions for bitmaps and other stuff they&#39;ll also be placed correctly. Also a buffer allows you to use a shader to perform the final scaling.</p><p>There&#39;s no question that transforms are faster though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 09 Jan 2013 05:50:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span> backbuffer <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_backbuffer"><span class="a">al_get_backbuffer</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_current_display"><span class="a">al_get_current_display</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></span><br />How is that different from checking the screensize? It gives me the same values (1280x1024) regardless of the transforms I apply, even though I request the screen to be 800x480 on initialization. <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" /></p><p>And what about comparing  the difference between two different transforms, say the current transform and the identity (I think that&#39;s the right term for the transform at initialization)?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (No God Mode Required)</author>
		<pubDate>Wed, 09 Jan 2013 06:35:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Edgar: whoops. I was thinking of a different function...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Luiji99)</author>
		<pubDate>Wed, 09 Jan 2013 13:22:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Other than getting the difference between two transforms (which wasn&#39;t the original question anyway) I think I got it.</p><p>Thanks everyone.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (No God Mode Required)</author>
		<pubDate>Thu, 10 Jan 2013 01:22:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well I&#39;m not a linear algebra expert but a transform is just a 4x4 matrix so in theory you could use some linear algebra operations to compare two matrices.</p><p>What exactly do you want to know about two transformations?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Thu, 10 Jan 2013 01:53:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The scaling difference between the two of them - their ratios to each other.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (No God Mode Required)</author>
		<pubDate>Thu, 10 Jan 2013 05:22:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In general I&#39;m not sure but if you only ever apply a scaling factor to transformations starting from the identity transformation then you can transform a coordinate and use the output to do comparisons.</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_TRANSFORM"><span class="a">ALLEGRO_TRANSFORM</span></a> t1, t2<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_identity_transform"><span class="a">al_identity_transform</span></a><span class="k2">(</span><span class="k3">&amp;</span>t1<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><span class="k3">&amp;</span>t1, <span class="n">2</span>, <span class="n">2</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_identity_transform"><span class="a">al_identity_transform</span></a><span class="k2">(</span><span class="k3">&amp;</span>t2<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><span class="k3">&amp;</span>t2, <span class="n">1</span>.<span class="n">4</span>, <span class="n">1</span>.<span class="n">4</span><span class="k2">)</span><span class="k2">;</span>

<span class="k1">float</span> x1, y1, x2, y2<span class="k2">;</span>
x1 <span class="k3">=</span> y1 <span class="k3">=</span> x2 <span class="k3">=</span> y2 <span class="k3">=</span> <span class="n">1</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_transform_coordinates"><span class="a">al_transform_coordinates</span></a><span class="k2">(</span><span class="k3">&amp;</span>t1, <span class="k3">&amp;</span>x1, <span class="k3">&amp;</span>y1<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_transform_coordinates"><span class="a">al_transform_coordinates</span></a><span class="k2">(</span><span class="k3">&amp;</span>t2, <span class="k3">&amp;</span>x2, <span class="k3">&amp;</span>y2<span class="k2">)</span><span class="k2">;</span>

<a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"scaling factor of t1 is %f\n"</span>, x1<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"scaling factor of t2 is %f\n"</span>, x2<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"scaling ratio between t1 and t2 is %f\n"</span>, x1 <span class="k3">/</span> x2<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

You can tell what the scaling factor is by how much the initial coordinate, x1 or x2, changes after transforming it with the given transformation.</p><p>If you apply any translations or rototations then you can&#39;t use this simple method and things get much more complicated.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kazzmir)</author>
		<pubDate>Thu, 10 Jan 2013 05:46:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks~!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (No God Mode Required)</author>
		<pubDate>Fri, 11 Jan 2013 20:50:09 +0000</pubDate>
	</item>
</rss>
