3

I need to draw the following figure in openGL.

alt text

I tried to do that with polygons like this

glTexCoord2f(0.0f, 0.0f);glVertex3f(9.5f,0,-20);
glTexCoord2f(0.5f, 0.0f);glVertex3f(20,0,-20);
glTexCoord2f(0.0f, 1.0f);glVertex3f(20,0,40);
glTexCoord2f(1.0f, 0.0f);glVertex3f(9.5f,0,40);



glTexCoord2f(0.0f, 0.0f);glVertex3f(9.5f,0,40);
glTexCoord2f(1.0f, 0.0f);glVertex3f(-20,0,40);
glTexCoord2f(0.0f, 1.0f);glVertex3f(-20,0,0);
glTexCoord2f(1.0f, 0.0f);glVertex3f(-3.5f,0,0);
glTexCoord2f(1.0f, 1.0f);glVertex3f(9.5f,0,0);

I didn't get the exact figure, I got the following figure:

alt text

can anyone help??

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Lisa
  • 3,121
  • 15
  • 53
  • 85

1 Answers1

4

Triangulate your input polygon and render the resulting triangles. GL_POLYGON only works on convex polygons.

Alternatively you can use the stencil buffer to render concave polygons.

genpfault
  • 51,148
  • 11
  • 85
  • 139