How can I do the following drawing in opengl?

I need to draw the following shape in openGL.

alt text

I tried to do this 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 did not get the exact number, I got the following number:

alt text

can anyone help ??

+3
source share
1 answer

Triangulate your input polygon and visualize the resulting triangles. GL_POLYGONonly works with convex polygons.

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

+4
source

Source: https://habr.com/ru/post/1745181/


All Articles