summaryrefslogtreecommitdiffstats
path: root/Common/interface
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-03-26 03:35:37 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-03-26 03:35:37 +0000
commitf419bd2c4fa2bf8df5df29100eae6fbca1d2578a (patch)
treeb3937bf1df662fe5460eaf2da880f7b7fbb56ae2 /Common/interface
parentAdded a couple of #includes to fix include test build errors (diff)
downloadDiligentCore-f419bd2c4fa2bf8df5df29100eae6fbca1d2578a.tar.gz
DiligentCore-f419bd2c4fa2bf8df5df29100eae6fbca1d2578a.zip
Added functions for Ortho projection matrix
Diffstat (limited to 'Common/interface')
-rw-r--r--Common/interface/BasicMath.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/Common/interface/BasicMath.h b/Common/interface/BasicMath.h
index eae2dc8a..de42c49e 100644
--- a/Common/interface/BasicMath.h
+++ b/Common/interface/BasicMath.h
@@ -1180,6 +1180,22 @@ inline float4x4 Projection(float fov, float aspectRatio, float zNear, float zFar
return mOut;
}
+inline float4x4 OrthoOffCenter(float left, float right, float bottom, float top, float zNear, float zFar, bool bIsDirectX) // Left-handed ortho projection
+{
+ float _22 = (bIsDirectX ? 1.f : 2.f) / (zFar - zNear);
+ float _32 = (bIsDirectX ? zNear : zNear + zFar) / (zNear - zFar);
+ return float4x4 (
+ 2.f / (right - left), 0.f, 0.f, 0.f,
+ 0.f, 2.f/(top - bottom), 0.f, 0.f,
+ 0.f, 0.f, _22, 0.f,
+ (left + right)/(left - right), (top + bottom) / (bottom - top), _32, 1.f
+ );
+}
+
+inline float4x4 Ortho(float width, float height, float zNear, float zFar, bool bIsDirectX) // Left-handed ortho projection
+{
+ return OrthoOffCenter(-width * 0.5f, +width * 0.5f, -height * 0.5f, +height * 0.5f, zNear, zFar, bIsDirectX);
+}
struct Quaternion
{