我正在努力让opengl三角形条显示为线框。我的显示算法如下所示:
// want to display by strip here to allow for quick processing of each of the polygons that we need
// allow a quick strip of polygons to be drawn
glBegin(GL_TRIANGLE_STRIP);
// set the triangle strip up for front-facing drawing to allow for clockwise
// glFrontFace(GL_CW);
// cache height / width etc of this element
int height = int(heightField->getHeight()),
width = int(heightField->getWidth());
// want to loop through each row, stopping one from the bottom
for (int y = height -2; y >= 0; --y) {
// we want to circle for each element in the next for loop and counter-clockwise add our vertices to the point
for (int x = 0; x < width - 2; ++x ) {
// http://en.wikipedia.org/wiki/Triangle_strip -- for reference on the element
glVertex3fv(heightField->getVertex(x, y+1));//add the left corner point -- point 1
glVertex3fv(heightField->getVertex(x, y));//add the current point -- point 2
glVertex3fv(heightField->getVertex(x+1, y+1));//add the next point -- point 3
glVertex3fv(heightField->getVertex(x+1, y));//add the 4th point -- point 4
}
}
// end the triangle strip
glEnd();
glDisable(GL_POLYGON_OFFSET_LINE);
基本上,我正在做的是启动 gl_triangle_strip,然后为我的 heightfield 对象中的每个点绘制 x、y、z 坐标。
基本上这画出来的是一个大的白色斑点,我试图只显示不同点的线框。有人对如何做到这一点有任何想法吗?