add guPerspective()
This commit is contained in:
parent
2d7bafe23b
commit
e05c62725c
@ -117,3 +117,24 @@ void guMatrixFrustum(guMatrix4x4 *m,
|
|||||||
mult[3][2] = -1.0;
|
mult[3][2] = -1.0;
|
||||||
guMatrixMult(m, m, &mult);
|
guMatrixMult(m, m, &mult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void guPerspective(guMatrix4x4 *m, GLfloat fovy, GLfloat aspect,
|
||||||
|
GLfloat near, GLfloat far)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
guMatrix4x4 mult;
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < 4; j++)
|
||||||
|
{
|
||||||
|
mult[i][j] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GLfloat f = 1.0 / tan(fovy / 2.0);
|
||||||
|
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[3][2] = -1.0;
|
||||||
|
guMatrixMult(m, m, &mult);
|
||||||
|
}
|
||||||
|
@ -24,6 +24,8 @@ void guMatrixFrustum(guMatrix4x4 *m,
|
|||||||
GLfloat left, GLfloat right,
|
GLfloat left, GLfloat right,
|
||||||
GLfloat bottom, GLfloat top,
|
GLfloat bottom, GLfloat top,
|
||||||
GLfloat near, GLfloat far);
|
GLfloat near, GLfloat far);
|
||||||
|
void guPerspective(guMatrix4x4 *m, GLfloat fovy, GLfloat aspect,
|
||||||
|
GLfloat near, GLfloat far);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user