Greg Brown
Greg Brown

Reputation: 1299

When rendering using GL_QUADS in OpenGL part of the shape is missing

I am trying to render a square, using GL_QUADS, but every time it renders it has a triangle missing form enter image description here

Here is the code I have:

gl.glPushMatrix();
gl.glBegin(GL.GL_QUADS);
gl.glVertex3d(pts2d.get(0).x, extra[0],pts2d.get(0).y);
gl.glVertex3d(pts2d.get(1).x,extra[0],pts2d.get(1).y);
gl.glVertex3d(pts2d.get(0).x, portalHeight,pts2d.get(0).y);
gl.glVertex3d(pts2d.get(1).x,portalHeight,pts2d.get(1).y);
gl.glEnd();
gl.glPopMatrix();

I am using JOGL, and the points are the correct points to create a square, I just don't know why there is a triangle cut out.

Upvotes: 1

Views: 900

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473262

Note that OpenGL's ordering for quads is not the same ordering as for an equivalent triangle-strip. Here's what I mean.

Four vertices that make up a triangle strip for a quad are specified in this order:

0 2
1 3

Quads are specified in this order:

0 3
1 2

See the difference? It's counter-clockwise (or clockwise, depending on your winding order) around the quad's face. It's not top-to-bottom, left-to-right.

Upvotes: 2

Related Questions