add guMatrixFrustum()
This commit is contained in:
parent
514a1c6d09
commit
26bc6781cb
@ -35,3 +35,26 @@ void guMatrixTranslate(guMatrix4x4 *m, float x, float y, float z)
|
|||||||
m[i][3] += m[i][0] * x + m[i][1] * y + m[i][2] * z;
|
m[i][3] += m[i][0] * x + m[i][1] * y + m[i][2] * z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void guMatrixFrustum(guMatrix4x4 *m,
|
||||||
|
float left, float right,
|
||||||
|
float bottom, float top,
|
||||||
|
float near, float far)
|
||||||
|
{
|
||||||
|
guMatrix4x4 mult;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 4; j++)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
mult[3][2] = -1.0;
|
||||||
|
guMatrixMult(m, &mult);
|
||||||
|
}
|
||||||
|
@ -17,6 +17,10 @@ extern "C" {
|
|||||||
void guMatrixLoadIdentity(guMatrix4x4 *m);
|
void guMatrixLoadIdentity(guMatrix4x4 *m);
|
||||||
void guMatrixMult(guMatrix4x4 *m, guMatrix4x4 *a, guMatrix4x4 *b);
|
void guMatrixMult(guMatrix4x4 *m, guMatrix4x4 *a, guMatrix4x4 *b);
|
||||||
void guMatrixTranslate(guMatrix4x4 *m, float x, float y, float z);
|
void guMatrixTranslate(guMatrix4x4 *m, float x, float y, float z);
|
||||||
|
void guMatrixFrustum(guMatrix4x4 *m,
|
||||||
|
float left, float right,
|
||||||
|
float bottom, float top,
|
||||||
|
float near, float far);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user