gpt4 book ai didi

c++ - 将 GL_TRIANGLE_STRIP 显示为线框

转载 作者:太空宇宙 更新时间:2023-11-04 01:35:39 25 4
gpt4 key购买 nike

我正在努力让 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 坐标。

基本上这画出的是一个大的白色 Blob ,我只是想展示不同点的线框。有人对如何执行此操作有任何想法吗?

最佳答案

glPolygonMode()一个镜头:

glPolygonMode( GL_FRONT, GL_LINE );

关于c++ - 将 GL_TRIANGLE_STRIP 显示为线框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14991756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com