How to initialize a glm::mat4 with an array?
Although there isn't a constructor, GLM includes make_* functions in glm/gtc/type_ptr.hpp:
#include <glm/gtc/type_ptr.hpp>
float aaa[16];
glm::mat4 bbb = glm::make_mat4(aaa);
You can also directly copy the memory:
float aaa[16] = {
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16
};
glm::mat4 bbb;
memcpy( glm::value_ptr( bbb ), aaa, sizeof( aaa ) );
You could write an adapter function:
template<typename T>
tvec4<T> tvec4_from_t(const T *arr) {
return tvec4<T>(arr[0], arr[1], arr[2], arr[3]);
}
template<typename T>
tmat4<T> tmat4_from_t(const T *arr) {
return tmat4<T>(tvec4_from_t(arr), tvec4_from_t(arr + 4), tvec4_from_t(arr + 8), tvec4_from_t(arr + 12));
}
// later
float aaa[16];
glm::mat4 bbb = tmac4_from_t(aaa);