static void R_SetupProjectionMatrix(const refdef_t *rd, mat4x4_t m)
{
#ifndef GLES2 //if OGL
GLdouble xMin, xMax, yMin, yMax, zNear, zFar;
#else
GLfloat xMin, xMax, yMin, yMax, zNear, zFar;
#endif
if (ri.params & RP_SHADOWMAPVIEW)
// do not alter the farclip distance for shadow map views
;
else if (rd->rdflags & RDF_NOWORLDMODEL)
ri.farClip = 2048;
else
ri.farClip = R_FarClip();
zNear = Z_NEAR;
zFar = ri.farClip;
yMax = zNear * tan(rd->fov_y * M_PI / 360.0);
yMin = -yMax;
xMax = zNear * tan(rd->fov_x * M_PI / 360.0);
xMin = -xMax;
xMin += -(2 * glState.cameraSeparation) / zNear;
xMax += -(2 * glState.cameraSeparation) / zNear;
m[0] = (2.0 * zNear) / (xMax - xMin);
m[1] = 0.0f;
m[2] = 0.0f;
m[3] = 0.0f;
m[4] = 0.0f;
m[5] = (2.0 * zNear) / (yMax - yMin);
m[6] = 0.0f;
m[7] = 0.0f;
m[8] = (xMax + xMin) / (xMax - xMin);
m[9] = (yMax + yMin) / (yMax - yMin);
m[10] = -(zFar + zNear) / (zFar - zNear);
m[11] = -1.0f;
m[12] = 0.0f;
m[13] = 0.0f;
m[14] = -(2.0 * zFar * zNear) / (zFar - zNear);
m[15] = 0.0f;
}