JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
jngl
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
10
namespace
jngl
{
11
15
class
Mat4
{
16
public
:
18
Mat4
() =
default
;
19
21
Mat4
(
std::initializer_list<float>
);
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
29
namespace
boost::qvm {
30
template
<>
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
jngl::Mat4
4x4 matrix
Definition
Mat4.hpp:15
jngl::Mat4::Mat4
Mat4()=default
creates identity matrix
jngl::Mat4::data
float data[16]
column-major
Definition
Mat4.hpp:24
jngl::Mat4::Mat4
Mat4(std::initializer_list< float >)
construct matrix from row-major array with 16 elements
std::function
initializer_list
jngl
JNGL's main namespace.
Definition
Achievement.hpp:10