android – 在OpenGL ES中翻转Y轴?

android – 在OpenGL ES中翻转Y轴?,第1张

概述我试图用OpenGL ES绘制正交模式,点(0,0)位于屏幕的左下角.但是,我想把它放在左上角. 这是我在Android应用中设置的地方: public void onSurfaceChanged(final GL10 gl, final int width, final int height) { assert gl != null; // use orthographic p 我试图用OpenGL ES绘制正交模式,点(0,0)位于屏幕的左下角.但是,我想把它放在左上角.

这是我在Android应用中设置的地方:

public voID onSurfaceChanged(final GL10 gl,final int wIDth,final int height) {    assert gl != null;    // use orthographic projection (no depth perception)    glu.gluOrtho2D(gl,wIDth,height);}

我尝试过多种方式更改上述调用,包括:

glu.gluOrtho2D(gl,height);    glu.gluOrtho2D(gl,-height);    glu.gluOrtho2D(gl,height,0);    glu.gluOrtho2D(gl,-height,0);

我也尝试过使用视口无济于事:

public voID onSurfaceChanged(final GL10 gl,final int height) {    assert gl != null;    // define the vIEwport    gl.glVIEwport(0,height);    gl.glMatrixMode(GL10.GL_PROJECTION);    gl.glLoadIDentity();    // use orthographic projection (no depth perception)    glu.gluOrtho2D(gl,height);}

而且,我尝试使用视口设置无效:

gl.glVIEwport(0,height);    gl.glVIEwport(0,-height);    gl.glVIEwport(0,0);    gl.glVIEwport(0,0);

有关如何将点(0,0)放到屏幕左上角的任何线索?谢谢!

解决方法 怎么样:

glVIEwport(0,height);gluOrtho2D(0,0);

glVIEwport调用仅在设备坐标中设置视口.这是你的窗口系统. glOrtho(gluOrtho2D)调用设置从世界坐标到设备坐标的坐标映射.

看到:

> http://pyopengl.sourceforge.net/documentation/manual/gluOrtho2D.3G.html
> http://www.opengl.org/sdk/docs/man/xhtml/glViewport.xml

总结

以上是内存溢出为你收集整理的android – 在OpenGL ES中翻转Y轴?全部内容,希望文章能够帮你解决android – 在OpenGL ES中翻转Y轴?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1123019.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存