add guOrtho()
This commit is contained in:
parent
e06395ff5d
commit
cf31a302f2
@ -142,3 +142,29 @@ void guPerspective(guMatrix4x4 *m, GLfloat fovy, GLfloat aspect,
|
|||||||
mult[3][2] = -1.0;
|
mult[3][2] = -1.0;
|
||||||
guMatrixMult(m, m, &mult);
|
guMatrixMult(m, m, &mult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void guOrtho(guMatrix4x4 *m,
|
||||||
|
GLfloat left, GLfloat right,
|
||||||
|
GLfloat bottom, GLfloat top,
|
||||||
|
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 rl = right - left;
|
||||||
|
GLfloat tb = top - bottom;
|
||||||
|
GLfloat fn = far - near;
|
||||||
|
mult[0][0] = 2 / rl;
|
||||||
|
mult[0][3] = - (right + left) / rl;
|
||||||
|
mult[1][1] = 2 / tb;
|
||||||
|
mult[1][3] = - (top + bottom) / tb;
|
||||||
|
mult[2][2] = -2 / fn;
|
||||||
|
mult[2][3] = - (far + near) / fn;
|
||||||
|
mult[3][3] = 1.0;
|
||||||
|
}
|
||||||
|
@ -26,6 +26,10 @@ void guMatrixFrustum(guMatrix4x4 *m,
|
|||||||
GLfloat near, GLfloat far);
|
GLfloat near, GLfloat far);
|
||||||
void guPerspective(guMatrix4x4 *m, GLfloat fovy, GLfloat aspect,
|
void guPerspective(guMatrix4x4 *m, GLfloat fovy, GLfloat aspect,
|
||||||
GLfloat near, GLfloat far);
|
GLfloat near, GLfloat far);
|
||||||
|
void guOrtho(guMatrix4x4 *m,
|
||||||
|
GLfloat left, GLfloat right,
|
||||||
|
GLfloat bottom, GLfloat top,
|
||||||
|
GLfloat near, GLfloat far);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user