feat(mat4.hpp): add cpp port

This commit is contained in:
2025-08-13 09:37:52 +02:00
parent 9d7e47045e
commit a5a9cc596d
2 changed files with 27 additions and 7 deletions

View File

@@ -1,13 +1,9 @@
#include <iostream>
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;
}

24
src/math/mat4.hpp Normal file
View File

@@ -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; }
};
}