add glm::ortho_2d

This commit is contained in:
Russell Greene 2015-08-22 14:30:36 -06:00
parent cd907a8f0f
commit 9da11ffdb1
2 changed files with 32 additions and 0 deletions

View File

@ -151,6 +151,21 @@ namespace glm
T right, T right,
T bottom, T bottom,
T top); 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 <typename T>
GLM_FUNC_DECL tmat3x3<T, defaultp> ortho_2d(
T left,
T right,
T bottom,
T top);
/// Creates a frustum matrix. /// Creates a frustum matrix.
/// ///

View File

@ -185,6 +185,23 @@ namespace glm
Result[3][1] = - (top + bottom) / (top - bottom); Result[3][1] = - (top + bottom) / (top - bottom);
return Result; return Result;
} }
template <typename T>
GLM_FUNC_QUALIFIER tmat3x3<T, defaultp> ortho_2d
(
T left,
T right,
T bottom,
T top
)
{
tmat3x3<T, defaultp> Result(1);
Result[0][0] = static_cast<T>(2) / (right - left);
Result[1][1] = static_cast<T>(2) / (top - bottom);
Result[2][0] = -(right + left) / (right - left);
Result[2][1] = -(top + bottom) / (top - bottom);
return Result;
}
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustum GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustum