extract fovy and aspect for perpective matrix

This commit is contained in:
Recep Aslantas
2018-01-04 11:16:09 +03:00
parent 3e4f52b3af
commit 797c4581ee
5 changed files with 59 additions and 1 deletions

25
test/src/test_cam.c Normal file
View File

@@ -0,0 +1,25 @@
/*
* 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"
void
test_camera_decomp(void **state) {
mat4 proj;
float aspect, fovy, nearVal, farVal;
aspect = 0.782f;
fovy = glm_rad(49.984f);
nearVal = 0.1f;
farVal = 100.0f;
glm_perspective(fovy, aspect, nearVal, farVal, proj);
assert_true(fabsf(aspect - glm_persp_aspect(proj)) < FLT_EPSILON);
assert_true(fabsf(fovy - glm_persp_fovy(proj)) < FLT_EPSILON);
assert_true(fabsf(49.984f - glm_deg(glm_persp_fovy(proj))) < FLT_EPSILON);
}

View File

@@ -11,6 +11,9 @@ main(int argc, const char * argv[]) {
const struct CMUnitTest tests[] = {
/* mat4 */
cmocka_unit_test(test_mat4),
/* camera */
cmocka_unit_test(test_camera_decomp)
};
return cmocka_run_group_tests(tests,

View File

@@ -9,4 +9,8 @@
/* mat4 */
void test_mat4(void **state);
/* camera */
void
test_camera_decomp(void **state);
#endif /* test_tests_h */