<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[a5] best way to scale/stretch screen?</title>
		<link>http://www.allegro.cc/forums/view/606289</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 03 Feb 2011 10:43:25 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m creating a game where I&#39;m going in the direction of hardcore pixel art. I might even go as far as to run the game in less than 100 * 100 resolution. The thing is, I still want people to make things out on the screen. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /><br />As far as my newly discovered a5 skills go, I have two options:<br />- Use a separate buffer and scale/stretch it when blitting to the Allegro backbuffer<br />- Find the screen resolution before the game starts, and scale every bitmap and every number accordingly.<br />I&#39;m scared of the first one because of the anticipated speed hit, since: 1) It&#39;s scale/stretching a huge bitmap the entire time, and 2) It&#39;s slower drawing things with alpha to memory bitmaps than it is to the backbuffer. I&#39;m scared of the second one because it would require me to use nothing but floats (which in itself makes me cringe) and just sounds like bug city.<br />Is there a magical third option I don&#39;t know about, or is there a better way to do either of the above? <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Thu, 03 Feb 2011 09:17:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There are two main things, which you&#39;ve outlined:
</p><ol><li><p>use a small buffer and scale only the final blit
</p></li><li><p>use a full screen buffer and scale every call
</p></li></ol><p>The first is better for bitmap oriented games. The second is better if you are drawing everything with primitives, because you&#39;ll get higher resolution.</p><p>You can do the latter via the transformation API. Just use (0,0)-(1,1) in your code and set up a transformation that scales by (w,h).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 03 Feb 2011 09:42:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_scale_transform"><span class="a">al_scale_transform</span></a></span><br /><span class="source-code"><a href="http://www.allegro.cc/manual/al_use_transform"><span class="a">al_use_transform</span></a></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 03 Feb 2011 09:43:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><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><span class="k1">float</span> scaleX <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_width"><span class="a">al_get_display_width</span></a><span class="k2">(</span>currentDisplay<span class="k2">)</span><span class="k3">/</span>currentResW<span class="k2">;</span>
<span class="number"> 2</span><span class="k1">float</span> scaleY <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_height"><span class="a">al_get_display_height</span></a><span class="k2">(</span>currentDisplay<span class="k2">)</span><span class="k3">/</span>currentResH<span class="k2">;</span>
<span class="number"> 3</span><a href="http://www.allegro.cc/manual/ALLEGRO_TRANSFORM"><span class="a">ALLEGRO_TRANSFORM</span></a> trans<span class="k2">;</span>
<span class="number"> 4</span><a href="http://www.allegro.cc/manual/al_scale_transform"><span class="a">al_scale_transform</span></a><span class="k2">(</span>trans, scaleX, scaleY<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 5</span><a href="http://www.allegro.cc/manual/al_use_transform"><span class="a">al_use_transform</span></a><span class="k2">(</span>trans<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 6</span><span class="c">//draw as normal?</span>
</div></div><p>
I&#39;m hoping that&#39;s it? Most of what I read in the docs went straight over my head.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Thu, 03 Feb 2011 09:55:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s pretty much it, but watch the integer math in those divisions. You could end up with some non-exact fitting images.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 03 Feb 2011 10:04:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">float</span> scaleX <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_width"><span class="a">al_get_display_width</span></a><span class="k2">(</span>currentDisplay<span class="k2">)</span><span class="k3">/</span><span class="k2">(</span><span class="k1">float</span><span class="k2">)</span>currentResW<span class="k2">;</span>
<span class="k1">float</span> scaleY <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_height"><span class="a">al_get_display_height</span></a><span class="k2">(</span>currentDisplay<span class="k2">)</span><span class="k3">/</span><span class="k2">(</span><span class="k1">float</span><span class="k2">)</span>currentResH<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_TRANSFORM"><span class="a">ALLEGRO_TRANSFORM</span></a> trans<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>trans<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>trans, scaleX, scaleY<span class="k2">)</span><span class="k2">;</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>trans<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 03 Feb 2011 10:10:01 +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/606289/901752#target">Trent Gamblin</a> said:</div><div class="quote"><p>That&#39;s pretty much it, but watch the integer math in those divisions. You could end up with some non-exact fitting images.</p></div></div><p>
You, uh, you lost me there. Does that mean it&#39;s better to do:
</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><span class="k1">float</span> screenWidth <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_width"><span class="a">al_get_display_width</span></a><span class="k2">(</span>currentDisplay<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 2</span><span class="k1">float</span> screenHeight <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_height"><span class="a">al_get_display_height</span></a><span class="k2">(</span>currentDisplay<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 3</span><span class="k1">float</span> floatResW <span class="k3">=</span> currentResW<span class="k2">;</span>
<span class="number"> 4</span><span class="k1">float</span> floatResH <span class="k3">=</span> currentResH<span class="k2">;</span>
<span class="number"> 5</span><span class="k1">float</span> scaleX <span class="k3">=</span> screenWidth<span class="k3">/</span>floatResW<span class="k2">;</span>
<span class="number"> 6</span><span class="k1">float</span> scaleY <span class="k3">=</span> screenHeight<span class="k3">/</span>floatResH<span class="k2">;</span>
<span class="number"> 7</span><a href="http://www.allegro.cc/manual/ALLEGRO_TRANSFORM"><span class="a">ALLEGRO_TRANSFORM</span></a> trans<span class="k2">;</span>
<span class="number"> 8</span><a href="http://www.allegro.cc/manual/al_scale_transform"><span class="a">al_scale_transform</span></a><span class="k2">(</span>trans, scaleX, scaleY<span class="k2">)</span><span class="k2">;</span>
</div></div><p>
?<br />Because if so, then I learned something (else) new today.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Thu, 03 Feb 2011 10:10:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I assume you also need to initialize it to the identity first. See my previous post.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 03 Feb 2011 10:12:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah Matthew nailed it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 03 Feb 2011 10:13:56 +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/606289/901757#target">Matthew Leverton</a> said:</div><div class="quote"><p>I assume you also need to initialize it to the identity first. See my previous post.</p></div></div><p>
Whoa, yeah, that. I also didn&#39;t notice that I shouldn&#39;t be passing trans directly, thanks.
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606289/901755#target">Matthew Leverton</a> said:</div><div class="quote"><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><span class="k1">float</span> scaleX <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_width"><span class="a">al_get_display_width</span></a><span class="k2">(</span>currentDisplay<span class="k2">)</span><span class="k3">/</span><span class="k2">(</span><span class="k1">float</span><span class="k2">)</span>currentResW<span class="k2">;</span>
<span class="number"> 2</span><span class="k1">float</span> scaleY <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_display_height"><span class="a">al_get_display_height</span></a><span class="k2">(</span>currentDisplay<span class="k2">)</span><span class="k3">/</span><span class="k2">(</span><span class="k1">float</span><span class="k2">)</span>currentResH<span class="k2">;</span>
</div></div><p>
</p></div></div><div class="quote_container"><div class="title">Matthew Leverton said:</div><div class="quote"><p><span class="source-code"><span class="k2">(</span><span class="k1">float</span><span class="k2">)</span>currentResH<span class="k2">;</span></span>
</p></div></div><p>
</p><div class="quote_container"><div class="title">Matthew Leverton said:</div><div class="quote"><p><span class="source-code"><span class="k2">(</span><span class="k1">float</span><span class="k2">)</span></span>
</p></div></div><p>
-.- duh. Thanks a ton. <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Thu, 03 Feb 2011 10:17:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>FYI, the attributes to the &lt;quote&gt; and &lt;code&gt; tags are optional and usually not necessary.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 03 Feb 2011 10:29:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>&lt;quote name=&quot;Matthew Leverton&quot;&gt;FYI, the attributes to the </p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606289/901761#target">Matthew Leverton</a> said:</div><div class="quote"><p> and &lt;code&gt; tags are optional and usually not necessary.</p></div></div><p>
Oh, I know. I&#39;m just super OCD and stuff.</p><p>[edit]<br />iseewhatyoudidthere.jpg<br />-_-
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Aaron Santiago)</author>
		<pubDate>Thu, 03 Feb 2011 10:43:25 +0000</pubDate>
	</item>
</rss>
