diff --git a/include/cglm/call/cam.h b/include/cglm/call/cam.h index fe0ee61..ad5adcd 100644 --- a/include/cglm/call/cam.h +++ b/include/cglm/call/cam.h @@ -63,6 +63,10 @@ CGLM_EXPORT void glmc_perspective_default(float aspect, mat4 dest); +CGLM_EXPORT +void +glmc_perspective_default_infinite(float aspect, mat4 dest); + CGLM_EXPORT void glmc_perspective_resize(float aspect, mat4 proj); diff --git a/include/cglm/cam.h b/include/cglm/cam.h index 4760e5b..73677de 100644 --- a/include/cglm/cam.h +++ b/include/cglm/cam.h @@ -30,6 +30,7 @@ float nearZ, mat4 dest) CGLM_INLINE void glm_perspective_default(float aspect, mat4 dest) + CGLM_INLINE void glm_perspective_default_infinite(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize(float aspect, mat4 proj) CGLM_INLINE void glm_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest) CGLM_INLINE void glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) @@ -343,6 +344,27 @@ glm_perspective_default(float aspect, mat4 dest) { #endif } +/*! + * @brief set up infinite perspective projection matrix with default near + * and angle values + * + * @param[in] aspect aspect ratio ( width / height ) + * @param[out] dest result matrix + */ +CGLM_INLINE +void +glm_perspective_default_infinite(float aspect, mat4 dest) { +#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO + glm_perspective_default_infinite_lh_zo(aspect, dest); +#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO + glm_perspective_default_infinite_lh_no(aspect, dest); +#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO + glm_perspective_default_infinite_rh_zo(aspect, dest); +#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO + glm_perspective_default_infinite_rh_no(aspect, dest); +#endif +} + /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport diff --git a/include/cglm/clipspace/persp_lh_no.h b/include/cglm/clipspace/persp_lh_no.h index 1b7d030..6126b72 100644 --- a/include/cglm/clipspace/persp_lh_no.h +++ b/include/cglm/clipspace/persp_lh_no.h @@ -21,6 +21,7 @@ float nearZ, mat4 dest) CGLM_INLINE void glm_perspective_default_lh_no(float aspect, mat4 dest) + CGLM_INLINE void glm_perspective_default_infinite_lh_no(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize_lh_no(float aspect, mat4 proj) CGLM_INLINE void glm_persp_move_far_lh_no(mat4 proj, float deltaFar) @@ -165,6 +166,20 @@ glm_perspective_default_lh_no(float aspect, mat4 dest) { glm_perspective_lh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest); } +/*! + * @brief set up infinite perspective projection matrix with default near + * and angle values with a left-hand coordinate system and a + * clip-space of [-1, 1]. + * + * @param[in] aspect aspect ratio ( width / height ) + * @param[out] dest result matrix + */ +CGLM_INLINE +void +glm_perspective_default_infinite_lh_no(float aspect, mat4 dest) { + glm_perspective_infinite_lh_no(GLM_PI_4f, aspect, 0.01f, dest); +} + /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport diff --git a/include/cglm/clipspace/persp_lh_zo.h b/include/cglm/clipspace/persp_lh_zo.h index a1d193e..905eacb 100644 --- a/include/cglm/clipspace/persp_lh_zo.h +++ b/include/cglm/clipspace/persp_lh_zo.h @@ -21,6 +21,7 @@ float nearZ, mat4 dest) CGLM_INLINE void glm_perspective_default_lh_zo(float aspect, mat4 dest) + CGLM_INLINE void glm_perspective_default_infinite_lh_zo(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize_lh_zo(float aspect, mat4 proj) CGLM_INLINE void glm_persp_move_far_lh_zo(mat4 proj, float deltaFar) @@ -177,7 +178,7 @@ glm_persp_move_far_lh_zo(mat4 proj, float deltaFar) { /*! * @brief set up perspective projection matrix with default near/far - * and angle values with a left-hand coordinate system and a + * and angle values with a left-hand coordinate system and a * clip-space of [0, 1]. * * @param[in] aspect aspect ratio ( width / height ) @@ -189,6 +190,20 @@ glm_perspective_default_lh_zo(float aspect, mat4 dest) { glm_perspective_lh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest); } +/*! + * @brief set up infinite perspective projection matrix with default near + * and angle values with a left-hand coordinate system and a + * clip-space of [0, 1]. + * + * @param[in] aspect aspect ratio ( width / height ) + * @param[out] dest result matrix + */ +CGLM_INLINE +void +glm_perspective_default_infinite_lh_zo(float aspect, mat4 dest) { + glm_perspective_infinite_lh_zo(GLM_PI_4f, aspect, 0.01f, dest); +} + /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport diff --git a/include/cglm/clipspace/persp_rh_no.h b/include/cglm/clipspace/persp_rh_no.h index a052470..9ef719d 100644 --- a/include/cglm/clipspace/persp_rh_no.h +++ b/include/cglm/clipspace/persp_rh_no.h @@ -21,6 +21,7 @@ float nearZ, mat4 dest) CGLM_INLINE void glm_perspective_default_rh_no(float aspect, mat4 dest) + CGLM_INLINE void glm_perspective_default_infinite_rh_no(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize_rh_no(float aspect, mat4 proj) CGLM_INLINE void glm_persp_move_far_rh_no(mat4 proj, float deltaFar) @@ -165,6 +166,20 @@ glm_perspective_default_rh_no(float aspect, mat4 dest) { glm_perspective_rh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest); } +/*! + * @brief set up infinite perspective projection matrix with default near + * and angle values with a right-hand coordinate system and a + * clip-space of [-1, 1]. + * + * @param[in] aspect aspect ratio ( width / height ) + * @param[out] dest result matrix + */ +CGLM_INLINE +void +glm_perspective_default_infinite_rh_no(float aspect, mat4 dest) { + glm_perspective_infinite_rh_no(GLM_PI_4f, aspect, 0.01f, dest); +} + /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport diff --git a/include/cglm/clipspace/persp_rh_zo.h b/include/cglm/clipspace/persp_rh_zo.h index 9c38191..7aaabab 100644 --- a/include/cglm/clipspace/persp_rh_zo.h +++ b/include/cglm/clipspace/persp_rh_zo.h @@ -21,6 +21,7 @@ float nearZ, mat4 dest) CGLM_INLINE void glm_perspective_default_rh_zo(float aspect, mat4 dest) + CGLM_INLINE void glm_perspective_default_infinite_rh_zo(float aspect, mat4 dest) CGLM_INLINE void glm_perspective_resize_rh_zo(float aspect, mat4 proj) CGLM_INLINE void glm_persp_move_far_rh_zo(mat4 proj, float deltaFar) @@ -163,6 +164,20 @@ glm_perspective_default_rh_zo(float aspect, mat4 dest) { glm_perspective_rh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest); } +/*! + * @brief set up infinite perspective projection matrix with default near + * and angle values with a right-hand coordinate system and a + * clip-space of [0, 1]. + * + * @param[in] aspect aspect ratio ( width / height ) + * @param[out] dest result matrix + */ +CGLM_INLINE +void +glm_perspective_default_infinite_rh_zo(float aspect, mat4 dest) { + glm_perspective_infinite_rh_zo(GLM_PI_4f, aspect, 0.01f, dest); +} + /*! * @brief resize perspective matrix by aspect ratio ( width / height ) * this makes very easy to resize proj matrix when window /viewport diff --git a/src/cam.c b/src/cam.c index 24ac602..0c03ce4 100644 --- a/src/cam.c +++ b/src/cam.c @@ -80,6 +80,12 @@ glmc_perspective_default(float aspect, mat4 dest) { glm_perspective_default(aspect, dest); } +CGLM_EXPORT +void +glmc_perspective_default_infinite(float aspect, mat4 dest) { + glm_perspective_default_infinite(aspect, dest); +} + CGLM_EXPORT void glmc_perspective_resize(float aspect, mat4 proj) {