OpenGL GL_POLYGON_SMOOTH 2D 抗锯齿从四边形中创建三边形
更新:
我在安装 NVIDIA 控制面板时找到了它,如果卸载它,它可以正常工作。
当您在 OpenGL 中旋转四边形时,边缘会变得锯齿状。
如果我调用 glEnable(GL_POLYGON_SMOOTH) 边缘会变得平滑,但 OpenGL 然后会在我的所有图像中绘制一条白色对角线,就好像它正在创建我的四边形的三边形一样。
它看起来是这样的:
有没有办法禁用该行,或者我可以通过其他简单的方式获得抗锯齿功能? 我尝试了 GL_MULTISAMPLE 但什么也没发生。
在我的代码中我还有:
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UPDATE:
I have located it to when I install NVIDIA Control Panel, if I uninstall it it works properly.
When you rotate a quad in OpenGL the edges become jagged.
If I call glEnable(GL_POLYGON_SMOOTH) the edges become smooth, but OpenGL then draws a white diagonal line through all my images as if it's creating trisout of my quads.
This is how it looks:
Is there a way to disable that line, or can I get antialiasing in another easy way?
I tried GL_MULTISAMPLE but nothing happened.
In my code I have also:
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我会将其写为答案,尝试后告诉我是否有效。
GL_TRIANGLE_FAN:如果应用程序指定了一系列顶点v,OpenGL将使用v 0、v 1和v 2渲染三角形;使用 v 0、v 2 和 v 3 的另一个三角形;使用 v 0、v 3 和 v 4 的另一个三角形;等等。如果应用程序指定 n 个顶点,OpenGL 将渲染 n–2 个相连的三角形。
因此,要绘制一个以原点为中心的单位四边形,
现在您可以对其进行与四边形周围使用的相同的变换!希望有帮助!
Ok, I'll write this up as an answer, let me know if it works after trying it out.
GL_TRIANGLE_FAN: If the application specifies a sequence of vertices v, OpenGL renders a triangle using v 0, v 1, and v 2; another triangle using v 0, v 2, and v 3; another triangle using v 0, v 3, and v 4; and so on. If the application specifies n vertices, OpenGL renders n–2 connected triangles.
So to draw a unit quad centered around the origin,
Now you can put the same transformations around this that you used around your quad! Hope that helps!