diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2012-01-06 00:49:59 +0100 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2012-01-06 00:49:59 +0100 |
commit | fe82c60f5ec2b6f3e5483432d912a42aa4515b15 (patch) | |
tree | 197f030e41d08e406473ac29d47052233d7cfd4d | |
parent | 3362962bcb06cee03c6029491f1c4ea38c396eb7 (diff) | |
download | linmath-fe82c60f5ec2b6f3e5483432d912a42aa4515b15.tar.gz linmath-fe82c60f5ec2b6f3e5483432d912a42aa4515b15.tar.xz linmath-fe82c60f5ec2b6f3e5483432d912a42aa4515b15.zip |
linmath.h -- added code for ortho projection matrix, fixed some copynpaste typos in frustum
-rw-r--r-- | linmath.h | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -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]; |