1

我正在使用 OpenGL ES 2.0 教程作为基础在 Android 平台上使用 OpenGL。有问题的代码是:

public void onSurfaceChanged( GL10 unused, int width, int height )
{   GLES20.glViewport( 0, 0, width, height );

    float ratio = (float) width / height;
    Matrix.frustumM( mProjMatrix, 0, -ratio, ratio, -1, 1, 1,  9.9999f );

    Matrix.setLookAtM( mVMatrix, 0, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,  0.0f, 0.0f, 1.0f,  0.0f );

    muMVPMatrixHandle = GLES20.glGetUniformLocation( mProgram, "uMVPMatrix" );
}

特别是 frustumM 的“far”参数。只要该参数为 10,图像(三角形)就不会出现。任何其他值都可以。为什么?

我已经做了相当多的阅读 - 一切都无济于事。甚至我的朋友(又名 Google)也无法帮助我。

提前致谢。

4

1 回答 1

1

When you calculate your projection matrix you specify the far plane to be at 9.9999f, which is why an eyeZ value of 10 or larger in the view matrix calculation will result in an empty image. You are looking outside of your frustum.

Please take a look at this article: http://www.lighthouse3d.com/tutorials/view-frustum-culling/

于 2012-02-29T20:46:50.457 回答