Android ndc命令没有,android - OpenGLES20 screen coordinates to NDC - Stack Overflow

i want to render an image in OpenGL ES20 for my android app.

Because i am really new to opengl i used a example from enter link description here

I already defined objects by using the NDC system [-1, 1]

but in this example you have to define the vertices by using the screen coordinates.

My question now is:

How can i change the screen coordiante system back to the NDC system??

PS: i think the problem lies in this piece of code:

@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);

}

Thanks for all answeres!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值