From fe18a36c107f3d49ace74f7be3bd83b9e1a71fd7 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 6 Mar 2016 00:16:09 +0100 Subject: [PATCH] - Added right and left handed projection and clip control support #447 #119 --- glm/gtc/matrix_transform.inl | 10 ++++++++++ readme.md | 1 + 2 files changed, 11 insertions(+) diff --git a/glm/gtc/matrix_transform.inl b/glm/gtc/matrix_transform.inl index 2cd2645c..c79f822a 100644 --- a/glm/gtc/matrix_transform.inl +++ b/glm/gtc/matrix_transform.inl @@ -578,7 +578,12 @@ namespace glm tmp = proj * tmp; tmp /= tmp.w; +#ifdef GLM_DEPTH_ZERO_TO_ONE + tmp.x = tmp.x * T(0.5) + T(0.5); + tmp.y = tmp.y * T(0.5) + T(0.5); +#else tmp = tmp * T(0.5) + T(0.5); +#endif tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); @@ -599,7 +604,12 @@ namespace glm tvec4 tmp = tvec4(win, T(1)); tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]); tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]); +#ifdef GLM_DEPTH_ZERO_TO_ONE + tmp.x = tmp.x * T(2) - T(1); + tmp.y = tmp.y * T(2) - T(1); +#else tmp = tmp * T(2) - T(1); +#endif tvec4 obj = Inverse * tmp; obj /= obj.w; diff --git a/readme.md b/readme.md index caa17243..dee3416b 100644 --- a/readme.md +++ b/readme.md @@ -53,6 +53,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) #### [GLM 0.9.8.0](https://github.com/g-truc/glm/releases/latest) - 2016-XX-XX ##### Features: +- Added right and left handed projection and clip control support #447 #119 - Added compNormalize and compScale functions to GTX_component_wise - Added packF3x9_E1x5 and unpackF3x9_E1x5 to GTC_packing for RGB9E5 #416 - Added (un)packHalf to GTC_packing