From d9c5a439d09211ec210195709d275596c6c3c9ba Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 1 Jul 2012 22:59:22 +0200 Subject: 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 --- src/math/geometry.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/math/geometry.h') 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) -- cgit v1.2.3-1-g7c22