Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the correct way to draw a distorted plane in OpenGL?
    primarykey
    data
    text
    <p>I've tryed to distort a plane using GL_QUADS, GL_TRIANGLES and GL_POLYGON:</p> <pre><code>glBegin(GL_QUADS); for (int i = 0; i &lt; squareIn.size(); i++) { glNormal3f(0,0,1); glTexCoord2f(squareIn[i]-&gt;v1-&gt;x,squareIn[i]-&gt;v1-&gt;y); glVertex2f(squareOut[i]-&gt;v1-&gt;x,squareOut[i]-&gt;v1-&gt;y); glTexCoord2f(squareIn[i]-&gt;v2-&gt;x,squareIn[i]-&gt;v2-&gt;y); glVertex2f(squareOut[i]-&gt;v2-&gt;x,squareOut[i]-&gt;v2-&gt;y); glTexCoord2f(squareIn[i]-&gt;v3-&gt;x,squareIn[i]-&gt;v3-&gt;y); glVertex2f(squareOut[i]-&gt;v3-&gt;x,squareOut[i]-&gt;v3-&gt;y); glTexCoord2f(squareIn[i]-&gt;v4-&gt;x,squareIn[i]-&gt;v4-&gt;y); glVertex2f(squareOut[i]-&gt;v4-&gt;x,squareOut[i]-&gt;v4-&gt;y); glTexCoord2f(squareIn[i]-&gt;v1-&gt;x,squareIn[i]-&gt;v1-&gt;y); glVertex2f(squareOut[i]-&gt;v1-&gt;x,squareOut[i]-&gt;v1-&gt;y); } glEnd(); </code></pre> <p>But all of them gives this result when I do a extreme distortion:</p> <p><img src="https://i.stack.imgur.com/TWF59.png" alt="Plane distorted"></p> <p>Expected result:</p> <p><img src="https://i.stack.imgur.com/SvSZw.png" alt="Expected result"></p> <p>I saw two possible solutions right now, using glNormal or glMultMatrixf.</p> <p>glNormal apparently look a elegant solution, while glMultMatrixf look complex. But I can't find any code explaining how to calculate glNormals to texture a Plane.</p> <p>Here's <a href="http://www.gamedev.net/topic/419296-skewedsheared-texture-mapping-in-opengl/" rel="nofollow noreferrer">a good example</a> using glMultMatrif.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload