我想为我的安卓应用程序在OpenGL ES20中呈现一幅图像。因为我对opengl非常陌生,所以我使用了在这里输入链接描述中的一个例子。
我已经使用NDC系统1,1定义了对象,但是在本例中,您必须使用屏幕坐标来定义顶点。我现在的问题是:我如何才能将屏幕辅助性系统改为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);
}谢谢你的回答!!
发布于 2016-01-01 11:42:33
我知道怎么做!所以对于所有想知道的人来说:
Matrix.orthoM(mtrxProjection,0,-1f,1,-1f,1,-1,1);
https://stackoverflow.com/questions/34536778
复制相似问题