template <typename type>
inline mat4<type> mat4<type>::perspectiveProjection(type fovy, type aspect, type zNear, type zFar)
{
type f = (type) 1 / tan(radians(fovy) / 2);
return mat4<type>(f / aspect, 0, 0, 0,
0, f, 0, 0,
0, 0, (zFar + zNear) / (zNear - zFar), (2*zFar*zNear) / (zNear - zFar),
0, 0, -1, 0);
}
template <typename type>
inline mat4<type> mat4<type>::orthoProjection(type xRight, type xLeft, type yTop, type yBottom, type zNear, type zFar)
{
type tx, ty, tz;
tx = - (xRight + xLeft) / (xRight - xLeft);
ty = - (yTop + yBottom) / (yTop - yBottom);
tz = - (zFar + zNear) / (zFar - zNear);
return mat4<type>(2 / (xRight - xLeft), 0, 0, tx,
0, 2 / (yTop - yBottom), 0, ty,
0, 0, -2 / (zFar - zNear), tz,
0, 0, 0, 1);
}