mirror of
https://github.com/recp/cglm.git
synced 2026-01-03 14:12:11 +00:00
extract fovy and aspect for perpective matrix
This commit is contained in:
25
test/src/test_cam.c
Normal file
25
test/src/test_cam.c
Normal 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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -9,4 +9,8 @@
|
||||
/* mat4 */
|
||||
void test_mat4(void **state);
|
||||
|
||||
/* camera */
|
||||
void
|
||||
test_camera_decomp(void **state);
|
||||
|
||||
#endif /* test_tests_h */
|
||||
|
||||
Reference in New Issue
Block a user