<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Draw a textured quad in allegro5</title>
		<link>http://www.allegro.cc/forums/view/614834</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 01 Dec 2014 03:39:25 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,<br />I&#39;m trying to develop a simple &quot;3D engine&quot;, i have already done an algorithm that provide a list of quads to be draw on screen to create a 3d view; the problem is how texturize them.<br />I&#39;m using  al_draw_prim with ALLEGRO_PRIM_TRIANGLE_FAN, but i can&#39;t see how properly set it to get a good textured quad and not this crap:</p><p><a href="http://imgur.com/L3n5KdT"><span class="remote-thumbnail"><span class="json">{"name":"L3n5KdT.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/8\/b800b45cc0a0e8cf867bb06e9754d50c.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/8\/b800b45cc0a0e8cf867bb06e9754d50c"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/b/8/b800b45cc0a0e8cf867bb06e9754d50c-240.jpg" alt="L3n5KdT.png" title="source: imgur.com" width="240" height="180" /></span></a><br />All the vertexes setting are printed in the image.</p><p>Is it possible in Allegro? or i have to use OpenGL?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cecco4)</author>
		<pubDate>Sun, 30 Nov 2014 04:40:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m pretty sure you need to use z values for the vertex locations as well, and rotate them with a matrix, otherwise you&#39;re trying to texture a trapezoid, which causes the effects shown.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 30 Nov 2014 04:49:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/manual/5/allegro_vertex">Allegro manual</a> said:</div><div class="quote"><p>Defines the generic vertex type, with a 3D position, color and texture coordinates for a single texture. <b>Note that at this time, the software driver for this addon cannot render 3D primitives.</b> If you want a 2D only primitive, set z to 0. Note that when you must initialize all members of this struct when you&#39;re using it. One exception to this rule are the u and v variables which can be left uninitialized when you are not using textures.</p></div></div><p>
Can this be a problem?</p><p>Also, i didn&#39;t find any example of al_draw_prim using the z value <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cecco4)</author>
		<pubDate>Sun, 30 Nov 2014 05:05:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>These functions will help you get started:</p><p><a href="http://alleg.sourceforge.net/a5docs/refman/transformations.html#al_perspective_transform">al_perspective_transform</a><br /><a href="http://alleg.sourceforge.net/a5docs/refman/transformations.html#al_set_projection_transform">al_set_projection_transform</a></p><p>If you have already calculated the 3D coordinates (x, y, z) for all of your vertices, you should just be able to pass them to <span class="source-code"><a href="http://www.allegro.cc/manual/al_draw_prim"><span class="a">al_draw_prim</span></a><span class="k2">(</span><span class="k2">)</span></span> and let it handle the rest.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sun, 30 Nov 2014 12:07:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A split texture like that makes me think you have the verticies in the wrong order. I think you want to make sure they are in CCW? And I prefer TRIANGLES vs TRIANGLE_FAN or TRIANGLE_STRIP. More data, but easier to process.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 30 Nov 2014 12:10:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
This image shows a trapezoid 2d layout of a brick wall on the left half, and the right half shows a proper rectangular image that&#39;s rotated.</p><p><span class="remote-thumbnail"><span class="json">{"name":"609058","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/6\/268557f9316ad50b613540449d867ad8.png","w":810,"h":629,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/6\/268557f9316ad50b613540449d867ad8"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/2/6/268557f9316ad50b613540449d867ad8-240.jpg" alt="609058" width="240" height="186" /></span></p><p>The program and image (warp.c and brick2.jpg) are in the paperclip.</p><p>[EDIT]</p><p>I left an orthogonal matrix in it (glFrustum on line 124), change it to
</p><div class="source-code snippet"><div class="inner"><pre>  gluPerspective<span class="k2">(</span><span class="n">90</span>.<span class="n">0</span>,<span class="n">4</span>.<span class="n">0</span><span class="k3">/</span><span class="n">3</span>.<span class="n">0</span>,<span class="n">1</span>.<span class="n">0</span>,<span class="n">30</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p> and it&#39;ll look a bit better but the effects still the same.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 30 Nov 2014 15:06:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried to change some z value but it doesn&#39;t affect anything in the texture since i go off-bounds (-1:+1) and it start to disappear:<br />  <a href="http://imgur.com/2TZiPlq"><span class="remote-thumbnail"><span class="json">{"name":"2TZiPlq.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/8\/68ce9eb4c8f8fd2631195afd7a4262f1.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/8\/68ce9eb4c8f8fd2631195afd7a4262f1"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/6/8/68ce9eb4c8f8fd2631195afd7a4262f1-240.jpg" alt="2TZiPlq.png" title="source: imgur.com" width="240" height="180" /></span></a><br />I&#39;m working with Allegro 5.0, i have to upgrade?</p><p>Arthur Kalliokoski&#39;s example works fine but i never used OpenGL and i have some problem with the vertex coordinate. <br />Maybe it&#39;s time to stop procrastinating and start to study it...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cecco4)</author>
		<pubDate>Sun, 30 Nov 2014 18:13:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The parts that exceed -1.0 - 1.0 are &quot;disappearing&quot; because the normal 2D transform has set the viewing frustum near and far values to -1 and 1.  You need to use al_perspective_transform() as Todd Cope said.</p><p>I haven&#39;t learned how to use A5 built in transform stuff myself, but I&#39;ll try to hack on it for 30 minutes to see if I can get it to work as in the OpenGL example above.</p><p>[EDIT]</p><p>AAAaannd I failed to do it.  I was looking at ex_projection.c in the <a href="http://cdn.allegro.cc/file/library/allegro/5.0.8/allegro-5.0.8-extra.zip">examples</a>.  Maybe somebody who knows can help?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 30 Nov 2014 21:27:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I studied a bit openGL and understood the basic coordinate system, however i think i simply need some image manipulation that took the bmp and stretch it in four point.<br />I can do it manually just by taking every columns of the bitmap and resize it to the wall projected height, but it is too slow.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cecco4)</author>
		<pubDate>Sun, 30 Nov 2014 23:31:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The perspective correct texture mapping uses the rotation matrix to do that automatically using several &quot;math chips&quot; at once.  Or should I say it does scan lines per triangle, which the orthographic trapezoid shows where the edges are, but the calculation differs for each triangle.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 30 Nov 2014 23:35:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think <a href="https://www.allegro.cc/forums/thread/613323/990769#target">this</a> can be useful, but i don&#39;t understand the x,y,z used.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cecco4)</author>
		<pubDate>Mon, 01 Dec 2014 03:39:25 +0000</pubDate>
	</item>
</rss>
