使用顶点缓冲区对象渲染不同的三角形类型和三角形扇形? (OpenGL)
我的网格中大约有一半使用三角形,另一半使用三角形扇形。 我想将它们卸载到顶点缓冲区对象中,但我不太确定如何执行此操作。三角形扇形都有不同数量的顶点...例如,一个可能有 5 个,另一个可能有 7 个。VBO
使用普通三角形相当简单,但是我不确定如何将它们与三角形扇形或不同的三角形一起使用类型。我相当确定我需要一个索引缓冲区,但我不太确定我需要做什么。
我知道在运行时每个扇形有多少个顶点...我想我可以用它来调用类似 glArrayElement
的东西。
这里的任何帮助将不胜感激!
About half of my meshes are using triangles, another half using triangle fans.
I'd like to offload these into a vertex buffer object but I'm not quite sure how to do this. The triangle fans all have a different number of vertices... for example, one might have 5 and another 7.
VBO's are fairly straight forward using plain triangles, however I'm not sure how to use them with triangle fans or with different triangle types. I'm fairly sure I need an index buffer, but I'm not quite sure what I need to do this.
I know how many vertices make up each fan during run time... I'm thinking I can use that to call something like glArrayElement
Any help here would be much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VBO 和索引缓冲区是一个正交的东西。
如果您尚未使用索引缓冲区,也许一次移动一步更为明智。
所以...关于你的问题。如果您将所有三角形扇形放入 vbo 中,则绘制它们唯一需要的就是设置 vbo 并在其中传递索引以供扇形启动
编辑:我不得不说您可能最好将扇形转换为常规三角形集,并对所有三角形使用
glDrawArrays(GL_TRIANGLES)
。每个原语的调用很少是有效的。VBOs and index buffers are an orthogonal things.
If you're not using index buffers yet, maybe it is wiser to move one step at a time.
So... regarding your question. If you put all your triangle fans in a vbo, the only thing you need to draw them is to setup your vbo and pass the index in it for your fan start
Edit: I'd have to say that you're probably better off transforming your fans to a regular triangle set, and use
glDrawArrays(GL_TRIANGLES)
for all your triangles. A call per primitive is rarely efficient.