tags:

views:

73

answers:

1

Hey all, 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??

+2  A: 

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
This is probably the only few solutions that is the most practical. I would triangulate as well.
Xavier Ho
Thanks for your answer, I'll go with stencil buffer.
Shaza
Please, can you help here http://stackoverflow.com/questions/2823584/opengl-stencil-buffer-problem-wall-window
Shaza