作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 libgdx 应用程序,我在其中创建了一个由立方体组成的迷宫。当我渲染底部蓝色和顶部红色面时,底部一个会渲染在顶部面的前面。两个面具有相同的法 vector 。
我可以切换远近剪裁平面吗?
这是我设置相机的方法:
public PerspectiveCamera updateCamera() {
if (camera == null) {
float aspectRatio = Gdx.graphics.getWidth() / Gdx.graphics.getHeight();
camera = new PerspectiveCamera(67f, aspectRatio, 1);
this.setActive(true);
}
return camera;
}
最佳答案
我只是忘记添加深度测试。
添加到 create() 方法:
Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
Gdx.gl.glDepthFunc(GL10.GL_LESS);
添加到 render() 方法:
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
关于java - 较远的平面渲染在较近的平面前面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13985425/
我是一名优秀的程序员,十分优秀!