#pragma once #include namespace plot::math { /// Column-major 3x3 matrix of `f32`, the layout OpenGL expects for `mat3` /// uniforms. struct Mat3 { f32 m[9] = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}; static constexpr Mat3 identity() noexcept { return Mat3{}; } /// Column-major product `(*this) * rhs`. constexpr Mat3 operator*(const Mat3& rhs) const noexcept { Mat3 out{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; for (usize col = 0; col < 3; ++col) { for (usize row = 0; row < 3; ++row) { f32 acc = 0.0f; for (usize k = 0; k < 3; ++k) acc += m[k * 3 + row] * rhs.m[col * 3 + k]; out.m[col * 3 + row] = acc; } } return out; } }; } // namespace plot::math namespace plot { using math::Mat3; }