How can I draw the following figure in opengl?
I need to draw the following figure in openGL.
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开发者_Python百科);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:
can anyone help??
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.
精彩评论