将GL_TRIANGLE_STRIP显示为线框

时间:2013-02-20 23:18:21

标签: c++ c opengl gl-triangle-strip

我正在努力让一个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,然后绘制我的高度域对象中每个点的x,y,z坐标。

基本上这是一个大的白色斑点,我试图只显示不同点的线框。有没有人对如何做到这一点有任何想法?

1 个答案:

答案 0 :(得分:4)

glPolygonMode()一个镜头:

glPolygonMode( GL_FRONT, GL_LINE );