GL_QUAD confusion

I have been drawing a simple quad for texture mapping and I have a few questions…

The quad is defined starting in the top left corner, then top right, bottom right and bottom left last.

  1. The quad appears to be drawing in the wrong order. If I remove 1 vertex (and make it a GL_POLYGON) the bottom corner is on the wrong side.

  2. If I change to a GL_QUAD_STRIP there is an indentation in the quad on the left hand side. Isnt this an invalid polygon?? What is causing this?

  3. When texture mapped the image appears backwards? This may be related to the other questions but I am baffled.

If it helps I have been using the OpenGL SuperBible and Visual C++ for this program.

GL_QUAD vertices order is as follows :

  1. top left
  2. bottom left
  3. top right
  4. bottom right

:rolleyes:

GL_QUAD_STRIP vertices order is as follows :

  1. top left
  2. bottom left
  3. top right
  4. bottom right

GL_QUADS vertices order is as follows :

  1. top left
  2. top right
  3. bottom right
  4. bottom left

:rolleyes:

GL_QUAD_STRIP vertices order is as follows :

  1. top left
  2. bottom left
  3. top right
  4. bottom right

GL_QUADS vertices order is as follows :

  1. top left
  2. top right
  3. bottom right
  4. bottom left

:rolleyes:

Ignore the above …

Quads, by default, are defined in a counter-clockwise (CCW) fashion.

It doesn’t matter where you start, as long as the vertices follow the CCW rules.

Thanks, I was just about to reply saying how confused I still was… and I still am.

The problem is still occurring, if I remove the top right vertex function the top left vertex disappears. And the texture map is still backwards

I’m sure the two are related problems and that the answer is a simple one, but at the moment I am at a loss

Before you start removing a vertex from a quad, remember that OpenGL expects 4 coordinates … if you only give it 3 you will see strange effects on the screen.

But try drawing top left, bottom left, bottom right, then top right.

I have the vertices specified in that order at the moment. The code to draw the quad at present is as follows:

glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 1.0f );
glVertex3f( -30.0f, 30.0f, 0.0f );
//top left
glTexCoord2f( 0.0f, 0.0f );
glVertex3f( -30.0f, -30.0f, 0.0f );
//bottom left
glTexCoord2f( 1.0f, 0.0f );
glVertex3f( 30.0f, -30.0f, 0.0f ); //bottom right
glTexCoord2f( 1.0f, 1.0f );
glVertex3f( 30.0f, 30.0f, 0.0f ); //top right
glEnd( );

*you’ll have to excuse the editing this is the 1st time I’ve posted snippets of code

This produces a texture mapped square with the image back to front. If I remove the last vertex( top-right ) and use GL_POLYGON, the top left corner is removed from the image.

what compiler are you using?

either way, if you want to email me the source, i’ll happily look at it for you

What’s your modelview matrix looking like at this point? Maybe a silly question, but are you sure you’re not looking at the back of your quad?

Cheers MikeC!

Your problem is that you’re looking at the quad from the back!

The Z axis DECREASES as you go into the screen, and you’d set up

gluLookAt( locX, locY, locZ, 0.0, 0.0, 0.0, 0.0f, 1.0f, 0.0f );

with locX, locY, locZ as 0,0,-150

which means that the Z coord you where viewing from was behind the QUAD!

Change your locZ to (150) NOT (-150)

[This message has been edited by Shag (edited 11-03-2001).]

[This message has been edited by Shag (edited 11-03-2001).]