简体   繁体   English

OpenGL ES 2 - 关于深度的noob问题

[英]OpenGL ES 2 - noob question regarding depth

okay i'm kind of new to this 3D math and it was a major milestone was to get the projection & modelview matrices right last night :] 好吧,我对这个3D数学有点新意,这是一个重要的里程碑,就是让昨晚的投影和模型视图矩阵正确:]

so i've got this simple model which renders correctly from this angle: 所以我有这个简单的模型从这个角度正确呈现:

在此输入图像描述

but when i rotate around the y axis, there's something wrong with the depth like this: 但当我围绕y轴旋转时,深度有问题,如下所示:

在此输入图像描述

that might look interesting, but is not what i want currently. 这可能看起来很有趣,但不是我现在想要的。 Basically the depth of these walls get mixed up? 基本上这些墙的深度混在一起?

can someone point me to the necessary steps on how to solve this? 有人能指出我如何解决这个问题的必要步骤吗? i need a depth buffer or something... right? 我需要一个深度缓冲或什么......对吗?

You should enable depth testing by calling 您应该通过调用启用深度测试

glEnable(GL_DEPTH_TEST);

And of course do not forget to clear your buffers by calling: 当然不要忘记通过调用以清除缓冲区:

glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

I hope that this will help ;) 我希望这会有所帮助;)

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

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