JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Mat4.hpp
Go to the documentation of this file.
1// Copyright 2021-2023 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include <boost/qvm_lite.hpp>
8#include <initializer_list>
9
10namespace jngl {
11
15class Mat4 {
16public:
18 Mat4() = default;
19
22
24 float data[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
25};
26
27} // namespace jngl
28
29namespace boost::qvm {
30template <> struct mat_traits<jngl::Mat4> {
31 static int const rows = 4;
32 static int const cols = 4;
33 using scalar_type = float;
34
35 template <int R, int C> static scalar_type read_element(const jngl::Mat4& m) {
36 return m.data[C * 4 + R];
37 }
38 template <int R, int C> static scalar_type& write_element(jngl::Mat4& m) {
39 return m.data[C * 4 + R];
40 }
41};
42} // namespace boost::qvm
4x4 matrix
Definition Mat4.hpp:15
Mat4()=default
creates identity matrix
float data[16]
column-major
Definition Mat4.hpp:24
Mat4(std::initializer_list< float >)
construct matrix from row-major array with 16 elements
JNGL's main namespace.