本文介绍了在OpenGL ES 2.0中,如何绘制三角形的线框(除了相邻共面面上的线以外)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我隐约记得在OpenGL中看到的某些东西(不是ES,当我遇到它时iPhone上仍为v1.0,这就是为什么我从未使用过它)让我指定了多边形的哪些边被视为轮廓与那些构成脸部内部的东西相比.因此,这与整个模型的轮廓(我知道该怎么做)并不相同,而是一个平面的轮廓,其所有三叉戟基本上都混入了一个多边形中.例如,在由tri组成的立方体中,每个面实际上是两个tris.我要绘制正方形的轮廓,而不是整个表面的对角线.六角形也一样.这需要四个Tris,但脸部只有一个轮廓.

I vaguely remember seeing something in OpenGL (not ES, which was still at v1.0 on the iPhone when I came across this, which is why I never used it) that let me specify which edges of my polygons were considered outlines vs those that made up the interior of faces. As such, this isn't the same as the outline of the entire model (which I know how to do), but rather the outline of a planar face with all its tris basically blended into one poly. For instance, in a cube made up of tri's, each face is actually two tris. I want to render the outline of the square, but not the diagonal across the face. Same thing with a hexagon. That takes four tris, but just one outline for the face.

现在是的,我知道我可以简单地测试所有边缘以查看它们是否共享共面,但是我可能发誓我记得在定义三重网格数据时看到的某个地方,您可以说这条线勾勒出一个脸,而这是一张脸."这样,在渲染时,您可以设置一个标志,该标志基本上说:给我一个线框,但是只给完整面的边缘周围的线,而不是组成它们的三角形周围的线."

Now yes, I know I can simply test all the edges to see if they share coplanar faces, but I could have sworn I remember seeing somewhere when you're defining the tri mesh data where you could say 'this line outlines a face whereas this one is inside a face.' That way when rendering, you could set a flag that basically says 'Give me a wireframe, but only the wires around the edges of complete faces, not around the tris that make them up.'

顺便说一句,我的目标是所有支持OpenGL ES 2.0的平台,但我的开发平台是iOS.同样,我非常确定该像素最初是在OpenGL中使用的,一旦着色器出现在场景中,它可能已贬值,但是我什至找不到该功能的参考来检查是否是这种情况.

BTW, my target is all platforms that support OpenGL ES 2.0 but my dev platform is iOS. Again, this Im pretty sure was originally in OpenGL and may have been depreciated once shaders came on the scene, but I can't even find a reference to this feature to check if that's the case.

我现在唯一知道的方法是拥有一组顶点,但是有两组独立的索引...一组用于渲染tris,另一组用于渲染面的线框.这是一个真正的痛苦,因为我最终手动编码了很多代码,这再次使我99%确信可以在渲染线条时定义.

The only way I know now is to have one set of vertices, but two separate sets of indices... one for rendering tris, and another for rendering the wireframes of the faces. It's a real pain since I end up hand-coding a lot of this, which again, I'm 99% sure you can define when rendering the lines.

推荐答案

OpenGL ES不支持GL_QUADS,glEdgeFlag和glPolygonMode.

GL_QUADS, glEdgeFlag and glPolygonMode are not supported in OpenGL ES.

您可以使用LINES绘制线框:要获取隐藏线,请先绘制黑色填充的三角形(启用DEPTH),然后使用GL_LINES绘制感兴趣的边缘.

You could use LINES to draw the wireframe: To get hidden lines, first draw black filled triangles (with DEPTH on) and then draw the edges you are interested in with GL_LINES.

这篇关于在OpenGL ES 2.0中,如何绘制三角形的线框(除了相邻共面面上的线以外)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 03:03