Skip to content

Commit f6341a1

Browse files
authored
Merge pull request #1317 from Zuzu-Typ/fix-matrix-clip-space
Fixed infinitePerspective declarations and definitions
2 parents 5b295d8 + d03194c commit f6341a1

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

glm/ext/matrix_clip_space.hpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,56 @@ namespace glm
461461
T fov, T width, T height, T near, T far);
462462

463463
/// Creates a matrix for a left-handed, symmetric perspective-view frustum with far plane at infinite.
464+
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
465+
///
466+
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
467+
/// @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).
468+
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
469+
///
470+
/// @tparam T A floating-point scalar type
471+
template<typename T>
472+
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveLH_ZO(
473+
T fovy, T aspect, T near);
474+
475+
/// Creates a matrix for a left-handed, symmetric perspective-view frustum with far plane at infinite.
476+
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
477+
///
478+
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
479+
/// @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).
480+
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
481+
///
482+
/// @tparam T A floating-point scalar type
483+
template<typename T>
484+
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveLH_NO(
485+
T fovy, T aspect, T near);
486+
487+
/// Creates a matrix for a right-handed, symmetric perspective-view frustum with far plane at infinite.
488+
/// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
489+
///
490+
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
491+
/// @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).
492+
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
493+
///
494+
/// @tparam T A floating-point scalar type
495+
template<typename T>
496+
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveRH_ZO(
497+
T fovy, T aspect, T near);
498+
499+
/// Creates a matrix for a right-handed, symmetric perspective-view frustum with far plane at infinite.
500+
/// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
501+
///
502+
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
503+
/// @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).
504+
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
505+
///
506+
/// @tparam T A floating-point scalar type
507+
template<typename T>
508+
GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveRH_NO(
509+
T fovy, T aspect, T near);
510+
511+
/// Creates a matrix for a left-handed, symmetric perspective-view frustum with far plane at infinite.
512+
/// 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)
513+
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
464514
///
465515
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
466516
/// @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).
@@ -472,6 +522,8 @@ namespace glm
472522
T fovy, T aspect, T near);
473523

474524
/// Creates a matrix for a right-handed, symmetric perspective-view frustum with far plane at infinite.
525+
/// 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)
526+
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
475527
///
476528
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
477529
/// @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).
@@ -483,6 +535,8 @@ namespace glm
483535
T fovy, T aspect, T near);
484536

485537
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite with default handedness.
538+
/// 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)
539+
/// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
486540
///
487541
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
488542
/// @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).

glm/ext/matrix_clip_space.inl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,26 @@ namespace glm
554554
return Result;
555555
}
556556

557+
template<typename T>
558+
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveRH(T fovy, T aspect, T zNear)
559+
{
560+
# if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
561+
return infinitePerspectiveRH_ZO(fovy, aspect, zNear);
562+
# else
563+
return infinitePerspectiveRH_NO(fovy, aspect, zNear);
564+
# endif
565+
}
566+
567+
template<typename T>
568+
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspectiveLH(T fovy, T aspect, T zNear)
569+
{
570+
# if GLM_CONFIG_CLIP_CONTROL & GLM_CLIP_CONTROL_ZO_BIT
571+
return infinitePerspectiveLH_ZO(fovy, aspect, zNear);
572+
# else
573+
return infinitePerspectiveLH_NO(fovy, aspect, zNear);
574+
# endif
575+
}
576+
557577
template<typename T>
558578
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> infinitePerspective(T fovy, T aspect, T zNear)
559579
{

0 commit comments

Comments
 (0)