Fix D3D z-buffer problem by having separate GetOrthoMatrix functions for OGL and D3D.

I don't understand why the two APIs create an ortho matrix so differently, but I'm tried of messing with it for now.
This commit is contained in:
Chris Danford
2003-05-25 00:43:44 +00:00
parent c9b4efb861
commit a75cd6e7b1
8 changed files with 97 additions and 80 deletions
-46
View File
@@ -440,23 +440,6 @@ RageMatrix RageLookAt(
return ret;
}
RageMatrix RageOrtho( float l, float r, float b, float t, float zn, float zf )
{
RageMatrix m(
2/(r-l), 0, 0, 0,
0, 2/(t-b), 0, 0,
0, 0, -2/(zf-zn), 0,
-(r+l)/(r-l), -(t+b)/(t-b), -(zf+zn)/(zf-zn), 1 );
/*
RageMatrix m(
2/(r-l), 0, 0, 0,
0, 2/(t-b), 0, 0,
0, 0, 1/(zf-zn), 0,
(l+r)/(l-r), (t+b)/(b-t), zn/(zn-zf), 1 );
*/
return m;
}
RageMatrix RageMatrixIdentity()
{
RageMatrix m;
@@ -464,32 +447,3 @@ RageMatrix RageMatrixIdentity()
return m;
}
RageMatrix RageMatrixFrustrum(
float left,
float right,
float bottom,
float top,
float znear,
float zfar ) // see glFrustrum docs
{
float A = (right+left) / (right-left);
float B = (top+bottom) / (top-bottom);
float C = -1 * (zfar+znear) / (zfar-znear);
float D = -1 * (2*zfar*znear) / (zfar-znear);
RageMatrix m(
2*znear/(right-left), 0, 0, 0,
0, 2*znear/(top-bottom), 0, 0,
A, B, C, -1,
0, 0, D, 0 );
return m;
}
RageMatrix RageMatrixPerspective(float fovy, float aspect, float zNear, float zFar)
{
float ymax = zNear * tanf(fovy * PI / 360.0f);
float ymin = -ymax;
float xmin = ymin * aspect;
float xmax = ymax * aspect;
return RageMatrixFrustrum(xmin, xmax, ymin, ymax, zNear, zFar);
}