diff options
author | sanine <sanine.not@pm.me> | 2022-06-14 00:06:42 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-06-14 00:06:42 -0500 |
commit | 2f518e5e28d35ae24a5ac0e31000835e43b01972 (patch) | |
tree | 47fdeb9fa5b04e267702acb06424d3f87b37dd84 /libs/cglm/test/src/test_cam_lh_zo.c | |
parent | 034d5c965ff34cfdf4b153af9f32360a02e35684 (diff) |
add cglm as 3rd-party library
Diffstat (limited to 'libs/cglm/test/src/test_cam_lh_zo.c')
-rw-r--r-- | libs/cglm/test/src/test_cam_lh_zo.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libs/cglm/test/src/test_cam_lh_zo.c b/libs/cglm/test/src/test_cam_lh_zo.c new file mode 100644 index 0000000..f5f50af --- /dev/null +++ b/libs/cglm/test/src/test_cam_lh_zo.c @@ -0,0 +1,36 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#include "test_common.h" + +TEST_IMPL(perspective_lh_zo) { + mat4 dst; + const float fovy = glm_rad(45.0f); + const float aspect = 640/480.0f; + const float zNearVal = 0.1f; + const float zFarVal = 100.0f; + + glm_perspective_lh_zo(fovy, aspect, zNearVal, zFarVal, dst); + + /* Sanity mk. I: longhand version */ + ASSERT(test_eq(dst[0][0], 1.0f / (tanf(fovy / 2) * aspect))) + ASSERT(test_eq(dst[1][1], 1.0f / tanf(fovy / 2))) + ASSERT(test_eq(dst[2][2], zFarVal / (zFarVal - zNearVal))) + ASSERT(test_eq(dst[2][3], 1.0f)) + ASSERT(test_eq(dst[3][2], -1 * zFarVal * zNearVal / (zFarVal - zNearVal))) + + /* Sanity mk. II */ + /* "Reference values" generated by GLM's glm::perspectiveLH_ZO */ + mat4 cmp = {0}; + cmp[0][0] = 1.8106601f; + cmp[1][1] = 2.4142134f; + cmp[2][2] = 1.0010010f; + cmp[2][3] = 1.0000000f; + cmp[3][2] = -0.1001001f; + + return test_assert_mat4_eq(dst, cmp); +} |