JNGL
Mat4.hpp
Go to the documentation of this file.
1 // Copyright 2021 Jan Niklas Hasse <[email protected]>
2 // For conditions of distribution and use, see copyright notice in LICENSE.txt
5 #pragma once
6 
7 #if !defined(__has_include) || __has_include("boost/version.hpp")
8 #include <boost/version.hpp>
9 #endif
10 #include <initializer_list>
11 
12 namespace jngl {
13 
17 class Mat4 {
18 public:
20  Mat4() = default;
21 
24 
26  float data[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
27 };
28 
29 } // namespace jngl
30 
31 #if BOOST_VERSION >= 106200 || __has_include("boost/qvm/mat_traits.hpp")
32 #include <boost/qvm/mat_traits.hpp>
33 
34 namespace boost::qvm {
35 template <> struct mat_traits<jngl::Mat4> {
36  static int const rows = 4;
37  static int const cols = 4;
38  using scalar_type = float;
39 
40  template <int R, int C> static scalar_type read_element(const jngl::Mat4& m) {
41  return m.data[C * 4 + R];
42  }
43  template <int R, int C> static scalar_type& write_element(jngl::Mat4& m) {
44  return m.data[C * 4 + R];
45  }
46 };
47 } // namespace boost::qvm
48 #endif
4x4 matrix
Definition: Mat4.hpp:17
Mat4()=default
creates identity matrix
float data[16]
column-major
Definition: Mat4.hpp:26
Mat4(std::initializer_list< float >)
construct matrix from row-major array with 16 elements
JNGL's main namespace.
Definition: App.hpp:10