我有8个顶点。我想用这个顶点绘制立方体。如何用顶点绘制立方体?
顶点:
v1, v2, v3,v4, v5,v6,v7,v8
they are array of float with 3 elements(float v1[3])
我已经完成了
glBegin(GL_QUADS);
glVertex3f(v1[0], v1 [1], v1[2]);
// do same thing for other 7 vertex
glEnd();
答案 0 :(得分:0)
总结自http://www.wikihow.com/Make-a-Cube-in-OpenGL
现在我们在glBegin()和glEnd()行之间添加顶点。
// Multi-colored side - FRONT
glBegin(GL_POLYGON);
glVertex3f( -0.5, -0.5, -0.5); // P1
glVertex3f( -0.5, 0.5, -0.5); // P2
glVertex3f( 0.5, 0.5, -0.5); // P3
glVertex3f( 0.5, -0.5, -0.5); // P4
glEnd();