简体   繁体   English

使用glPrimitiveRestartIndex()进行细分吗?

[英]Tessellation with glPrimitiveRestartIndex()?

I'm trying to draw cube using tessellation and primitive restart index. 我正在尝试使用镶嵌和原始重启索引绘制多维数据集。 With using primitive restart index I can reduce index count down to 17, and draw cube with something like this: 通过使用原始的重新启动索引,我可以将索引计数减少到17,并使用类似以下内容绘制多维数据集:

glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(0xFFFF);
glDrawElements(GL_TRIANGLE_STRIP, 17, GL_UNSIGNED_SHORT, NULL);

So, in this case I'm getting strange results, but drawing cube with 36 indices and GL_TRIANGLES type works just fine. 因此,在这种情况下,我得到的结果很奇怪,但是绘制具有36个索引和GL_TRIANGLES类型的多维数据集效果很好。

How can I use tessellation with glPrimitiveRestartIndex() ? 如何在glPrimitiveRestartIndex()使用镶嵌?

There is exactly one primitive type allowed for tessellation: GL_PATCHES . 细分可以使用一种原始类型: GL_PATCHES So you can't tessellate GL_TRIANGLE_STRIP s. 因此,您无法细分GL_TRIANGLE_STRIP You should have gotten a GL_INVALID_OPERATION error when you rendered. 渲染时应该已经出现GL_INVALID_OPERATION错误。

Every N vertices will be taken as a single patch to be tessellated, where N is defined either by the TCS or by a call to glPatchParameteri(GL_PATCH_VERTICES, N); N个顶点将作为一个单独的面片进行细分,其中N是通过TCS或通过调用glPatchParameteri(GL_PATCH_VERTICES, N); . This is much like GL_TRIANGLES : every 3 vertices is a triangle. 这很像GL_TRIANGLES :每3个顶点是一个三角形。 Each patch is completely separate from every other path. 每个补丁都与其他路径完全分开。 So if N is 4, then drawing 8 vertices will generate 2 patches. 因此,如果N为4,则绘制8个顶点将生成2个面片。

This means that there's really no purpose in using primitive restart with tessellation. 这意味着使用带有细分的原始重启实际上没有任何目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM