0
所以我绝对到处找,找不到安塞。当我在android的opengl中绘制一个3d立方体时,只要我处于肖像模式,但是当我切换到横向时,它看起来更像钻石。我认为问题与比例,但我真的不能这样说,这里是我用于比率的代码。安卓OpenGL ES 3D立方体在横向模式下呈现
public void onSurfaceChanged(GL10 gl, int width, int height){
gl.glViewport(0, 0, width, height);
float ratio = (float) width/height;
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glFrustumf(-ratio, ratio, -1, 1, 1, 11);
}
,可能是我认为这个问题的另一种选择是立方体自身却又不知道所以这里的顶点和索引。
private int vertices[] = {
-one, -one, -one,
one, -one, -one,
one, one, -one,
-one, one, -one,
-one, -one, one,
one, -one, one,
one, one, one,
-one, one, one
};
private byte indices[] = {
0, 4, 5, 0, 5, 1,
1, 5, 6, 1, 6, 2,
2, 6, 7, 2, 7, 3,
3, 7, 4, 3, 4, 0,
4, 7, 6, 4, 6, 5,
3, 0, 1, 3, 1, 2
};