<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>polygon3d_f errors</title>
		<link>http://www.allegro.cc/forums/view/575921</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 01 Apr 2006 02:38:44 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi, I&#39;m trying to write a portable image viewer, so I thought Allegro would be a good basis for doing this.</p><p>But I am having problems drawing the zoomed image with the polygon3d_f function. When I do the image comes out all garbled, with blank spaces between lines, then the program locks up.</p><p>I can do much the same thing fine when using the stretch_blit function, but stretch_blit only allows integer coordinates for the source region, so it isn&#39;t sufficient.</p><p>I am using Allegro 4.2 with MinGW on Windows XP.</p><p>Heres the code for stretch_blit which works fine:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> rect_image<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span><span class="k1">const</span> src, <span class="k1">const</span> rect_t src_rect, <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span><span class="k1">const</span> dest, <span class="k1">const</span> rect_t dest_rect<span class="k2">)</span>
<span class="k2">{</span>
   <a href="http://www.allegro.cc/manual/stretch_blit" target="_blank"><span class="a">stretch_blit</span></a><span class="k2">(</span>src, dest, src_rect.x1, src_rect.y1,
      src_rect.x2 <span class="k3">-</span> src_rect.x1, src_rect.y2 <span class="k3">-</span> src_rect.y1,
      dest_rect.x1, dest_rect.y1,
      dest_rect.x2 <span class="k3">-</span> dest_rect.x1, dest_rect.y2 <span class="k3">-</span> dest_rect.y1<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
Heres the code for polygon3d_f which is problematic:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> rect_image<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span><span class="k1">const</span> src, <span class="k1">const</span> rect_t src_rect, <a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a> <span class="k3">*</span><span class="k1">const</span> dest, <span class="k1">const</span> rect_t dest_rect<span class="k2">)</span>
<span class="k2">{</span>
   <a href="http://www.allegro.cc/manual/V3D_f" target="_blank"><span class="a">V3D_f</span></a> vertices<span class="k2">[</span><span class="n">4</span><span class="k2">]</span> <span class="k3">=</span> <span class="k2">{</span>
      <span class="k2">{</span>dest_rect.x1, dest_rect.y1, <span class="n">0</span>, src_rect.x1, src_rect.y1, <span class="n">0</span><span class="k2">}</span>,
      <span class="k2">{</span>dest_rect.x2, dest_rect.y1, <span class="n">0</span>, src_rect.x2, src_rect.y1, <span class="n">0</span><span class="k2">}</span>,
      <span class="k2">{</span>dest_rect.x2, dest_rect.y2, <span class="n">0</span>, src_rect.x2, src_rect.y2, <span class="n">0</span><span class="k2">}</span>,
      <span class="k2">{</span>dest_rect.x1, dest_rect.y2, <span class="n">0</span>, src_rect.x1, src_rect.y2, <span class="n">0</span><span class="k2">}</span>
   <span class="k2">}</span><span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/V3D_f" target="_blank"><span class="a">V3D_f</span></a> <span class="k3">*</span>vertex_pointers<span class="k2">[</span><span class="n">4</span><span class="k2">]</span> <span class="k3">=</span> <span class="k2">{</span>
      <span class="k3">&amp;</span><span class="k2">(</span>vertices<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span>, <span class="k3">&amp;</span><span class="k2">(</span>vertices<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span>,
      <span class="k3">&amp;</span><span class="k2">(</span>vertices<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">)</span>, <span class="k3">&amp;</span><span class="k2">(</span>vertices<span class="k2">[</span><span class="n">3</span><span class="k2">]</span><span class="k2">)</span><span class="k2">}</span><span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/polygon3d_f" target="_blank"><span class="a">polygon3d_f</span></a><span class="k2">(</span>dest, <a href="http://www.allegro.cc/manual/POLYTYPE_ATEX" target="_blank"><span class="a">POLYTYPE_ATEX</span></a>, src, <span class="n">4</span>, vertex_pointers<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

And the rect struct:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">typedef</span> <span class="k1">struct</span> <span class="k2">{</span>
   <span class="k1">float</span> x1, y1,
         x2, y2<span class="k2">;</span>
<span class="k2">}</span> rect_t<span class="k2">;</span>
</pre></div></div><p>

Full test code is attached.</p><p>Can anyone tell me what I&#39;m doing wrong here?</p><p>Also could someone explain why polygon3d_f takes an array of pointers to V3D_f rather than just an array of V3D_f?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Druss)</author>
		<pubDate>Fri, 31 Mar 2006 09:30:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What&#39;s the size of the source bitmap? Is the width and height powers of two?</p><p>As a side note, you should probably also pass the rectangles as pointers to rect_image. That&#39;ll keep you from making extra copies of the variables on the stack.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Fri, 31 Mar 2006 12:08:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Arg! That is probably it. I thought it may be something like that, but when looking in the manual my eyes missed it.</p><p>The problem is that power of two BITMAPs isn&#39;t really feasible for my purposes (loading very large, think gigabytes, partitioned images) as expanding the bitmaps to fit will waste a lot of memory which is at a premium.</p><p>I guess I&#39;ll have to write my own drawing function. Maybe modify stretch_blit to take float source geometry.</p><p>Thanks Kitty Cat.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Druss)</author>
		<pubDate>Fri, 31 Mar 2006 12:34:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You mean the destination bitmap needs to span only part of a huge pixel?  You could stretch blit to a huge memory bitmap, then blit from that to the screen.  In other words, the huge pixels would be &quot;splittable&quot; with integer coords.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sat, 01 Apr 2006 02:38:44 +0000</pubDate>
	</item>
</rss>
