diff --git a/include/cglm/struct/cam.h b/include/cglm/struct/cam.h index d3c35b0..2a92af7 100644 --- a/include/cglm/struct/cam.h +++ b/include/cglm/struct/cam.h @@ -322,20 +322,24 @@ glms_perspective_default(float aspect) { * this makes very easy to resize proj matrix when window /viewport * reized * + * NOTE: if you dodn't want to create new matrix then use array api on struct.raw + * like glms_perspective_resize(proj.raw, aspect) to avoid create new mat4 + * each time + * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE -void +mat4s glms_perspective_resize(mat4s proj, float aspect) { #if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO - glms_perspective_resize_lh_zo(proj, aspect); + return glms_perspective_resize_lh_zo(proj, aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO - glms_perspective_resize_lh_no(proj, aspect); + return glms_perspective_resize_lh_no(proj, aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO - glms_perspective_resize_rh_zo(proj, aspect); + return glms_perspective_resize_rh_zo(proj, aspect); #elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO - glms_perspective_resize_rh_no(proj, aspect); + return glms_perspective_resize_rh_no(proj, aspect); #endif } diff --git a/include/cglm/struct/clipspace/persp_lh_no.h b/include/cglm/struct/clipspace/persp_lh_no.h index 42d325d..1c1bb68 100644 --- a/include/cglm/struct/clipspace/persp_lh_no.h +++ b/include/cglm/struct/clipspace/persp_lh_no.h @@ -127,13 +127,20 @@ glms_perspective_default_lh_no(float aspect) { * reized with a left-hand coordinate system and a * clip-space of [-1, 1]. * + * NOTE: if you dodn't want to create new matrix then use array api on struct.raw + * like glm_perspective_resize_lh_no(proj.raw, aspect) to avoid create new mat4 + * each time + * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE -void +mat4s glms_perspective_resize_lh_no(mat4s proj, float aspect) { - glm_perspective_resize_lh_no(aspect, proj.raw); + mat4s dest; + dest = proj; + glm_perspective_resize_lh_no(aspect, dest.raw); + return dest; } /*! diff --git a/include/cglm/struct/clipspace/persp_lh_zo.h b/include/cglm/struct/clipspace/persp_lh_zo.h index 488a1e4..230301f 100644 --- a/include/cglm/struct/clipspace/persp_lh_zo.h +++ b/include/cglm/struct/clipspace/persp_lh_zo.h @@ -127,13 +127,20 @@ glms_perspective_default_lh_zo(float aspect) { * reized with a left-hand coordinate system and a * clip-space of [0, 1]. * + * NOTE: if you dodn't want to create new matrix then use array api on struct.raw + * like glms_perspective_resize_lh_zo(proj.raw, aspect) to avoid create new mat4 + * each time + * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE -void +mat4s glms_perspective_resize_lh_zo(mat4s proj, float aspect) { - glm_perspective_resize_lh_zo(aspect, proj.raw); + mat4s dest; + dest = proj; + glm_perspective_resize_lh_zo(aspect, dest.raw); + return dest; } /*! diff --git a/include/cglm/struct/clipspace/persp_rh_no.h b/include/cglm/struct/clipspace/persp_rh_no.h index 942b677..7170e9a 100644 --- a/include/cglm/struct/clipspace/persp_rh_no.h +++ b/include/cglm/struct/clipspace/persp_rh_no.h @@ -127,13 +127,20 @@ glms_perspective_default_rh_no(float aspect) { * reized with a right-hand coordinate system and a * clip-space of [-1, 1]. * + * NOTE: if you dodn't want to create new matrix then use array api on struct.raw + * like glm_perspective_resize_rh_no(proj.raw, aspect) to avoid create new mat4 + * each time + * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE -void +mat4s glms_perspective_resize_rh_no(mat4s proj, float aspect) { - glm_perspective_resize_rh_no(aspect, proj.raw); + mat4s dest; + dest = proj; + glm_perspective_resize_rh_no(aspect, dest.raw); + return dest; } /*! diff --git a/include/cglm/struct/clipspace/persp_rh_zo.h b/include/cglm/struct/clipspace/persp_rh_zo.h index a00d9d7..ff4d8de 100644 --- a/include/cglm/struct/clipspace/persp_rh_zo.h +++ b/include/cglm/struct/clipspace/persp_rh_zo.h @@ -127,13 +127,20 @@ glms_perspective_default_rh_zo(float aspect) { * reized with a right-hand coordinate system and a * clip-space of [0, 1]. * + * NOTE: if you dodn't want to create new matrix then use array api on struct.raw + * like glm_perspective_resize_rh_zo(proj.raw, aspect) to avoid create new mat4 + * each time + * * @param[in, out] proj perspective projection matrix * @param[in] aspect aspect ratio ( width / height ) */ CGLM_INLINE -void +mat4s glms_perspective_resize_rh_zo(mat4s proj, float aspect) { - glm_perspective_resize_rh_zo(aspect, proj.raw); + mat4s dest; + dest = proj; + glm_perspective_resize_rh_zo(aspect, dest.raw); + return dest; } /*!