首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenGLES20屏幕坐标到NDC

OpenGLES20屏幕坐标到NDC
EN

Stack Overflow用户
提问于 2015-12-30 20:29:16
回答 1查看 208关注 0票数 0

我想为我的安卓应用程序在OpenGL ES20中呈现一幅图像。因为我对opengl非常陌生,所以我使用了在这里输入链接描述中的一个例子。

我已经使用NDC系统1,1定义了对象,但是在本例中,您必须使用屏幕坐标来定义顶点。我现在的问题是:我如何才能将屏幕辅助性系统改为NDC系统?

PS:我认为问题在于这段代码:

代码语言:javascript
复制
@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);
}

谢谢你的回答!!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-01 11:42:33

我知道怎么做!所以对于所有想知道的人来说:

Matrix.orthoM(mtrxProjection,0,-1f,1,-1f,1,-1,1);

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34536778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档