OpenGL 中奇怪的裁剪问题
我对 OpenGL 非常陌生,所以请耐心等待。 :) 我正在学习 NeHe 的 OpenGL 教程,并且我已经开发了我自己的第 5 课版本,其中您将围绕原点旋转 3D 形状。我不确定我做错了什么,我几乎逐行复制了代码,但我在表面上看到了奇怪的重叠。
有谁对导致此类问题的原因有任何建议吗?
I am very very new to OpenGL, so please bear with me. :) I'm working through NeHe's OpenGL tutorials, and I have developed my own version of Lesson 5, in which you rotate a 3D shape around the origin. I'm not sure what I did wrong, I copied the code nearly line-for-line, but I'm seeing strange overlaps in my surfaces.
Does anyone have any suggestions as to what would cause such an issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对我来说,您似乎缺少启用深度缓冲区或者可能创建带有 z 缓冲区的帧缓冲区。 (这与游吟诗人写的类似)
To me it looks like you are missing enabling the Depth buffer or maybe creating a framebuffer with a z-buffer. (this is similar to what Troubadour is writing)
看来您的深度缓冲区有问题。特别是,看起来每个多边形的绘制都与深度无关,即来自多边形的每个片段都通过了深度测试。这意味着多边形只是按照它们渲染的顺序相互绘制。
禁用了对深度缓冲区的写入
您是否
?如果不是这样,那么您是否记得在每帧开始时清除深度缓冲区? Nehe 教程首先
清除深度和颜色缓冲区。确保您没有删除其中的
GL_DEPTH_BUFFER_BIT
部分。华泰
Looks like you've got an issue with the depth buffer. In particular it looks like each polygon is being drawn without regard to depth i.e. each fragment coming from the polygons is passing the depth test. This would mean that the polygons are simply drawn over each other in whatever order they happen to be rendered in.
Did you disable writing to the depth buffer with something like
by any chance?
If it's not that then did you remember to clear the depth buffer at the beginning of each frame? The Nehe tutorial starts with
which clears both the depth and colour buffers. Make sure you haven't got rid of the
GL_DEPTH_BUFFER_BIT
part of that.HTH
哇,用一行就完全修复了它:
我不知道它是做什么的,但我使用的任何教程中都没有提到它,但我的演示现在工作得很好。去谷歌看看它做了什么。 :D
Wow, completely fixed it with one line:
I have no idea what it does, but it wasn't mentioned in any tutorials I used, but my demo works perfectly now. Off to Google to figure out what that did. :D