我試圖用OpenGL ES繪製正交模式,點(0,0)位於屏幕的左下角。但是,我想讓它位於左上角。在OpenGL ES中翻轉Y軸?
這裏就是我在我的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, 0, width, 0, height);
}
我試圖改變在許多方面上面的調用,包括:
GLU.gluOrtho2D(gl, 0, width, 0, height);
GLU.gluOrtho2D(gl, 0, width, 0, -height);
GLU.gluOrtho2D(gl, 0, width, height, 0);
GLU.gluOrtho2D(gl, 0, width, -height, 0);
我也試圖與視口打無效:
public void onSurfaceChanged(final GL10 gl, final int width, final int height) {
assert gl != null;
// define the viewport
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
// use orthographic projection (no depth perception)
GLU.gluOrtho2D(gl, 0, width, 0, height);
}
而且,我試着玩視口設置無濟於事:
gl.glViewport(0, 0, width, height);
gl.glViewport(0, 0, width, -height);
gl.glViewport(0, height, width, 0);
gl.glViewport(0, -height, width, 0);
任何關於如何讓點(0,0)到屏幕左上角的線索?謝謝!
glScalef應該用於縮放類似,不固定座標投影。 – rioki 2010-07-16 12:58:41
您認爲'gluOrtho2D'如何工作?它當然會調整投影矩陣,「glScale」也會改變。 – 2010-07-16 14:25:20
GL ES不提供矩陣運算符 – 2013-12-10 01:13:54