31 #include <glm/glm.hpp>
52 Vec2(T x, T y): x(x), y(y) {}
58 T & operator[](std::size_t i) {
return (&x)[i]; }
59 const T & operator[](std::size_t i)
const {
return (&x)[i]; }
73 Vec4(T x, T y, T z, T w): x(x), y(y), z(z), w(w) {}
79 T & operator[](std::size_t i) {
return (&x)[i]; }
80 const T & operator[](std::size_t i)
const {
return (&x)[i]; }
89 Vec4<T> data_[4]{{}, {}, {}, {}};
94 Mat4(Vec4<T> & x,
const Vec4<T> & y,
const Vec4<T> & z,
const Vec4<T> &w)
96 data_[0] = x; data_[1] = y; data_[2] = z; data_[3] = w;
99 Mat4(T xx, T xy, T xz, T xw,
100 T yx, T yy, T yz, T yw,
101 T zx, T zy, T zz, T zw,
102 T wx, T wy, T wz, T ww)
104 data_[0][0] = xx; data_[0][1] = xy; data_[0][2] = xz; data_[0][3] = xw;
105 data_[1][0] = yx; data_[1][1] = yy; data_[1][2] = yz; data_[1][3] = yw;
106 data_[2][0] = zx; data_[2][1] = zy; data_[2][2] = zz; data_[2][3] = zw;
107 data_[3][0] = wx; data_[3][1] = wy; data_[3][2] = wz; data_[3][3] = ww;
110 Mat4(T diagonal):
Mat4(diagonal, 0, 0, 0,
120 Vec4<T> & operator[](std::size_t i) {
return data_[i]; }
121 const Vec4<T> & operator[](std::size_t i)
const {
return data_[i]; }
126 template <
typename U>
127 Mat4<decltype(std::declval<T>() * std::declval<U>())>
operator*(
const Mat4<U> & b)
const
130 for(
int col = 0; col < 4; ++col)
132 for(
int row = 0; row < 4; ++row)
135 for(
int k = 0; k < 4; ++k)
136 out[col][row] += data_[k][row] * b[col][k];
143 template <
typename U>
144 Mat4<decltype(std::declval<T>() * std::declval<U>())> &
operator*=(
const Mat4<U> & b)
146 return *
this = *
this * b;
152 template<
typename T>
struct Vec2_t {
using type = Vec2<T>; };
153 template<
typename T>
struct Vec4_t {
using type = Vec4<T>; };
154 template<
typename T>
struct Mat4_t {
using type = Mat4<T>; };
158 template<>
struct Vec2_t<float> {
using type = glm::vec2; };
159 template<>
struct Vec2_t<double> {
using type = glm::dvec2; };
160 template<>
struct Vec2_t<int> {
using type = glm::ivec2; };
161 template<>
struct Vec2_t<unsigned int> {
using type = glm::uvec2; };
163 template<>
struct Vec4_t<float> {
using type = glm::vec4; };
164 template<>
struct Vec4_t<double> {
using type = glm::dvec4; };
165 template<>
struct Vec4_t<int> {
using type = glm::ivec4; };
166 template<>
struct Vec4_t<unsigned int> {
using type = glm::uvec4; };
168 template<>
struct Mat4_t<float> {
using type = glm::mat4; };
169 template<>
struct Mat4_t<double> {
using type = glm::dmat4; };
176 template<
typename T =
float>
using Vec2 =
typename detail::Vec2_t<T>::type;
181 template<
typename T =
float>
using Vec4 =
typename detail::Vec4_t<T>::type;
186 template<
typename T =
float>
using Mat4 =
typename detail::Mat4_t<T>::type;
OpenGL Font rendering types.
Definition: font.hpp:35
Vec4< float > Color
Color vector
Definition: types.hpp:191
typename detail::Mat4_t< T >::type Mat4
4D Matrix
Definition: types.hpp:186
typename detail::Vec4_t< T >::type Vec4
4D Vector
Definition: types.hpp:181
typename detail::Vec2_t< T >::type Vec2
2D Vector
Definition: types.hpp:176