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
};