diff --git a/glm/gtc/matrix_transform.hpp b/glm/gtc/matrix_transform.hpp index d4ff3cfe..504bb5c8 100644 --- a/glm/gtc/matrix_transform.hpp +++ b/glm/gtc/matrix_transform.hpp @@ -151,6 +151,21 @@ namespace glm T right, T bottom, T top); + + /// Creates a matrix for projecting two-dimensional coordinates onto the screen. + /// + /// @param left + /// @param right + /// @param bottom + /// @param top + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + template + GLM_FUNC_DECL tmat3x3 ortho_2d( + T left, + T right, + T bottom, + T top); /// Creates a frustum matrix. /// diff --git a/glm/gtc/matrix_transform.inl b/glm/gtc/matrix_transform.inl index d60494e3..a35482f1 100644 --- a/glm/gtc/matrix_transform.inl +++ b/glm/gtc/matrix_transform.inl @@ -185,6 +185,23 @@ namespace glm Result[3][1] = - (top + bottom) / (top - bottom); return Result; } + + template + GLM_FUNC_QUALIFIER tmat3x3 ortho_2d + ( + T left, + T right, + T bottom, + T top + ) + { + tmat3x3 Result(1); + Result[0][0] = static_cast(2) / (right - left); + Result[1][1] = static_cast(2) / (top - bottom); + Result[2][0] = -(right + left) / (right - left); + Result[2][1] = -(top + bottom) / (top - bottom); + return Result; + } template GLM_FUNC_QUALIFIER tmat4x4 frustum