Weird GL_QUAD problem

Hi,

If I try and create a textured polygon with the one end squashed, it creates it as if its two triangles with a bad line dividing them.

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -0.5f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 0.5f, 1.0f);
glEnd();

Why does it look like two triangles and how can I create a proper squashed on the one side quad ?

It’s probably because you’re sqaushing the texture at one end. Try changing your texture coords to the following :

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.25f); glVertex3f(-1.0f, -0.5f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.75f); glVertex3f(-1.0f, 0.5f, 1.0f);
glEnd();

This will ‘cut out’ a section of the texture that fits the quad rather than compressing the whole texture at one end to fit.

I do want to squash the texture, but I dont want it to appear as two seperate triangles.

First of all, if the OpenGL implementation triangulates your quad, the way it splits it into triangles is implementation dependant. So you might wan’t to use triangles instead. Secondly, to fix this problem which has to do with the way OpenGL computes the texture coords slopes, you’ll probably have to use the q texture coordinate. See this tutorial.

Yes ! Thanks harsman. That is exactly the tut I needed