Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 07:12:17 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Drawing texture-mapped planar quadrilaterals in OpenGL
Pages: [1]
Print
Author Topic: Drawing texture-mapped planar quadrilaterals in OpenGL  (Read 5747 times)
Alex May
...is probably drunk right now.
Level 10
*


hen hao wan


View Profile WWW
« on: August 12, 2008, 12:30:35 AM »

Hello, thought I would share this information with you.

Have you ever tried to draw quads on the screen in OpenGL and found that the texture mapping went all wrong? This is because in reality your quad is really two triangles. You probably already know this.

Here is an illustration of the actual results and the desired results.



Top left is the original quad. Top right is the actual result. Bottom left is the desired result. Here is another illustration of the effect ( I took these from the reference page, see the end of the post):

Left is the actual result, and right is the intended result.

Well, the good news is that you can indeed do this without having to use the third dimension at all.

I've run out of time so I'll edit this later.



Essentially you want to do d1/d2 for the fourth texture coordinate which is usually 1. Also your texture coordinate must be multiplied by d1/d2. so texture coords of point d which would normally be (0, u, 0, 1) would now be (0, u * (d1/d2), 0, (d1/d2)).

Note that this technique forces your quad to appear to be in perspective; the spacing of the horizontal lines is non-linear. I haven't worked out how one might achieve a non-perspective distortion.

I got all this information from THIS BLOG which also links to THIS USEFUL PAGE.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic