【发布时间】:2013-04-06 21:21:10
【问题描述】:
我知道标准化坐标应该是-1(左)+1(右)和-1(下)+1(上)
像这样:
但是在应用这个之后:
来自我的 onSurfaceChanged 方法
GLES20.glViewport(0, 0, width, height);
float ratio = (float) width / height;
Matrix.orthoM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7);
//The above line can be replaced with:
//Matrix.frustumM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7);
//But I get the same results with either frustumM or otrhoM
这在我的 onDrawFrame 方法中
Matrix.setLookAtM(mVMatrix, 0, 0, 0, 3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);
(然后我将 mMVPMatrix 传递到我的自定义类的 draw 方法中,在该方法中它被旋转和平移)。
但是,我的坐标似乎发生了变化——大致是这样的:
如您所见,x 坐标有所改变,-1 和 +1 不再是屏幕的边缘(在我目前使用的设备上,外边缘变为 -1.7 和 + 1.7)
Y坐标保持不变。
如果有人能指出我哪里出错了,不胜感激?我需要它应该是 -1 到 +1。
谢谢
【问题讨论】:
标签: android opengl-es-2.0 coordinates coordinate-systems orthographic