opengl着色器中的多边形细分

发布于 2024-08-18 01:25:07 字数 90 浏览 3 评论 0原文

我想要在 opengl 中渲染 20k+ 2D 多边形,并带有轮廓和轮廓。充满。

有些多边形是凹的。

是否可以使用着色器来做到这一点?

I want 20k+ 2D polygons to be rendered in opengl with outline & fill.

Some polygons are concave.

Is it possible to do this using shaders?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最好是你 2024-08-25 01:25:07

为此,您不需要着色器:

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //Fill
glDrawElements(...);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //Outline
glDrawElements(...);

如果多边形是凹面,您必须手动或使用 gl 实用程序库 glu 对它们进行细分。看看gluNewTess。如果您决定自己对多边形进行细分,则必须记住设置正确的边缘标志,以便不会渲染细分的内部边缘,请参阅glEdgeFlagPointer

编辑:我找到了以下链接 关于如何使用模板缓冲区渲染凹多边形。

You don't need shaders for this:

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //Fill
glDrawElements(...);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //Outline
glDrawElements(...);

If the polygons are concave you'll have to tesselate them, either manually or using the gl utility library, glu. Look at gluNewTess. If you decide to tesselate the polygons yourself you'll have to remember to set the correct edge flags so that the interior edges of the tesselation aren't rendered, see glEdgeFlagPointer.

EDIT: I found the following link on how to use the stencil buffer to render concave polygons.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文