aboutsummaryrefslogtreecommitdiffstats
path: root/linmath.h
diff options
context:
space:
mode:
Diffstat (limited to 'linmath.h')
-rw-r--r--linmath.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/linmath.h b/linmath.h
index 9220940..e7d308f 100644
--- a/linmath.h
+++ b/linmath.h
@@ -262,22 +262,35 @@ static inline void mat4x4_invert(mat4x4 R, mat4x4 const M)
}
static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, float n, float f)
{
- M[0][0] = 2*n/(r-l);
+ M[0][0] = 2.*n/(r-l);
M[0][1] = M[0][2] = M[0][3] = 0.;
- M[1][1] = 2*n/(t-b);
- M[1][0] = M[0][2] = M[0][3] = 0.;
+ M[1][1] = 2.*n/(t-b);
+ M[1][0] = M[1][2] = M[1][3] = 0.;
M[2][0] = (r+l)/(r-l);
M[2][1] = (t+b)/(t-b);
M[2][2] = -(f+n)/(f-n);
M[2][3] = -1;
- M[3][2] = -2*f*n/(f-n);
- M[3][0] = M[0][1] = M[0][3] = 0.;
+ M[3][2] = -2.*f*n/(f-n);
+ M[3][0] = M[3][1] = M[3][3] = 0.;
}
static inline void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f)
{
+ M[0][0] = 2./(r-l);
+ M[0][1] = M[0][2] = M[0][3] = 0.;
+
+ M[1][1] = 2./(t-b);
+ M[1][0] = M[1][2] = M[1][3] = 0.;
+
+ M[2][2] = -2./(f-n);
+ M[2][0] = M[2][1] = M[0][3] = 0.;
+
+ M[3][0] = (r+l)/(r-l);
+ M[3][1] = (t+b)/(t-b);
+ M[3][2] = (f+n)/(f-n);
+ M[3][3] = 1.;
}
typedef float quat[4];