0
我要呈現在OpenGL ES20的圖像爲我的Android應用程序。 因爲我是真正的新的OpenGL我使用enter link description hereOpenGLES20屏幕座標NDC
一個例子,我已經通過NDC系統定義的對象[-1,1] 但在這個例子中,你必須使用屏幕座標來定義的頂點。 我現在的問題是: 如何將屏幕coordiante系統更改回NDC系統?
PS:我覺得問題就出在這一段代碼:
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
// We need to know the current width and height.
mScreenWidth = width;
mScreenHeight = height;
// Redo the Viewport, making it fullscreen.
GLES20.glViewport(0, 0, width, height);
// Clear our matrices
for(int i=0;i<16;i++)
{
mtrxProjection[i] = 0.0f;
mtrxView[i] = 0.0f;
mtrxProjectionAndView[i] = 0.0f;
}
// Setup our screen width and height for normal sprite translation.
Matrix.orthoM(mtrxProjection, 0, 0f, width, 0.0f, height, 0, 50);
// Set the camera position (View matrix)
Matrix.setLookAtM(mtrxView, 0, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
// Calculate the projection and view transformation
Matrix.multiplyMM(mtrxProjectionAndView, 0, mtrxProjection, 0, mtrxView, 0);
}
感謝所有answeres!