【问题标题】:Farther plane is rendered in front of closer one较远的平面呈现在较近的平面前面
【发布时间】:2013-12-18 08:49:24
【问题描述】:

我有一个 libgdx 应用程序,我在其中创建了一个由立方体组成的迷宫。 当我渲染底部 blue 和顶部 red 面时,底部的一个渲染在顶面的前面。两张脸的法线向量相同。

我可以切换远近剪裁平面吗?

这是我设置相机的方法:

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;
}

【问题讨论】:

    标签: java opengl-es libgdx


    【解决方案1】:

    我只是忘了添加深度测试。

    添加到 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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-12
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      • 2012-10-08
      • 2022-12-15
      • 2013-03-20
      • 1970-01-01
      相关资源
      最近更新 更多