Hi,
am working on my template skills.
Example is vec4 and mat4, but there are also vec2/3 and square mat2/3.
The vec's data is
template <typename T>
struct vec4_t {
union {
struct{ T x, y, z, w; };
struct{ T r, g, b, a; };
struct{ T s, t, u, v; };
};
....
and the corresponding mat's
template<typename T>
struct mat4_t {
vec4_t<T> value[4];
....
Unfortunately, the 4 vectors are not tightly in a row without padding, on my machine there are two garbage values between each vector, so that if i obtain a pointer to m[0][0] i can not use it directly to for example feed a uniform with it. I have looked over glm (which i took as an example for my tinkering), but the guy performs things depending on platform and compiler that are a little over my head.
My question is, is there an easy C++ way (alignas ?) to achieve a tight packing of the vecs in a mat ?
Sure, there are different ways to solve it (like use an array of 16 values in case of a mat4), but i'd have to rewrite a lot of things then ...
Cheers