summaryrefslogtreecommitdiffstats
path: root/src/math/geometry.h
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-07-01 22:59:22 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-07-01 22:59:22 +0200
commitd9c5a439d09211ec210195709d275596c6c3c9ba (patch)
treeb536721f8ac5f42649345eeb836259bbf6a887e3 /src/math/geometry.h
parent9bd4ec03b272e7925b11c3efc2bd8460894ea589 (diff)
downloadcolobot-d9c5a439d09211ec210195709d275596c6c3c9ba.tar.gz
colobot-d9c5a439d09211ec210195709d275596c6c3c9ba.tar.bz2
colobot-d9c5a439d09211ec210195709d275596c6c3c9ba.zip
CGLDevice implementation
- extended Gfx::CDevice interface - written OpenGL implementation in Gfx::CGLDevice - rewrote color and light module - added Gfx::VertexCol - added array casts to Math::Vector, Math::Matrix and Gfx::Color
Diffstat (limited to 'src/math/geometry.h')
-rw-r--r--src/math/geometry.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/math/geometry.h b/src/math/geometry.h
index 2f937e5..d5960b8 100644
--- a/src/math/geometry.h
+++ b/src/math/geometry.h
@@ -305,6 +305,24 @@ inline void LoadProjectionMatrix(Matrix &mat, float fov = 1.570795f, float aspec
/* (3,4) */ mat.m[14] = -q * nearPlane;
}
+//! Loads an othogonal projection matrix
+/** \a left,right coordinates for left and right vertical clipping planes
+ \a bottom,top coordinates for bottom and top horizontal clipping planes
+ \a zNear,zFar distance to nearer and farther depth clipping planes */
+inline void LoadOrthoProjectionMatrix(Matrix &mat, float left, float right, float bottom, float top,
+ float zNear = -1.0f, float zFar = 1.0f)
+{
+ mat.LoadIdentity();
+
+ /* (1,1) */ mat.m[0 ] = 2.0f / (right - left);
+ /* (2,2) */ mat.m[5 ] = 2.0f / (top - bottom);
+ /* (3,3) */ mat.m[10] = -2.0f / (zFar - zNear);
+
+ /* (1,4) */ mat.m[12] = - (right + left) / (right - left);
+ /* (2,4) */ mat.m[12] = - (top + bottom) / (top - bottom);
+ /* (3,4) */ mat.m[14] = - (zFar + zNear) / (zFar - zNear);
+}
+
//! Loads a translation matrix from given vector
/** \a trans vector of translation*/
inline void LoadTranslationMatrix(Matrix &mat, const Vector &trans)