diff --git a/CMakeLists.txt b/CMakeLists.txt index da50691..c8f847f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,5 +21,8 @@ list(FILTER SOURCES EXCLUDE REGEX ".*src/main\\.c$") foreach(test_src ${TEST_SOURCES}) get_filename_component(test_name ${test_src} NAME_WE) add_executable(${test_name} ${test_src} ${SOURCES}) + if(NOT MSVC) + target_link_libraries(${test_name} m) + endif() add_test(NAME ${test_name} COMMAND ${test_name}) endforeach() \ No newline at end of file diff --git a/src/main.c b/src/main.c index 09d4445..f277e94 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,13 @@ #include -#include "math/vec4.h" +#include "math/mat4.h" int main(void) { + float arr[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + Mat4f_t mat1 = mat4f_from_array(arr); + Mat4f_t mat2 = mat4f_scalar(1); + Mat4f_t mat3 = mat4f_zero(); + Mat4f_t mat4 = mat4f_identity(); + printf("%f", arr[1]); return 0; } diff --git a/src/math/mat4.c b/src/math/mat4.c index 70c92e2..e49fd20 100644 --- a/src/math/mat4.c +++ b/src/math/mat4.c @@ -1,27 +1,69 @@ -// #include "mat4.h" -// #include "math.h" +#include "mat4.h" -// Mat4_t mat4(const float arr[16]) -// { -// Mat4_t mat; -// memcpy(mat.m, arr, 16*sizeof(float)); -// return mat; -// } +Mat4f_t mat4f_from_array(const float arr[16]) +{ + Mat4f_t mat; + for(int i = 0; i