From a5a9cc596d30854295e010141b7cb09d96a3bc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Wed, 13 Aug 2025 09:37:52 +0200 Subject: [PATCH] feat(mat4.hpp): add cpp port --- src/main.cpp | 10 +++------- src/math/mat4.hpp | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 src/math/mat4.hpp diff --git a/src/main.cpp b/src/main.cpp index 6fe6c07..787dc3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,9 @@ #include - -extern "C" -{ - #include "math/mat4.h" - #include "math/vec3.h" - #include "math/vec4.h" -} +#include "math/mat4.hpp" int main() { + math::Mat4f test = math::Mat4f::Identity(); + std::cout << test.data().m[0] << test.data().m[5] << test.data().m[10] << test.data().m[15] << std::endl; return 0; } \ No newline at end of file diff --git a/src/math/mat4.hpp b/src/math/mat4.hpp new file mode 100644 index 0000000..caa79bc --- /dev/null +++ b/src/math/mat4.hpp @@ -0,0 +1,24 @@ +extern "C" +{ + #include "mat4.h" +} + +namespace math +{ + class Mat4f + { + private: + Mat4f_t mat4; + + public: + Mat4f() { mat4f_zero_r(&mat4); } + explicit Mat4f(const Mat4f_t& m) : mat4(m) {} + explicit Mat4f(const float arr[16]) { mat4f_from_array_r(&mat4, arr); } + + static Mat4f Identity() { Mat4f mat; mat4f_identity_r(&mat.mat4); return mat; } + static Mat4f Zero() { Mat4f mat; mat4f_zero_r(&mat.mat4); return mat; } + + const Mat4f_t& data() const { return mat4; } + Mat4f_t& data() { return mat4; } + }; +} \ No newline at end of file