mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 11:24:35 +00:00
Sliced matrix transform extension
This commit is contained in:
parent
15fe4e84cc
commit
f905aecd23
531
glm/ext/matrix_clip_space.hpp
Normal file
531
glm/ext/matrix_clip_space.hpp
Normal file
@ -0,0 +1,531 @@
|
|||||||
|
/// @ref ext_matrix_clip_space
|
||||||
|
/// @file glm/ext/matrix_clip_space.hpp
|
||||||
|
///
|
||||||
|
/// @see core (dependence)
|
||||||
|
///
|
||||||
|
/// @defgroup ext_matrix_clip_space GLM_EXT_matrix_clip_space
|
||||||
|
/// @ingroup ext
|
||||||
|
///
|
||||||
|
/// Include <glm/ext/matrix_clip_space.hpp> to use the features of this extension.
|
||||||
|
///
|
||||||
|
/// Defines functions that generate common transformation matrices.
|
||||||
|
///
|
||||||
|
/// The matrices generated by this extension use standard OpenGL fixed-function
|
||||||
|
/// conventions. For example, the lookAt function generates a transform from world
|
||||||
|
/// space into the specific eye space that the projective matrix functions
|
||||||
|
/// (perspective, ortho, etc) are designed to expect. The OpenGL compatibility
|
||||||
|
/// specifications defines the particular layout of this eye space.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
#include "../gtc/constants.hpp"
|
||||||
|
#include "../geometric.hpp"
|
||||||
|
#include "../trigonometric.hpp"
|
||||||
|
#include "../matrix.hpp"
|
||||||
|
|
||||||
|
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||||
|
# pragma message("GLM: GLM_EXT_matrix_clip_space extension included")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace glm
|
||||||
|
{
|
||||||
|
/// @addtogroup ext_matrix_clip_space
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/// Creates a matrix for projecting two-dimensional coordinates onto the screen.
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top, T const& zNear, T const& zFar)
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluOrtho2D.xml">gluOrtho2D man page</a>
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> ortho(
|
||||||
|
T left, T right, T bottom, T top);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH_ZO(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume using right-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH_NO(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH_ZO(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using right-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH_NO(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoZO(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoNO(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
|
||||||
|
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using right-handed coordinates.
|
||||||
|
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a matrix for an orthographic parallel viewing volume, using the default handedness and default near and far clip planes definition.
|
||||||
|
/// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml">glOrtho man page</a>
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> ortho(
|
||||||
|
T left, T right, T bottom, T top, T zNear, T zFar);
|
||||||
|
|
||||||
|
/// Creates a left handed frustum matrix.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH_ZO(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a left handed frustum matrix.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH_NO(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a right handed frustum matrix.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH_ZO(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a right handed frustum matrix.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH_NO(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a frustum matrix using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumZO(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a frustum matrix using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumNO(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a left handed frustum matrix.
|
||||||
|
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a right handed frustum matrix.
|
||||||
|
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a frustum matrix with default handedness, using the default handedness and default near and far clip planes definition.
|
||||||
|
/// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
||||||
|
///
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glFrustum.xml">glFrustum man page</a>
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustum(
|
||||||
|
T left, T right, T bottom, T top, T near, T far);
|
||||||
|
|
||||||
|
|
||||||
|
/// Creates a matrix for a right handed, symetric perspective-view frustum.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH_ZO(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a right handed, symetric perspective-view frustum.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH_NO(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a left handed, symetric perspective-view frustum.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH_ZO(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a left handed, symetric perspective-view frustum.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH_NO(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a symetric perspective-view frustum using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveZO(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a symetric perspective-view frustum using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveNO(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a right handed, symetric perspective-view frustum.
|
||||||
|
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a left handed, symetric perspective-view frustum.
|
||||||
|
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a symetric perspective-view frustum based on the default handedness and default near and far clip planes definition.
|
||||||
|
/// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml">gluPerspective man page</a>
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspective(
|
||||||
|
T fovy, T aspect, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a perspective projection matrix based on a field of view using right-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH_ZO(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a perspective projection matrix based on a field of view using right-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH_NO(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a perspective projection matrix based on a field of view using left-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH_ZO(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a perspective projection matrix based on a field of view using left-handed coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH_NO(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a perspective projection matrix based on a field of view using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovZO(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a perspective projection matrix based on a field of view using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovNO(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a right handed perspective projection matrix based on a field of view.
|
||||||
|
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a left handed perspective projection matrix based on a field of view.
|
||||||
|
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Builds a perspective projection matrix based on a field of view and the default handedness and default near and far clip planes definition.
|
||||||
|
/// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
||||||
|
///
|
||||||
|
/// @param fov Expressed in radians.
|
||||||
|
/// @param width Width of the viewport
|
||||||
|
/// @param height Height of the viewport
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFov(
|
||||||
|
T fov, T width, T height, T near, T far);
|
||||||
|
|
||||||
|
/// Creates a matrix for a left handed, symmetric perspective-view frustum with far plane at infinite.
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveLH(
|
||||||
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
|
/// Creates a matrix for a right handed, symmetric perspective-view frustum with far plane at infinite.
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveRH(
|
||||||
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite with default handedness.
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspective(
|
||||||
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> tweakedInfinitePerspective(
|
||||||
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||||
|
///
|
||||||
|
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
||||||
|
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
||||||
|
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
||||||
|
/// @param ep Epsilon
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, defaultp> tweakedInfinitePerspective(
|
||||||
|
T fovy, T aspect, T near, T ep);
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
}//namespace glm
|
||||||
|
|
||||||
|
#include "matrix_clip_space.inl"
|
534
glm/ext/matrix_clip_space.inl
Normal file
534
glm/ext/matrix_clip_space.inl
Normal file
@ -0,0 +1,534 @@
|
|||||||
|
namespace glm
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> ortho(T left, T right, T bottom, T top)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(1));
|
||||||
|
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||||
|
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||||
|
Result[2][2] = - static_cast<T>(1);
|
||||||
|
Result[3][0] = - (right + left) / (right - left);
|
||||||
|
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH_ZO(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(1);
|
||||||
|
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||||
|
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||||
|
Result[2][2] = static_cast<T>(1) / (zFar - zNear);
|
||||||
|
Result[3][0] = - (right + left) / (right - left);
|
||||||
|
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||||
|
Result[3][2] = - zNear / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH_NO(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(1);
|
||||||
|
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||||
|
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||||
|
Result[2][2] = static_cast<T>(2) / (zFar - zNear);
|
||||||
|
Result[3][0] = - (right + left) / (right - left);
|
||||||
|
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||||
|
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH_ZO(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(1);
|
||||||
|
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||||
|
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||||
|
Result[2][2] = - static_cast<T>(1) / (zFar - zNear);
|
||||||
|
Result[3][0] = - (right + left) / (right - left);
|
||||||
|
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||||
|
Result[3][2] = - zNear / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH_NO(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(1);
|
||||||
|
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||||
|
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||||
|
Result[2][2] = - static_cast<T>(2) / (zFar - zNear);
|
||||||
|
Result[3][0] = - (right + left) / (right - left);
|
||||||
|
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||||
|
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoZO(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
|
||||||
|
else
|
||||||
|
return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoNO(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return orthoLH_NO(left, right, bottom, top, zNear, zFar);
|
||||||
|
else
|
||||||
|
return orthoRH_NO(left, right, bottom, top, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
|
||||||
|
else
|
||||||
|
return orthoLH_NO(left, right, bottom, top, zNear, zFar);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
|
||||||
|
else
|
||||||
|
return orthoRH_NO(left, right, bottom, top, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> ortho(T left, T right, T bottom, T top, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO)
|
||||||
|
return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO)
|
||||||
|
return orthoLH_NO(left, right, bottom, top, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO)
|
||||||
|
return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO)
|
||||||
|
return orthoRH_NO(left, right, bottom, top, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH_ZO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(0);
|
||||||
|
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
||||||
|
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
||||||
|
Result[2][0] = (right + left) / (right - left);
|
||||||
|
Result[2][1] = (top + bottom) / (top - bottom);
|
||||||
|
Result[2][2] = farVal / (farVal - nearVal);
|
||||||
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
Result[3][2] = -(farVal * nearVal) / (farVal - nearVal);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH_NO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(0);
|
||||||
|
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
||||||
|
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
||||||
|
Result[2][0] = (right + left) / (right - left);
|
||||||
|
Result[2][1] = (top + bottom) / (top - bottom);
|
||||||
|
Result[2][2] = (farVal + nearVal) / (farVal - nearVal);
|
||||||
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH_ZO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(0);
|
||||||
|
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
||||||
|
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
||||||
|
Result[2][0] = (right + left) / (right - left);
|
||||||
|
Result[2][1] = (top + bottom) / (top - bottom);
|
||||||
|
Result[2][2] = farVal / (nearVal - farVal);
|
||||||
|
Result[2][3] = static_cast<T>(-1);
|
||||||
|
Result[3][2] = -(farVal * nearVal) / (farVal - nearVal);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH_NO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, defaultp> Result(0);
|
||||||
|
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
||||||
|
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
||||||
|
Result[2][0] = (right + left) / (right - left);
|
||||||
|
Result[2][1] = (top + bottom) / (top - bottom);
|
||||||
|
Result[2][2] = - (farVal + nearVal) / (farVal - nearVal);
|
||||||
|
Result[2][3] = static_cast<T>(-1);
|
||||||
|
Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumZO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
else
|
||||||
|
return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumNO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
else
|
||||||
|
return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
else
|
||||||
|
return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
else
|
||||||
|
return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustum(T left, T right, T bottom, T top, T nearVal, T farVal)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO)
|
||||||
|
return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO)
|
||||||
|
return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO)
|
||||||
|
return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO)
|
||||||
|
return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH_ZO(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
||||||
|
|
||||||
|
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||||
|
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||||
|
Result[2][2] = zFar / (zNear - zFar);
|
||||||
|
Result[2][3] = - static_cast<T>(1);
|
||||||
|
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH_NO(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
||||||
|
|
||||||
|
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||||
|
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||||
|
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||||
|
Result[2][3] = - static_cast<T>(1);
|
||||||
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH_ZO(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
||||||
|
|
||||||
|
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||||
|
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||||
|
Result[2][2] = zFar / (zFar - zNear);
|
||||||
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH_NO(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
||||||
|
|
||||||
|
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||||
|
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||||
|
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
||||||
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveZO(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
|
||||||
|
else
|
||||||
|
return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveNO(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return perspectiveLH_NO(fovy, aspect, zNear, zFar);
|
||||||
|
else
|
||||||
|
return perspectiveRH_NO(fovy, aspect, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
|
||||||
|
else
|
||||||
|
return perspectiveLH_NO(fovy, aspect, zNear, zFar);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
|
||||||
|
else
|
||||||
|
return perspectiveRH_NO(fovy, aspect, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspective(T fovy, T aspect, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO)
|
||||||
|
return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO)
|
||||||
|
return perspectiveLH_NO(fovy, aspect, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO)
|
||||||
|
return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO)
|
||||||
|
return perspectiveRH_NO(fovy, aspect, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH_ZO(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
assert(width > static_cast<T>(0));
|
||||||
|
assert(height > static_cast<T>(0));
|
||||||
|
assert(fov > static_cast<T>(0));
|
||||||
|
|
||||||
|
T const rad = fov;
|
||||||
|
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
||||||
|
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = w;
|
||||||
|
Result[1][1] = h;
|
||||||
|
Result[2][2] = zFar / (zNear - zFar);
|
||||||
|
Result[2][3] = - static_cast<T>(1);
|
||||||
|
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH_NO(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
assert(width > static_cast<T>(0));
|
||||||
|
assert(height > static_cast<T>(0));
|
||||||
|
assert(fov > static_cast<T>(0));
|
||||||
|
|
||||||
|
T const rad = fov;
|
||||||
|
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
||||||
|
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = w;
|
||||||
|
Result[1][1] = h;
|
||||||
|
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||||
|
Result[2][3] = - static_cast<T>(1);
|
||||||
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH_ZO(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
assert(width > static_cast<T>(0));
|
||||||
|
assert(height > static_cast<T>(0));
|
||||||
|
assert(fov > static_cast<T>(0));
|
||||||
|
|
||||||
|
T const rad = fov;
|
||||||
|
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
||||||
|
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = w;
|
||||||
|
Result[1][1] = h;
|
||||||
|
Result[2][2] = zFar / (zFar - zNear);
|
||||||
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH_NO(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
assert(width > static_cast<T>(0));
|
||||||
|
assert(height > static_cast<T>(0));
|
||||||
|
assert(fov > static_cast<T>(0));
|
||||||
|
|
||||||
|
T const rad = fov;
|
||||||
|
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
||||||
|
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = w;
|
||||||
|
Result[1][1] = h;
|
||||||
|
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
||||||
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovZO(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
|
||||||
|
else
|
||||||
|
return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovNO(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
|
||||||
|
else
|
||||||
|
return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
|
||||||
|
else
|
||||||
|
return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
|
||||||
|
else
|
||||||
|
return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFov(T fov, T width, T height, T zNear, T zFar)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO)
|
||||||
|
return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO)
|
||||||
|
return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO)
|
||||||
|
return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
|
||||||
|
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO)
|
||||||
|
return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveRH(T fovy, T aspect, T zNear)
|
||||||
|
{
|
||||||
|
T const range = tan(fovy / static_cast<T>(2)) * zNear;
|
||||||
|
T const left = -range * aspect;
|
||||||
|
T const right = range * aspect;
|
||||||
|
T const bottom = -range;
|
||||||
|
T const top = range;
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
||||||
|
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
||||||
|
Result[2][2] = - static_cast<T>(1);
|
||||||
|
Result[2][3] = - static_cast<T>(1);
|
||||||
|
Result[3][2] = - static_cast<T>(2) * zNear;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveLH(T fovy, T aspect, T zNear)
|
||||||
|
{
|
||||||
|
T const range = tan(fovy / static_cast<T>(2)) * zNear;
|
||||||
|
T const left = -range * aspect;
|
||||||
|
T const right = range * aspect;
|
||||||
|
T const bottom = -range;
|
||||||
|
T const top = range;
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(T(0));
|
||||||
|
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
||||||
|
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
||||||
|
Result[2][2] = static_cast<T>(1);
|
||||||
|
Result[2][3] = static_cast<T>(1);
|
||||||
|
Result[3][2] = - static_cast<T>(2) * zNear;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspective(T fovy, T aspect, T zNear)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
||||||
|
return infinitePerspectiveLH(fovy, aspect, zNear);
|
||||||
|
else
|
||||||
|
return infinitePerspectiveRH(fovy, aspect, zNear);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear, T ep)
|
||||||
|
{
|
||||||
|
T const range = tan(fovy / static_cast<T>(2)) * zNear;
|
||||||
|
T const left = -range * aspect;
|
||||||
|
T const right = range * aspect;
|
||||||
|
T const bottom = -range;
|
||||||
|
T const top = range;
|
||||||
|
|
||||||
|
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
||||||
|
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
||||||
|
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
||||||
|
Result[2][2] = ep - static_cast<T>(1);
|
||||||
|
Result[2][3] = static_cast<T>(-1);
|
||||||
|
Result[3][2] = (ep - static_cast<T>(2)) * zNear;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear)
|
||||||
|
{
|
||||||
|
return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon<T>());
|
||||||
|
}
|
||||||
|
}//namespace glm
|
148
glm/ext/matrix_projection.hpp
Normal file
148
glm/ext/matrix_projection.hpp
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
/// @ref ext_matrix_projection
|
||||||
|
/// @file glm/ext/matrix_projection.hpp
|
||||||
|
///
|
||||||
|
/// @see core (dependence)
|
||||||
|
///
|
||||||
|
/// @defgroup ext_matrix_projection GLM_EXT_matrix_projection
|
||||||
|
/// @ingroup ext
|
||||||
|
///
|
||||||
|
/// Include <glm/ext/matrix_projection.hpp> to use the features of this extension.
|
||||||
|
///
|
||||||
|
/// Defines functions that generate common transformation matrices.
|
||||||
|
///
|
||||||
|
/// The matrices generated by this extension use standard OpenGL fixed-function
|
||||||
|
/// conventions. For example, the lookAt function generates a transform from world
|
||||||
|
/// space into the specific eye space that the projective matrix functions
|
||||||
|
/// (perspective, ortho, etc) are designed to expect. The OpenGL compatibility
|
||||||
|
/// specifications defines the particular layout of this eye space.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
#include "../gtc/constants.hpp"
|
||||||
|
#include "../geometric.hpp"
|
||||||
|
#include "../trigonometric.hpp"
|
||||||
|
#include "../matrix.hpp"
|
||||||
|
|
||||||
|
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||||
|
# pragma message("GLM: GLM_EXT_matrix_projection extension included")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace glm
|
||||||
|
{
|
||||||
|
/// @addtogroup ext_matrix_projection
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param obj Specify the object coordinates.
|
||||||
|
/// @param model Specifies the current modelview matrix
|
||||||
|
/// @param proj Specifies the current projection matrix
|
||||||
|
/// @param viewport Specifies the current viewport
|
||||||
|
/// @return Return the computed window coordinates.
|
||||||
|
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_DECL vec<3, T, Q> projectZO(
|
||||||
|
vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
||||||
|
|
||||||
|
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param obj Specify the object coordinates.
|
||||||
|
/// @param model Specifies the current modelview matrix
|
||||||
|
/// @param proj Specifies the current projection matrix
|
||||||
|
/// @param viewport Specifies the current viewport
|
||||||
|
/// @return Return the computed window coordinates.
|
||||||
|
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_DECL vec<3, T, Q> projectNO(
|
||||||
|
vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
||||||
|
|
||||||
|
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates using default near and far clip planes definition.
|
||||||
|
/// To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
||||||
|
///
|
||||||
|
/// @param obj Specify the object coordinates.
|
||||||
|
/// @param model Specifies the current modelview matrix
|
||||||
|
/// @param proj Specifies the current projection matrix
|
||||||
|
/// @param viewport Specifies the current viewport
|
||||||
|
/// @return Return the computed window coordinates.
|
||||||
|
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_DECL vec<3, T, Q> project(
|
||||||
|
vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
||||||
|
|
||||||
|
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param win Specify the window coordinates to be mapped.
|
||||||
|
/// @param model Specifies the modelview matrix
|
||||||
|
/// @param proj Specifies the projection matrix
|
||||||
|
/// @param viewport Specifies the viewport
|
||||||
|
/// @return Returns the computed object coordinates.
|
||||||
|
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_DECL vec<3, T, Q> unProjectZO(
|
||||||
|
vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
||||||
|
|
||||||
|
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
|
||||||
|
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
||||||
|
///
|
||||||
|
/// @param win Specify the window coordinates to be mapped.
|
||||||
|
/// @param model Specifies the modelview matrix
|
||||||
|
/// @param proj Specifies the projection matrix
|
||||||
|
/// @param viewport Specifies the viewport
|
||||||
|
/// @return Returns the computed object coordinates.
|
||||||
|
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_DECL vec<3, T, Q> unProjectNO(
|
||||||
|
vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
||||||
|
|
||||||
|
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates using default near and far clip planes definition.
|
||||||
|
/// To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
||||||
|
///
|
||||||
|
/// @param win Specify the window coordinates to be mapped.
|
||||||
|
/// @param model Specifies the modelview matrix
|
||||||
|
/// @param proj Specifies the projection matrix
|
||||||
|
/// @param viewport Specifies the viewport
|
||||||
|
/// @return Returns the computed object coordinates.
|
||||||
|
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_DECL vec<3, T, Q> unProject(
|
||||||
|
vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
||||||
|
|
||||||
|
/// Define a picking region
|
||||||
|
///
|
||||||
|
/// @param center Specify the center of a picking region in window coordinates.
|
||||||
|
/// @param delta Specify the width and height, respectively, of the picking region in window coordinates.
|
||||||
|
/// @param viewport Rendering viewport
|
||||||
|
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
||||||
|
/// @tparam U Currently supported: Floating-point types and integer types.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPickMatrix.xml">gluPickMatrix man page</a>
|
||||||
|
template<typename T, qualifier Q, typename U>
|
||||||
|
GLM_FUNC_DECL mat<4, 4, T, Q> pickMatrix(
|
||||||
|
vec<2, T, Q> const& center, vec<2, T, Q> const& delta, vec<4, U, Q> const& viewport);
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
}//namespace glm
|
||||||
|
|
||||||
|
#include "matrix_projection.inl"
|
104
glm/ext/matrix_projection.inl
Normal file
104
glm/ext/matrix_projection.inl
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
namespace glm
|
||||||
|
{
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_QUALIFIER vec<3, T, Q> projectZO(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
||||||
|
{
|
||||||
|
vec<4, T, Q> tmp = vec<4, T, Q>(obj, static_cast<T>(1));
|
||||||
|
tmp = model * tmp;
|
||||||
|
tmp = proj * tmp;
|
||||||
|
|
||||||
|
tmp /= tmp.w;
|
||||||
|
tmp.x = tmp.x * static_cast<T>(0.5) + static_cast<T>(0.5);
|
||||||
|
tmp.y = tmp.y * static_cast<T>(0.5) + static_cast<T>(0.5);
|
||||||
|
|
||||||
|
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
|
||||||
|
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
|
||||||
|
|
||||||
|
return vec<3, T, Q>(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_QUALIFIER vec<3, T, Q> projectNO(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
||||||
|
{
|
||||||
|
vec<4, T, Q> tmp = vec<4, T, Q>(obj, static_cast<T>(1));
|
||||||
|
tmp = model * tmp;
|
||||||
|
tmp = proj * tmp;
|
||||||
|
|
||||||
|
tmp /= tmp.w;
|
||||||
|
tmp = tmp * static_cast<T>(0.5) + static_cast<T>(0.5);
|
||||||
|
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
|
||||||
|
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
|
||||||
|
|
||||||
|
return vec<3, T, Q>(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_QUALIFIER vec<3, T, Q> project(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return projectZO(obj, model, proj, viewport);
|
||||||
|
else
|
||||||
|
return projectNO(obj, model, proj, viewport);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_QUALIFIER vec<3, T, Q> unProjectZO(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, Q> Inverse = inverse(proj * model);
|
||||||
|
|
||||||
|
vec<4, T, Q> tmp = vec<4, T, Q>(win, T(1));
|
||||||
|
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
|
||||||
|
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
|
||||||
|
tmp.x = tmp.x * static_cast<T>(2) - static_cast<T>(1);
|
||||||
|
tmp.y = tmp.y * static_cast<T>(2) - static_cast<T>(1);
|
||||||
|
|
||||||
|
vec<4, T, Q> obj = Inverse * tmp;
|
||||||
|
obj /= obj.w;
|
||||||
|
|
||||||
|
return vec<3, T, Q>(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_QUALIFIER vec<3, T, Q> unProjectNO(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
||||||
|
{
|
||||||
|
mat<4, 4, T, Q> Inverse = inverse(proj * model);
|
||||||
|
|
||||||
|
vec<4, T, Q> tmp = vec<4, T, Q>(win, T(1));
|
||||||
|
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
|
||||||
|
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
|
||||||
|
tmp = tmp * static_cast<T>(2) - static_cast<T>(1);
|
||||||
|
|
||||||
|
vec<4, T, Q> obj = Inverse * tmp;
|
||||||
|
obj /= obj.w;
|
||||||
|
|
||||||
|
return vec<3, T, Q>(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename U, qualifier Q>
|
||||||
|
GLM_FUNC_QUALIFIER vec<3, T, Q> unProject(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
||||||
|
{
|
||||||
|
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
||||||
|
return unProjectZO(win, model, proj, viewport);
|
||||||
|
else
|
||||||
|
return unProjectNO(win, model, proj, viewport);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, qualifier Q, typename U>
|
||||||
|
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> pickMatrix(vec<2, T, Q> const& center, vec<2, T, Q> const& delta, vec<4, U, Q> const& viewport)
|
||||||
|
{
|
||||||
|
assert(delta.x > static_cast<T>(0) && delta.y > static_cast<T>(0));
|
||||||
|
mat<4, 4, T, Q> Result(static_cast<T>(1));
|
||||||
|
|
||||||
|
if(!(delta.x > static_cast<T>(0) && delta.y > static_cast<T>(0)))
|
||||||
|
return Result; // Error
|
||||||
|
|
||||||
|
vec<3, T, Q> Temp(
|
||||||
|
(static_cast<T>(viewport[2]) - static_cast<T>(2) * (center.x - static_cast<T>(viewport[0]))) / delta.x,
|
||||||
|
(static_cast<T>(viewport[3]) - static_cast<T>(2) * (center.y - static_cast<T>(viewport[1]))) / delta.y,
|
||||||
|
static_cast<T>(0));
|
||||||
|
|
||||||
|
// Translate and scale the picked region to the entire window
|
||||||
|
Result = translate(Result, Temp);
|
||||||
|
return scale(Result, vec<3, T, Q>(static_cast<T>(viewport[2]) / delta.x, static_cast<T>(viewport[3]) / delta.y, static_cast<T>(1)));
|
||||||
|
}
|
||||||
|
}//namespace glm
|
@ -87,607 +87,6 @@ namespace glm
|
|||||||
GLM_FUNC_DECL mat<4, 4, T, Q> scale(
|
GLM_FUNC_DECL mat<4, 4, T, Q> scale(
|
||||||
mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v);
|
mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v);
|
||||||
|
|
||||||
/// Creates a matrix for projecting two-dimensional coordinates onto the screen.
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top, T const& zNear, T const& zFar)
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluOrtho2D.xml">gluOrtho2D man page</a>
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> ortho(
|
|
||||||
T left, T right, T bottom, T top);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH_ZO(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume using right-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH_NO(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH_ZO(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume, using right-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH_NO(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoZO(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoNO(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
|
|
||||||
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume, using right-handed coordinates.
|
|
||||||
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a matrix for an orthographic parallel viewing volume, using the default handedness and default near and far clip planes definition.
|
|
||||||
/// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml">glOrtho man page</a>
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> ortho(
|
|
||||||
T left, T right, T bottom, T top, T zNear, T zFar);
|
|
||||||
|
|
||||||
/// Creates a left handed frustum matrix.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH_ZO(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a left handed frustum matrix.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH_NO(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a right handed frustum matrix.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH_ZO(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a right handed frustum matrix.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH_NO(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a frustum matrix using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumZO(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a frustum matrix using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumNO(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a left handed frustum matrix.
|
|
||||||
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a right handed frustum matrix.
|
|
||||||
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a frustum matrix with default handedness, using the default handedness and default near and far clip planes definition.
|
|
||||||
/// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
|
||||||
///
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glFrustum.xml">glFrustum man page</a>
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> frustum(
|
|
||||||
T left, T right, T bottom, T top, T near, T far);
|
|
||||||
|
|
||||||
|
|
||||||
/// Creates a matrix for a right handed, symetric perspective-view frustum.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH_ZO(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a right handed, symetric perspective-view frustum.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH_NO(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a left handed, symetric perspective-view frustum.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH_ZO(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a left handed, symetric perspective-view frustum.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH_NO(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a symetric perspective-view frustum using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveZO(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a symetric perspective-view frustum using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveNO(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a right handed, symetric perspective-view frustum.
|
|
||||||
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a left handed, symetric perspective-view frustum.
|
|
||||||
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a symetric perspective-view frustum based on the default handedness and default near and far clip planes definition.
|
|
||||||
/// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml">gluPerspective man page</a>
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspective(
|
|
||||||
T fovy, T aspect, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a perspective projection matrix based on a field of view using right-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH_ZO(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a perspective projection matrix based on a field of view using right-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH_NO(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a perspective projection matrix based on a field of view using left-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH_ZO(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a perspective projection matrix based on a field of view using left-handed coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH_NO(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a perspective projection matrix based on a field of view using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovZO(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a perspective projection matrix based on a field of view using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovNO(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a right handed perspective projection matrix based on a field of view.
|
|
||||||
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a left handed perspective projection matrix based on a field of view.
|
|
||||||
/// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Builds a perspective projection matrix based on a field of view and the default handedness and default near and far clip planes definition.
|
|
||||||
/// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
|
||||||
///
|
|
||||||
/// @param fov Expressed in radians.
|
|
||||||
/// @param width Width of the viewport
|
|
||||||
/// @param height Height of the viewport
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFov(
|
|
||||||
T fov, T width, T height, T near, T far);
|
|
||||||
|
|
||||||
/// Creates a matrix for a left handed, symmetric perspective-view frustum with far plane at infinite.
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveLH(
|
|
||||||
T fovy, T aspect, T near);
|
|
||||||
|
|
||||||
/// Creates a matrix for a right handed, symmetric perspective-view frustum with far plane at infinite.
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveRH(
|
|
||||||
T fovy, T aspect, T near);
|
|
||||||
|
|
||||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite with default handedness.
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspective(
|
|
||||||
T fovy, T aspect, T near);
|
|
||||||
|
|
||||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> tweakedInfinitePerspective(
|
|
||||||
T fovy, T aspect, T near);
|
|
||||||
|
|
||||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
|
||||||
///
|
|
||||||
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
|
|
||||||
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
|
|
||||||
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
|
|
||||||
/// @param ep Epsilon
|
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, defaultp> tweakedInfinitePerspective(
|
|
||||||
T fovy, T aspect, T near, T ep);
|
|
||||||
|
|
||||||
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param obj Specify the object coordinates.
|
|
||||||
/// @param model Specifies the current modelview matrix
|
|
||||||
/// @param proj Specifies the current projection matrix
|
|
||||||
/// @param viewport Specifies the current viewport
|
|
||||||
/// @return Return the computed window coordinates.
|
|
||||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_DECL vec<3, T, Q> projectZO(
|
|
||||||
vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
|
||||||
|
|
||||||
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param obj Specify the object coordinates.
|
|
||||||
/// @param model Specifies the current modelview matrix
|
|
||||||
/// @param proj Specifies the current projection matrix
|
|
||||||
/// @param viewport Specifies the current viewport
|
|
||||||
/// @return Return the computed window coordinates.
|
|
||||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_DECL vec<3, T, Q> projectNO(
|
|
||||||
vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
|
||||||
|
|
||||||
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates using default near and far clip planes definition.
|
|
||||||
/// To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
|
||||||
///
|
|
||||||
/// @param obj Specify the object coordinates.
|
|
||||||
/// @param model Specifies the current modelview matrix
|
|
||||||
/// @param proj Specifies the current projection matrix
|
|
||||||
/// @param viewport Specifies the current viewport
|
|
||||||
/// @return Return the computed window coordinates.
|
|
||||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_DECL vec<3, T, Q> project(
|
|
||||||
vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
|
||||||
|
|
||||||
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param win Specify the window coordinates to be mapped.
|
|
||||||
/// @param model Specifies the modelview matrix
|
|
||||||
/// @param proj Specifies the projection matrix
|
|
||||||
/// @param viewport Specifies the viewport
|
|
||||||
/// @return Returns the computed object coordinates.
|
|
||||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_DECL vec<3, T, Q> unProjectZO(
|
|
||||||
vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
|
||||||
|
|
||||||
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
|
|
||||||
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
|
|
||||||
///
|
|
||||||
/// @param win Specify the window coordinates to be mapped.
|
|
||||||
/// @param model Specifies the modelview matrix
|
|
||||||
/// @param proj Specifies the projection matrix
|
|
||||||
/// @param viewport Specifies the viewport
|
|
||||||
/// @return Returns the computed object coordinates.
|
|
||||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_DECL vec<3, T, Q> unProjectNO(
|
|
||||||
vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
|
||||||
|
|
||||||
/// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates using default near and far clip planes definition.
|
|
||||||
/// To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
|
|
||||||
///
|
|
||||||
/// @param win Specify the window coordinates to be mapped.
|
|
||||||
/// @param model Specifies the modelview matrix
|
|
||||||
/// @param proj Specifies the projection matrix
|
|
||||||
/// @param viewport Specifies the viewport
|
|
||||||
/// @return Returns the computed object coordinates.
|
|
||||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_DECL vec<3, T, Q> unProject(
|
|
||||||
vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
|
|
||||||
|
|
||||||
/// Define a picking region
|
|
||||||
///
|
|
||||||
/// @param center Specify the center of a picking region in window coordinates.
|
|
||||||
/// @param delta Specify the width and height, respectively, of the picking region in window coordinates.
|
|
||||||
/// @param viewport Rendering viewport
|
|
||||||
/// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
|
|
||||||
/// @tparam U Currently supported: Floating-point types and integer types.
|
|
||||||
/// @see gtc_matrix_transform
|
|
||||||
/// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPickMatrix.xml">gluPickMatrix man page</a>
|
|
||||||
template<typename T, qualifier Q, typename U>
|
|
||||||
GLM_FUNC_DECL mat<4, 4, T, Q> pickMatrix(
|
|
||||||
vec<2, T, Q> const& center, vec<2, T, Q> const& delta, vec<4, U, Q> const& viewport);
|
|
||||||
|
|
||||||
/// Build a right handed look at view matrix.
|
/// Build a right handed look at view matrix.
|
||||||
///
|
///
|
||||||
/// @param eye Position of the camera
|
/// @param eye Position of the camera
|
||||||
|
@ -95,640 +95,6 @@ namespace glm
|
|||||||
return m * Result;
|
return m * Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> ortho(T left, T right, T bottom, T top)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(1));
|
|
||||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
|
||||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
|
||||||
Result[2][2] = - static_cast<T>(1);
|
|
||||||
Result[3][0] = - (right + left) / (right - left);
|
|
||||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH_ZO(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(1);
|
|
||||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
|
||||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
|
||||||
Result[2][2] = static_cast<T>(1) / (zFar - zNear);
|
|
||||||
Result[3][0] = - (right + left) / (right - left);
|
|
||||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
|
||||||
Result[3][2] = - zNear / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH_NO(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(1);
|
|
||||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
|
||||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
|
||||||
Result[2][2] = static_cast<T>(2) / (zFar - zNear);
|
|
||||||
Result[3][0] = - (right + left) / (right - left);
|
|
||||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
|
||||||
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH_ZO(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(1);
|
|
||||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
|
||||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
|
||||||
Result[2][2] = - static_cast<T>(1) / (zFar - zNear);
|
|
||||||
Result[3][0] = - (right + left) / (right - left);
|
|
||||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
|
||||||
Result[3][2] = - zNear / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH_NO(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(1);
|
|
||||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
|
||||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
|
||||||
Result[2][2] = - static_cast<T>(2) / (zFar - zNear);
|
|
||||||
Result[3][0] = - (right + left) / (right - left);
|
|
||||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
|
||||||
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoZO(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
|
|
||||||
else
|
|
||||||
return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoNO(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return orthoLH_NO(left, right, bottom, top, zNear, zFar);
|
|
||||||
else
|
|
||||||
return orthoRH_NO(left, right, bottom, top, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoLH(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
|
|
||||||
else
|
|
||||||
return orthoLH_NO(left, right, bottom, top, zNear, zFar);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> orthoRH(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
|
|
||||||
else
|
|
||||||
return orthoRH_NO(left, right, bottom, top, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> ortho(T left, T right, T bottom, T top, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO)
|
|
||||||
return orthoLH_ZO(left, right, bottom, top, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO)
|
|
||||||
return orthoLH_NO(left, right, bottom, top, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO)
|
|
||||||
return orthoRH_ZO(left, right, bottom, top, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO)
|
|
||||||
return orthoRH_NO(left, right, bottom, top, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH_ZO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(0);
|
|
||||||
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
|
||||||
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
|
||||||
Result[2][0] = (right + left) / (right - left);
|
|
||||||
Result[2][1] = (top + bottom) / (top - bottom);
|
|
||||||
Result[2][2] = farVal / (farVal - nearVal);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
|
||||||
Result[3][2] = -(farVal * nearVal) / (farVal - nearVal);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH_NO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(0);
|
|
||||||
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
|
||||||
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
|
||||||
Result[2][0] = (right + left) / (right - left);
|
|
||||||
Result[2][1] = (top + bottom) / (top - bottom);
|
|
||||||
Result[2][2] = (farVal + nearVal) / (farVal - nearVal);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
|
||||||
Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH_ZO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(0);
|
|
||||||
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
|
||||||
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
|
||||||
Result[2][0] = (right + left) / (right - left);
|
|
||||||
Result[2][1] = (top + bottom) / (top - bottom);
|
|
||||||
Result[2][2] = farVal / (nearVal - farVal);
|
|
||||||
Result[2][3] = static_cast<T>(-1);
|
|
||||||
Result[3][2] = -(farVal * nearVal) / (farVal - nearVal);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH_NO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, defaultp> Result(0);
|
|
||||||
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
|
||||||
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
|
||||||
Result[2][0] = (right + left) / (right - left);
|
|
||||||
Result[2][1] = (top + bottom) / (top - bottom);
|
|
||||||
Result[2][2] = - (farVal + nearVal) / (farVal - nearVal);
|
|
||||||
Result[2][3] = static_cast<T>(-1);
|
|
||||||
Result[3][2] = - (static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumZO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
else
|
|
||||||
return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumNO(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
else
|
|
||||||
return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumLH(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
else
|
|
||||||
return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustumRH(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
else
|
|
||||||
return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> frustum(T left, T right, T bottom, T top, T nearVal, T farVal)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO)
|
|
||||||
return frustumLH_ZO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO)
|
|
||||||
return frustumLH_NO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO)
|
|
||||||
return frustumRH_ZO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO)
|
|
||||||
return frustumRH_NO(left, right, bottom, top, nearVal, farVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH_ZO(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
|
||||||
|
|
||||||
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
|
||||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
|
||||||
Result[2][2] = zFar / (zNear - zFar);
|
|
||||||
Result[2][3] = - static_cast<T>(1);
|
|
||||||
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH_NO(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
|
||||||
|
|
||||||
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
|
||||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
|
||||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = - static_cast<T>(1);
|
|
||||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH_ZO(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
|
||||||
|
|
||||||
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
|
||||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
|
||||||
Result[2][2] = zFar / (zFar - zNear);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
|
||||||
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH_NO(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
assert(abs(aspect - std::numeric_limits<T>::epsilon()) > static_cast<T>(0));
|
|
||||||
|
|
||||||
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
|
||||||
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
|
||||||
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
|
||||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveZO(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
|
|
||||||
else
|
|
||||||
return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveNO(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return perspectiveLH_NO(fovy, aspect, zNear, zFar);
|
|
||||||
else
|
|
||||||
return perspectiveRH_NO(fovy, aspect, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveLH(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
|
|
||||||
else
|
|
||||||
return perspectiveLH_NO(fovy, aspect, zNear, zFar);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveRH(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
|
|
||||||
else
|
|
||||||
return perspectiveRH_NO(fovy, aspect, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspective(T fovy, T aspect, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO)
|
|
||||||
return perspectiveLH_ZO(fovy, aspect, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO)
|
|
||||||
return perspectiveLH_NO(fovy, aspect, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO)
|
|
||||||
return perspectiveRH_ZO(fovy, aspect, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO)
|
|
||||||
return perspectiveRH_NO(fovy, aspect, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH_ZO(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
assert(width > static_cast<T>(0));
|
|
||||||
assert(height > static_cast<T>(0));
|
|
||||||
assert(fov > static_cast<T>(0));
|
|
||||||
|
|
||||||
T const rad = fov;
|
|
||||||
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
|
||||||
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = w;
|
|
||||||
Result[1][1] = h;
|
|
||||||
Result[2][2] = zFar / (zNear - zFar);
|
|
||||||
Result[2][3] = - static_cast<T>(1);
|
|
||||||
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH_NO(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
assert(width > static_cast<T>(0));
|
|
||||||
assert(height > static_cast<T>(0));
|
|
||||||
assert(fov > static_cast<T>(0));
|
|
||||||
|
|
||||||
T const rad = fov;
|
|
||||||
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
|
||||||
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = w;
|
|
||||||
Result[1][1] = h;
|
|
||||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = - static_cast<T>(1);
|
|
||||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH_ZO(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
assert(width > static_cast<T>(0));
|
|
||||||
assert(height > static_cast<T>(0));
|
|
||||||
assert(fov > static_cast<T>(0));
|
|
||||||
|
|
||||||
T const rad = fov;
|
|
||||||
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
|
||||||
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = w;
|
|
||||||
Result[1][1] = h;
|
|
||||||
Result[2][2] = zFar / (zFar - zNear);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
|
||||||
Result[3][2] = -(zFar * zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH_NO(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
assert(width > static_cast<T>(0));
|
|
||||||
assert(height > static_cast<T>(0));
|
|
||||||
assert(fov > static_cast<T>(0));
|
|
||||||
|
|
||||||
T const rad = fov;
|
|
||||||
T const h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
|
||||||
T const w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = w;
|
|
||||||
Result[1][1] = h;
|
|
||||||
Result[2][2] = (zFar + zNear) / (zFar - zNear);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
|
||||||
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovZO(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
|
|
||||||
else
|
|
||||||
return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovNO(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
|
|
||||||
else
|
|
||||||
return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovLH(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
|
|
||||||
else
|
|
||||||
return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFovRH(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
|
|
||||||
else
|
|
||||||
return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> perspectiveFov(T fov, T width, T height, T zNear, T zFar)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_ZO)
|
|
||||||
return perspectiveFovLH_ZO(fov, width, height, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_LH_NO)
|
|
||||||
return perspectiveFovLH_NO(fov, width, height, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_ZO)
|
|
||||||
return perspectiveFovRH_ZO(fov, width, height, zNear, zFar);
|
|
||||||
else if(GLM_CONFIG_CLIP_CONTROL == GLM_CLIP_CONTROL_RH_NO)
|
|
||||||
return perspectiveFovRH_NO(fov, width, height, zNear, zFar);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveRH(T fovy, T aspect, T zNear)
|
|
||||||
{
|
|
||||||
T const range = tan(fovy / static_cast<T>(2)) * zNear;
|
|
||||||
T const left = -range * aspect;
|
|
||||||
T const right = range * aspect;
|
|
||||||
T const bottom = -range;
|
|
||||||
T const top = range;
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
|
||||||
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
|
||||||
Result[2][2] = - static_cast<T>(1);
|
|
||||||
Result[2][3] = - static_cast<T>(1);
|
|
||||||
Result[3][2] = - static_cast<T>(2) * zNear;
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveLH(T fovy, T aspect, T zNear)
|
|
||||||
{
|
|
||||||
T const range = tan(fovy / static_cast<T>(2)) * zNear;
|
|
||||||
T const left = -range * aspect;
|
|
||||||
T const right = range * aspect;
|
|
||||||
T const bottom = -range;
|
|
||||||
T const top = range;
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(T(0));
|
|
||||||
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
|
||||||
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
|
||||||
Result[2][2] = static_cast<T>(1);
|
|
||||||
Result[2][3] = static_cast<T>(1);
|
|
||||||
Result[3][2] = - static_cast<T>(2) * zNear;
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspective(T fovy, T aspect, T zNear)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_LH_BIT)
|
|
||||||
return infinitePerspectiveLH(fovy, aspect, zNear);
|
|
||||||
else
|
|
||||||
return infinitePerspectiveRH(fovy, aspect, zNear);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear, T ep)
|
|
||||||
{
|
|
||||||
T const range = tan(fovy / static_cast<T>(2)) * zNear;
|
|
||||||
T const left = -range * aspect;
|
|
||||||
T const right = range * aspect;
|
|
||||||
T const bottom = -range;
|
|
||||||
T const top = range;
|
|
||||||
|
|
||||||
mat<4, 4, T, defaultp> Result(static_cast<T>(0));
|
|
||||||
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
|
||||||
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
|
||||||
Result[2][2] = ep - static_cast<T>(1);
|
|
||||||
Result[2][3] = static_cast<T>(-1);
|
|
||||||
Result[3][2] = (ep - static_cast<T>(2)) * zNear;
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> tweakedInfinitePerspective(T fovy, T aspect, T zNear)
|
|
||||||
{
|
|
||||||
return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon<T>());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_QUALIFIER vec<3, T, Q> projectZO(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
|
||||||
{
|
|
||||||
vec<4, T, Q> tmp = vec<4, T, Q>(obj, static_cast<T>(1));
|
|
||||||
tmp = model * tmp;
|
|
||||||
tmp = proj * tmp;
|
|
||||||
|
|
||||||
tmp /= tmp.w;
|
|
||||||
tmp.x = tmp.x * static_cast<T>(0.5) + static_cast<T>(0.5);
|
|
||||||
tmp.y = tmp.y * static_cast<T>(0.5) + static_cast<T>(0.5);
|
|
||||||
|
|
||||||
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
|
|
||||||
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
|
|
||||||
|
|
||||||
return vec<3, T, Q>(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_QUALIFIER vec<3, T, Q> projectNO(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
|
||||||
{
|
|
||||||
vec<4, T, Q> tmp = vec<4, T, Q>(obj, static_cast<T>(1));
|
|
||||||
tmp = model * tmp;
|
|
||||||
tmp = proj * tmp;
|
|
||||||
|
|
||||||
tmp /= tmp.w;
|
|
||||||
tmp = tmp * static_cast<T>(0.5) + static_cast<T>(0.5);
|
|
||||||
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
|
|
||||||
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
|
|
||||||
|
|
||||||
return vec<3, T, Q>(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_QUALIFIER vec<3, T, Q> project(vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return projectZO(obj, model, proj, viewport);
|
|
||||||
else
|
|
||||||
return projectNO(obj, model, proj, viewport);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_QUALIFIER vec<3, T, Q> unProjectZO(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, Q> Inverse = inverse(proj * model);
|
|
||||||
|
|
||||||
vec<4, T, Q> tmp = vec<4, T, Q>(win, T(1));
|
|
||||||
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
|
|
||||||
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
|
|
||||||
tmp.x = tmp.x * static_cast<T>(2) - static_cast<T>(1);
|
|
||||||
tmp.y = tmp.y * static_cast<T>(2) - static_cast<T>(1);
|
|
||||||
|
|
||||||
vec<4, T, Q> obj = Inverse * tmp;
|
|
||||||
obj /= obj.w;
|
|
||||||
|
|
||||||
return vec<3, T, Q>(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_QUALIFIER vec<3, T, Q> unProjectNO(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
|
||||||
{
|
|
||||||
mat<4, 4, T, Q> Inverse = inverse(proj * model);
|
|
||||||
|
|
||||||
vec<4, T, Q> tmp = vec<4, T, Q>(win, T(1));
|
|
||||||
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
|
|
||||||
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
|
|
||||||
tmp = tmp * static_cast<T>(2) - static_cast<T>(1);
|
|
||||||
|
|
||||||
vec<4, T, Q> obj = Inverse * tmp;
|
|
||||||
obj /= obj.w;
|
|
||||||
|
|
||||||
return vec<3, T, Q>(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename U, qualifier Q>
|
|
||||||
GLM_FUNC_QUALIFIER vec<3, T, Q> unProject(vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport)
|
|
||||||
{
|
|
||||||
if(GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT)
|
|
||||||
return unProjectZO(win, model, proj, viewport);
|
|
||||||
else
|
|
||||||
return unProjectNO(win, model, proj, viewport);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, qualifier Q, typename U>
|
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> pickMatrix(vec<2, T, Q> const& center, vec<2, T, Q> const& delta, vec<4, U, Q> const& viewport)
|
|
||||||
{
|
|
||||||
assert(delta.x > static_cast<T>(0) && delta.y > static_cast<T>(0));
|
|
||||||
mat<4, 4, T, Q> Result(static_cast<T>(1));
|
|
||||||
|
|
||||||
if(!(delta.x > static_cast<T>(0) && delta.y > static_cast<T>(0)))
|
|
||||||
return Result; // Error
|
|
||||||
|
|
||||||
vec<3, T, Q> Temp(
|
|
||||||
(static_cast<T>(viewport[2]) - static_cast<T>(2) * (center.x - static_cast<T>(viewport[0]))) / delta.x,
|
|
||||||
(static_cast<T>(viewport[3]) - static_cast<T>(2) * (center.y - static_cast<T>(viewport[1]))) / delta.y,
|
|
||||||
static_cast<T>(0));
|
|
||||||
|
|
||||||
// Translate and scale the picked region to the entire window
|
|
||||||
Result = translate(Result, Temp);
|
|
||||||
return scale(Result, vec<3, T, Q>(static_cast<T>(viewport[2]) / delta.x, static_cast<T>(viewport[3]) / delta.y, static_cast<T>(1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, qualifier Q>
|
template<typename T, qualifier Q>
|
||||||
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> lookAtRH(vec<3, T, Q> const& eye, vec<3, T, Q> const& center, vec<3, T, Q> const& up)
|
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> lookAtRH(vec<3, T, Q> const& eye, vec<3, T, Q> const& center, vec<3, T, Q> const& up)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "../vec2.hpp"
|
#include "../vec2.hpp"
|
||||||
#include "../vec3.hpp"
|
#include "../vec3.hpp"
|
||||||
#include "../vec4.hpp"
|
#include "../vec4.hpp"
|
||||||
|
#include "../ext/matrix_projection.hpp"
|
||||||
|
#include "../ext/matrix_clip_space.hpp"
|
||||||
#include "../ext/matrix_transform.hpp"
|
#include "../ext/matrix_transform.hpp"
|
||||||
|
|
||||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||||
|
@ -13,8 +13,6 @@ glmCreateTestGTC(ext_scalar_uint_sized)
|
|||||||
glmCreateTestGTC(ext_scalar_relational)
|
glmCreateTestGTC(ext_scalar_relational)
|
||||||
glmCreateTestGTC(ext_vec1)
|
glmCreateTestGTC(ext_vec1)
|
||||||
glmCreateTestGTC(ext_vector_bool1)
|
glmCreateTestGTC(ext_vector_bool1)
|
||||||
glmCreateTestGTC(ext_vector_float1)
|
glmCreateTestGTC(ext_vector_iec559)
|
||||||
glmCreateTestGTC(ext_vector_double1)
|
glmCreateTestGTC(ext_vector_integer)
|
||||||
glmCreateTestGTC(ext_vector_int1)
|
|
||||||
glmCreateTestGTC(ext_vector_uint1)
|
|
||||||
glmCreateTestGTC(ext_vector_relational)
|
glmCreateTestGTC(ext_vector_relational)
|
||||||
|
13
test/ext/ext_matrix_clip_space.cpp
Normal file
13
test/ext/ext_matrix_clip_space.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <glm/ext/matrix_relational.hpp>
|
||||||
|
#include <glm/ext/matrix_clip_space.hpp>
|
||||||
|
#include <glm/ext/matrix_float4x4.hpp>
|
||||||
|
#include <glm/ext/vector_relational.hpp>
|
||||||
|
#include <glm/ext/vector_float4.hpp>
|
||||||
|
#include <glm/ext/vector_float3.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
13
test/ext/ext_matrix_projection.cpp
Normal file
13
test/ext/ext_matrix_projection.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <glm/ext/matrix_relational.hpp>
|
||||||
|
#include <glm/ext/matrix_projection.hpp>
|
||||||
|
#include <glm/ext/matrix_float4x4.hpp>
|
||||||
|
#include <glm/ext/vector_relational.hpp>
|
||||||
|
#include <glm/ext/vector_float4.hpp>
|
||||||
|
#include <glm/ext/vector_float3.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
@ -18,12 +18,30 @@ static int test_translate()
|
|||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_scale()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::mat4 const M(1.0f);
|
||||||
|
glm::vec3 const V(2.0f);
|
||||||
|
|
||||||
|
glm::mat4 const S = glm::scale(M, V);
|
||||||
|
glm::mat4 const R = glm::mat4(
|
||||||
|
glm::vec4(2, 0, 0, 0),
|
||||||
|
glm::vec4(0, 2, 0, 0),
|
||||||
|
glm::vec4(0, 0, 2, 0),
|
||||||
|
glm::vec4(0, 0, 0, 1));
|
||||||
|
Error += glm::all(glm::equal(S, R, glm::epsilon<float>())) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
Error += test_translate();
|
Error += test_translate();
|
||||||
|
Error += test_scale();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
#include <glm/gtc/constants.hpp>
|
|
||||||
#include <glm/ext/scalar_relational.hpp>
|
|
||||||
#include <glm/ext/vector_relational.hpp>
|
|
||||||
#include <glm/ext/vector_double1.hpp>
|
|
||||||
#include <glm/ext/vector_double1_precision.hpp>
|
|
||||||
#include <glm/ext/vector_double2.hpp>
|
|
||||||
#include <glm/ext/vector_double3.hpp>
|
|
||||||
#include <glm/ext/vector_double4.hpp>
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_operators()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
genType const A(1);
|
|
||||||
genType const B(1);
|
|
||||||
|
|
||||||
genType const C = A + B;
|
|
||||||
Error += glm::all(glm::equal(C, genType(2), glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const D = A - B;
|
|
||||||
Error += glm::all(glm::equal(D, genType(0), glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const E = A * B;
|
|
||||||
Error += glm::all(glm::equal(E, genType(1), glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const F = A / B;
|
|
||||||
Error += glm::all(glm::equal(F, genType(1), glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_ctor()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::dvec1 const A = genType(1);
|
|
||||||
|
|
||||||
glm::dvec1 const E(genType(1));
|
|
||||||
Error += glm::all(glm::equal(A, E, glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::dvec1 const F(E);
|
|
||||||
Error += glm::all(glm::equal(A, F, glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const B = genType(1);
|
|
||||||
genType const G(glm::dvec2(1));
|
|
||||||
Error += glm::all(glm::equal(B, G, glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const H(glm::dvec3(1));
|
|
||||||
Error += glm::all(glm::equal(B, H, glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const I(glm::dvec4(1));
|
|
||||||
Error += glm::all(glm::equal(B, I, glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_size()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::dvec1) == sizeof(genType) ? 0 : 1;
|
|
||||||
Error += genType().length() == 1 ? 0 : 1;
|
|
||||||
Error += genType::length() == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_relational()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
genType const A(1);
|
|
||||||
genType const B(1);
|
|
||||||
genType const C(0);
|
|
||||||
|
|
||||||
Error += all(equal(A, B, glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
Error += any(notEqual(A, C, glm::epsilon<double>())) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_constexpr()
|
|
||||||
{
|
|
||||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
|
||||||
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_operators<glm::dvec1>();
|
|
||||||
Error += test_operators<glm::lowp_dvec1>();
|
|
||||||
Error += test_operators<glm::mediump_dvec1>();
|
|
||||||
Error += test_operators<glm::highp_dvec1>();
|
|
||||||
|
|
||||||
Error += test_ctor<glm::dvec1>();
|
|
||||||
Error += test_ctor<glm::lowp_dvec1>();
|
|
||||||
Error += test_ctor<glm::mediump_dvec1>();
|
|
||||||
Error += test_ctor<glm::highp_dvec1>();
|
|
||||||
|
|
||||||
Error += test_size<glm::dvec1>();
|
|
||||||
Error += test_size<glm::lowp_dvec1>();
|
|
||||||
Error += test_size<glm::mediump_dvec1>();
|
|
||||||
Error += test_size<glm::highp_dvec1>();
|
|
||||||
|
|
||||||
Error += test_relational<glm::dvec1>();
|
|
||||||
Error += test_relational<glm::lowp_dvec1>();
|
|
||||||
Error += test_relational<glm::mediump_dvec1>();
|
|
||||||
Error += test_relational<glm::highp_dvec1>();
|
|
||||||
|
|
||||||
Error += test_constexpr<glm::dvec1>();
|
|
||||||
Error += test_constexpr<glm::lowp_dvec1>();
|
|
||||||
Error += test_constexpr<glm::mediump_dvec1>();
|
|
||||||
Error += test_constexpr<glm::highp_dvec1>();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
#include <glm/gtc/constants.hpp>
|
|
||||||
#include <glm/ext/vector_relational.hpp>
|
|
||||||
#include <glm/ext/vector_float1.hpp>
|
|
||||||
#include <glm/ext/vector_float1_precision.hpp>
|
|
||||||
#include <glm/ext/vector_float2.hpp>
|
|
||||||
#include <glm/ext/vector_float3.hpp>
|
|
||||||
#include <glm/ext/vector_float4.hpp>
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_operators()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
genType const A(1);
|
|
||||||
genType const B(1);
|
|
||||||
|
|
||||||
genType const C = A + B;
|
|
||||||
Error += glm::all(glm::equal(C, genType(2), glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const D = A - B;
|
|
||||||
Error += glm::all(glm::equal(D, genType(0), glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const E = A * B;
|
|
||||||
Error += glm::all(glm::equal(E, genType(1), glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const F = A / B;
|
|
||||||
Error += glm::all(glm::equal(F, genType(1), glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_ctor()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::vec1 const A = genType(1);
|
|
||||||
|
|
||||||
glm::vec1 const E(genType(1));
|
|
||||||
Error += glm::all(glm::equal(A, E, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
glm::vec1 const F(E);
|
|
||||||
Error += glm::all(glm::equal(A, F, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const B = genType(1);
|
|
||||||
genType const G(glm::vec2(1));
|
|
||||||
Error += glm::all(glm::equal(B, G, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const H(glm::vec3(1));
|
|
||||||
Error += glm::all(glm::equal(B, H, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const I(glm::vec4(1));
|
|
||||||
Error += glm::all(glm::equal(B, I, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_size()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::vec1) == sizeof(genType) ? 0 : 1;
|
|
||||||
Error += genType().length() == 1 ? 0 : 1;
|
|
||||||
Error += genType::length() == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_relational()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
genType const A(1);
|
|
||||||
genType const B(1);
|
|
||||||
genType const C(0);
|
|
||||||
|
|
||||||
Error += all(equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
Error += any(notEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_constexpr()
|
|
||||||
{
|
|
||||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
|
||||||
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_operators<glm::vec1>();
|
|
||||||
Error += test_operators<glm::lowp_vec1>();
|
|
||||||
Error += test_operators<glm::mediump_vec1>();
|
|
||||||
Error += test_operators<glm::highp_vec1>();
|
|
||||||
|
|
||||||
Error += test_ctor<glm::vec1>();
|
|
||||||
Error += test_ctor<glm::lowp_vec1>();
|
|
||||||
Error += test_ctor<glm::mediump_vec1>();
|
|
||||||
Error += test_ctor<glm::highp_vec1>();
|
|
||||||
|
|
||||||
Error += test_size<glm::vec1>();
|
|
||||||
Error += test_size<glm::lowp_vec1>();
|
|
||||||
Error += test_size<glm::mediump_vec1>();
|
|
||||||
Error += test_size<glm::highp_vec1>();
|
|
||||||
|
|
||||||
Error += test_relational<glm::vec1>();
|
|
||||||
Error += test_relational<glm::lowp_vec1>();
|
|
||||||
Error += test_relational<glm::mediump_vec1>();
|
|
||||||
Error += test_relational<glm::highp_vec1>();
|
|
||||||
|
|
||||||
Error += test_constexpr<glm::vec1>();
|
|
||||||
Error += test_constexpr<glm::lowp_vec1>();
|
|
||||||
Error += test_constexpr<glm::mediump_vec1>();
|
|
||||||
Error += test_constexpr<glm::highp_vec1>();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
166
test/ext/ext_vector_iec559.cpp
Normal file
166
test/ext/ext_vector_iec559.cpp
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
#include <glm/gtc/constants.hpp>
|
||||||
|
#include <glm/ext/scalar_relational.hpp>
|
||||||
|
#include <glm/ext/vector_relational.hpp>
|
||||||
|
#include <glm/ext/vector_double1.hpp>
|
||||||
|
#include <glm/ext/vector_double1_precision.hpp>
|
||||||
|
#include <glm/ext/vector_double2.hpp>
|
||||||
|
#include <glm/ext/vector_double3.hpp>
|
||||||
|
#include <glm/ext/vector_double4.hpp>
|
||||||
|
#include <glm/ext/vector_float1.hpp>
|
||||||
|
#include <glm/ext/vector_float1_precision.hpp>
|
||||||
|
#include <glm/ext/vector_float2.hpp>
|
||||||
|
#include <glm/ext/vector_float3.hpp>
|
||||||
|
#include <glm/ext/vector_float4.hpp>
|
||||||
|
|
||||||
|
template <typename genType>
|
||||||
|
static int test_operators()
|
||||||
|
{
|
||||||
|
typedef typename genType::value_type valType;
|
||||||
|
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
genType const A(1);
|
||||||
|
genType const B(1);
|
||||||
|
|
||||||
|
genType const C = A + B;
|
||||||
|
Error += glm::all(glm::equal(C, genType(2), glm::epsilon<valType>())) ? 0 : 1;
|
||||||
|
|
||||||
|
genType const D = A - B;
|
||||||
|
Error += glm::all(glm::equal(D, genType(0), glm::epsilon<valType>())) ? 0 : 1;
|
||||||
|
|
||||||
|
genType const E = A * B;
|
||||||
|
Error += glm::all(glm::equal(E, genType(1), glm::epsilon<valType>())) ? 0 : 1;
|
||||||
|
|
||||||
|
genType const F = A / B;
|
||||||
|
Error += glm::all(glm::equal(F, genType(1), glm::epsilon<valType>())) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename genType>
|
||||||
|
static int test_ctor()
|
||||||
|
{
|
||||||
|
typedef typename genType::value_type T;
|
||||||
|
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::vec<1, T> const A = genType(1);
|
||||||
|
|
||||||
|
glm::vec<1, T> const E(genType(1));
|
||||||
|
Error += glm::all(glm::equal(A, E, glm::epsilon<T>())) ? 0 : 1;
|
||||||
|
|
||||||
|
glm::vec<1, T> const F(E);
|
||||||
|
Error += glm::all(glm::equal(A, F, glm::epsilon<T>())) ? 0 : 1;
|
||||||
|
|
||||||
|
genType const B = genType(1);
|
||||||
|
genType const G(glm::vec<2, T>(1));
|
||||||
|
Error += glm::all(glm::equal(B, G, glm::epsilon<T>())) ? 0 : 1;
|
||||||
|
|
||||||
|
genType const H(glm::vec<3, T>(1));
|
||||||
|
Error += glm::all(glm::equal(B, H, glm::epsilon<T>())) ? 0 : 1;
|
||||||
|
|
||||||
|
genType const I(glm::vec<4, T>(1));
|
||||||
|
Error += glm::all(glm::equal(B, I, glm::epsilon<T>())) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename genType>
|
||||||
|
static int test_size()
|
||||||
|
{
|
||||||
|
typedef typename genType::value_type T;
|
||||||
|
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
Error += sizeof(glm::vec<1, T>) == sizeof(genType) ? 0 : 1;
|
||||||
|
Error += genType().length() == 1 ? 0 : 1;
|
||||||
|
Error += genType::length() == 1 ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename genType>
|
||||||
|
static int test_relational()
|
||||||
|
{
|
||||||
|
typedef typename genType::value_type valType;
|
||||||
|
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
genType const A(1);
|
||||||
|
genType const B(1);
|
||||||
|
genType const C(0);
|
||||||
|
|
||||||
|
Error += all(equal(A, B, glm::epsilon<valType>())) ? 0 : 1;
|
||||||
|
Error += any(notEqual(A, C, glm::epsilon<valType>())) ? 0 : 1;
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename genType>
|
||||||
|
static int test_constexpr()
|
||||||
|
{
|
||||||
|
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||||
|
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
Error += test_operators<glm::dvec1>();
|
||||||
|
Error += test_operators<glm::lowp_dvec1>();
|
||||||
|
Error += test_operators<glm::mediump_dvec1>();
|
||||||
|
Error += test_operators<glm::highp_dvec1>();
|
||||||
|
|
||||||
|
Error += test_ctor<glm::dvec1>();
|
||||||
|
Error += test_ctor<glm::lowp_dvec1>();
|
||||||
|
Error += test_ctor<glm::mediump_dvec1>();
|
||||||
|
Error += test_ctor<glm::highp_dvec1>();
|
||||||
|
|
||||||
|
Error += test_size<glm::dvec1>();
|
||||||
|
Error += test_size<glm::lowp_dvec1>();
|
||||||
|
Error += test_size<glm::mediump_dvec1>();
|
||||||
|
Error += test_size<glm::highp_dvec1>();
|
||||||
|
|
||||||
|
Error += test_relational<glm::dvec1>();
|
||||||
|
Error += test_relational<glm::lowp_dvec1>();
|
||||||
|
Error += test_relational<glm::mediump_dvec1>();
|
||||||
|
Error += test_relational<glm::highp_dvec1>();
|
||||||
|
|
||||||
|
Error += test_constexpr<glm::dvec1>();
|
||||||
|
Error += test_constexpr<glm::lowp_dvec1>();
|
||||||
|
Error += test_constexpr<glm::mediump_dvec1>();
|
||||||
|
Error += test_constexpr<glm::highp_dvec1>();
|
||||||
|
|
||||||
|
Error += test_operators<glm::vec1>();
|
||||||
|
Error += test_operators<glm::lowp_vec1>();
|
||||||
|
Error += test_operators<glm::mediump_vec1>();
|
||||||
|
Error += test_operators<glm::highp_vec1>();
|
||||||
|
|
||||||
|
Error += test_ctor<glm::vec1>();
|
||||||
|
Error += test_ctor<glm::lowp_vec1>();
|
||||||
|
Error += test_ctor<glm::mediump_vec1>();
|
||||||
|
Error += test_ctor<glm::highp_vec1>();
|
||||||
|
|
||||||
|
Error += test_size<glm::vec1>();
|
||||||
|
Error += test_size<glm::lowp_vec1>();
|
||||||
|
Error += test_size<glm::mediump_vec1>();
|
||||||
|
Error += test_size<glm::highp_vec1>();
|
||||||
|
|
||||||
|
Error += test_relational<glm::vec1>();
|
||||||
|
Error += test_relational<glm::lowp_vec1>();
|
||||||
|
Error += test_relational<glm::mediump_vec1>();
|
||||||
|
Error += test_relational<glm::highp_vec1>();
|
||||||
|
|
||||||
|
Error += test_constexpr<glm::vec1>();
|
||||||
|
Error += test_constexpr<glm::lowp_vec1>();
|
||||||
|
Error += test_constexpr<glm::mediump_vec1>();
|
||||||
|
Error += test_constexpr<glm::highp_vec1>();
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
@ -3,6 +3,11 @@
|
|||||||
#include <glm/ext/vector_int2.hpp>
|
#include <glm/ext/vector_int2.hpp>
|
||||||
#include <glm/ext/vector_int3.hpp>
|
#include <glm/ext/vector_int3.hpp>
|
||||||
#include <glm/ext/vector_int4.hpp>
|
#include <glm/ext/vector_int4.hpp>
|
||||||
|
#include <glm/ext/vector_uint1.hpp>
|
||||||
|
#include <glm/ext/vector_uint1_precision.hpp>
|
||||||
|
#include <glm/ext/vector_uint2.hpp>
|
||||||
|
#include <glm/ext/vector_uint3.hpp>
|
||||||
|
#include <glm/ext/vector_uint4.hpp>
|
||||||
#include <glm/vector_relational.hpp>
|
#include <glm/vector_relational.hpp>
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -82,24 +87,26 @@ static int test_operators()
|
|||||||
template <typename genType>
|
template <typename genType>
|
||||||
static int test_ctor()
|
static int test_ctor()
|
||||||
{
|
{
|
||||||
|
typedef typename genType::value_type T;
|
||||||
|
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
glm::ivec1 const A = genType(1);
|
genType const A = genType(1);
|
||||||
|
|
||||||
glm::ivec1 const E(genType(1));
|
genType const E(genType(1));
|
||||||
Error += A == E ? 0 : 1;
|
Error += A == E ? 0 : 1;
|
||||||
|
|
||||||
glm::ivec1 const F(E);
|
genType const F(E);
|
||||||
Error += A == F ? 0 : 1;
|
Error += A == F ? 0 : 1;
|
||||||
|
|
||||||
genType const B = genType(1);
|
genType const B = genType(1);
|
||||||
genType const G(glm::ivec2(1));
|
genType const G(glm::vec<2, T>(1));
|
||||||
Error += B == G ? 0 : 1;
|
Error += B == G ? 0 : 1;
|
||||||
|
|
||||||
genType const H(glm::ivec3(1));
|
genType const H(glm::vec<3, T>(1));
|
||||||
Error += B == H ? 0 : 1;
|
Error += B == H ? 0 : 1;
|
||||||
|
|
||||||
genType const I(glm::ivec4(1));
|
genType const I(glm::vec<4, T>(1));
|
||||||
Error += B == I ? 0 : 1;
|
Error += B == I ? 0 : 1;
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
@ -110,7 +117,7 @@ static int test_size()
|
|||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
Error += sizeof(glm::ivec1) == sizeof(genType) ? 0 : 1;
|
Error += sizeof(typename genType::value_type) == sizeof(genType) ? 0 : 1;
|
||||||
Error += genType().length() == 1 ? 0 : 1;
|
Error += genType().length() == 1 ? 0 : 1;
|
||||||
Error += genType::length() == 1 ? 0 : 1;
|
Error += genType::length() == 1 ? 0 : 1;
|
||||||
|
|
||||||
@ -140,7 +147,7 @@ static int test_constexpr()
|
|||||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||||
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
||||||
static_assert(genType(1)[0] == 1, "GLM: Failed constexpr");
|
static_assert(genType(1)[0] == 1, "GLM: Failed constexpr");
|
||||||
static_assert(genType(1) == genType(glm::ivec1(1)), "GLM: Failed constexpr");
|
static_assert(genType(1) == genType(1), "GLM: Failed constexpr");
|
||||||
static_assert(genType(1) != genType(0), "GLM: Failed constexpr");
|
static_assert(genType(1) != genType(0), "GLM: Failed constexpr");
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -176,5 +183,30 @@ int main()
|
|||||||
Error += test_constexpr<glm::mediump_ivec1>();
|
Error += test_constexpr<glm::mediump_ivec1>();
|
||||||
Error += test_constexpr<glm::highp_ivec1>();
|
Error += test_constexpr<glm::highp_ivec1>();
|
||||||
|
|
||||||
|
Error += test_operators<glm::uvec1>();
|
||||||
|
Error += test_operators<glm::lowp_uvec1>();
|
||||||
|
Error += test_operators<glm::mediump_uvec1>();
|
||||||
|
Error += test_operators<glm::highp_uvec1>();
|
||||||
|
|
||||||
|
Error += test_ctor<glm::uvec1>();
|
||||||
|
Error += test_ctor<glm::lowp_uvec1>();
|
||||||
|
Error += test_ctor<glm::mediump_uvec1>();
|
||||||
|
Error += test_ctor<glm::highp_uvec1>();
|
||||||
|
|
||||||
|
Error += test_size<glm::uvec1>();
|
||||||
|
Error += test_size<glm::lowp_uvec1>();
|
||||||
|
Error += test_size<glm::mediump_uvec1>();
|
||||||
|
Error += test_size<glm::highp_uvec1>();
|
||||||
|
|
||||||
|
Error += test_relational<glm::uvec1>();
|
||||||
|
Error += test_relational<glm::lowp_uvec1>();
|
||||||
|
Error += test_relational<glm::mediump_uvec1>();
|
||||||
|
Error += test_relational<glm::highp_uvec1>();
|
||||||
|
|
||||||
|
Error += test_constexpr<glm::uvec1>();
|
||||||
|
Error += test_constexpr<glm::lowp_uvec1>();
|
||||||
|
Error += test_constexpr<glm::mediump_uvec1>();
|
||||||
|
Error += test_constexpr<glm::highp_uvec1>();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
@ -1,180 +0,0 @@
|
|||||||
#include <glm/ext/vector_uint1.hpp>
|
|
||||||
#include <glm/ext/vector_uint1_precision.hpp>
|
|
||||||
#include <glm/ext/vector_uint2.hpp>
|
|
||||||
#include <glm/ext/vector_uint3.hpp>
|
|
||||||
#include <glm/ext/vector_uint4.hpp>
|
|
||||||
#include <glm/ext/vector_relational.hpp>
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_operators()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
genType const A(1);
|
|
||||||
genType const B(1);
|
|
||||||
|
|
||||||
bool const R = A != B;
|
|
||||||
bool const S = A == B;
|
|
||||||
Error += (S && !R) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
genType const A(1);
|
|
||||||
genType const B(1);
|
|
||||||
|
|
||||||
genType const C = A + B;
|
|
||||||
Error += C == genType(2) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const D = A - B;
|
|
||||||
Error += D == genType(0) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const E = A * B;
|
|
||||||
Error += E == genType(1) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const F = A / B;
|
|
||||||
Error += F == genType(1) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
genType const A(3);
|
|
||||||
genType const B(2);
|
|
||||||
|
|
||||||
genType const C = A % B;
|
|
||||||
Error += C == genType(1) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
genType const A(1);
|
|
||||||
genType const B(1);
|
|
||||||
genType const C(0);
|
|
||||||
|
|
||||||
genType const I = A & B;
|
|
||||||
Error += I == genType(1) ? 0 : 1;
|
|
||||||
genType const D = A & C;
|
|
||||||
Error += D == genType(0) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const E = A | B;
|
|
||||||
Error += E == genType(1) ? 0 : 1;
|
|
||||||
genType const F = A | C;
|
|
||||||
Error += F == genType(1) ? 0 : 1;
|
|
||||||
|
|
||||||
genType const G = A ^ B;
|
|
||||||
Error += G == genType(0) ? 0 : 1;
|
|
||||||
genType const H = A ^ C;
|
|
||||||
Error += H == genType(1) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
genType const A(0);
|
|
||||||
genType const B(1);
|
|
||||||
genType const C(2);
|
|
||||||
|
|
||||||
genType const D = B << B;
|
|
||||||
Error += D == genType(2) ? 0 : 1;
|
|
||||||
genType const E = C >> B;
|
|
||||||
Error += E == genType(1) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_ctor()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
glm::uvec1 const A = genType(1);
|
|
||||||
|
|
||||||
glm::uvec1 const E(genType(1));
|
|
||||||
Error += A == E ? 0 : 1;
|
|
||||||
|
|
||||||
glm::uvec1 const F(E);
|
|
||||||
Error += A == F ? 0 : 1;
|
|
||||||
|
|
||||||
genType const B = genType(1);
|
|
||||||
genType const G(glm::uvec2(1));
|
|
||||||
Error += B == G ? 0 : 1;
|
|
||||||
|
|
||||||
genType const H(glm::uvec3(1));
|
|
||||||
Error += B == H ? 0 : 1;
|
|
||||||
|
|
||||||
genType const I(glm::uvec4(1));
|
|
||||||
Error += B == I ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_size()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += sizeof(glm::uvec1) == sizeof(genType) ? 0 : 1;
|
|
||||||
Error += genType().length() == 1 ? 0 : 1;
|
|
||||||
Error += genType::length() == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_relational()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
genType const A(1);
|
|
||||||
genType const B(1);
|
|
||||||
genType const C(0);
|
|
||||||
|
|
||||||
Error += A == B ? 0 : 1;
|
|
||||||
Error += A != C ? 0 : 1;
|
|
||||||
Error += all(equal(A, B)) ? 0 : 1;
|
|
||||||
Error += any(notEqual(A, C)) ? 0 : 1;
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
static int test_constexpr()
|
|
||||||
{
|
|
||||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
|
||||||
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
|
||||||
static_assert(genType(1)[0] == 1, "GLM: Failed constexpr");
|
|
||||||
static_assert(genType(1) == genType(glm::uvec1(1)), "GLM: Failed constexpr");
|
|
||||||
static_assert(genType(1) != genType(0), "GLM: Failed constexpr");
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error = 0;
|
|
||||||
|
|
||||||
Error += test_operators<glm::uvec1>();
|
|
||||||
Error += test_operators<glm::lowp_uvec1>();
|
|
||||||
Error += test_operators<glm::mediump_uvec1>();
|
|
||||||
Error += test_operators<glm::highp_uvec1>();
|
|
||||||
|
|
||||||
Error += test_ctor<glm::uvec1>();
|
|
||||||
Error += test_ctor<glm::lowp_uvec1>();
|
|
||||||
Error += test_ctor<glm::mediump_uvec1>();
|
|
||||||
Error += test_ctor<glm::highp_uvec1>();
|
|
||||||
|
|
||||||
Error += test_size<glm::uvec1>();
|
|
||||||
Error += test_size<glm::lowp_uvec1>();
|
|
||||||
Error += test_size<glm::mediump_uvec1>();
|
|
||||||
Error += test_size<glm::highp_uvec1>();
|
|
||||||
|
|
||||||
Error += test_relational<glm::uvec1>();
|
|
||||||
Error += test_relational<glm::lowp_uvec1>();
|
|
||||||
Error += test_relational<glm::mediump_uvec1>();
|
|
||||||
Error += test_relational<glm::highp_uvec1>();
|
|
||||||
|
|
||||||
Error += test_constexpr<glm::uvec1>();
|
|
||||||
Error += test_constexpr<glm::lowp_uvec1>();
|
|
||||||
Error += test_constexpr<glm::mediump_uvec1>();
|
|
||||||
Error += test_constexpr<glm::highp_uvec1>();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user