slight optimization
This commit is contained in:
parent
e05c62725c
commit
e06395ff5d
@ -108,12 +108,15 @@ void guMatrixFrustum(guMatrix4x4 *m,
|
||||
mult[i][j] = 0.0;
|
||||
}
|
||||
}
|
||||
mult[0][0] = 2 * near / (right - left);
|
||||
mult[0][2] = (right + left) / (right - left);
|
||||
mult[1][1] = 2 * near / (top - bottom);
|
||||
mult[1][2] = (top + bottom) / (top - bottom);
|
||||
mult[2][2] = - (far + near) / (far - near);
|
||||
mult[2][3] = - 2 * far * near / (far - near);
|
||||
GLfloat rl = right - left;
|
||||
GLfloat tb = top - bottom;
|
||||
GLfloat fn = far - near;
|
||||
mult[0][0] = 2 * near / rl;
|
||||
mult[0][2] = (right + left) / rl;
|
||||
mult[1][1] = 2 * near / tb;
|
||||
mult[1][2] = (top + bottom) / tb;
|
||||
mult[2][2] = - (far + near) / fn;
|
||||
mult[2][3] = - 2 * far * near / fn;
|
||||
mult[3][2] = -1.0;
|
||||
guMatrixMult(m, m, &mult);
|
||||
}
|
||||
@ -131,10 +134,11 @@ void guPerspective(guMatrix4x4 *m, GLfloat fovy, GLfloat aspect,
|
||||
}
|
||||
}
|
||||
GLfloat f = 1.0 / tan(fovy / 2.0);
|
||||
GLfloat nf = near - far;
|
||||
mult[0][0] = f / aspect;
|
||||
mult[1][1] = f;
|
||||
mult[2][2] = (far + near) / (near - far);
|
||||
mult[2][3] = (2 * far * near) / (near - far);
|
||||
mult[2][2] = (far + near) / nf;
|
||||
mult[2][3] = (2 * far * near) / nf;
|
||||
mult[3][2] = -1.0;
|
||||
guMatrixMult(m, m, &mult);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user