How to initialize a glm::mat4 with an array?

j00hi picture j00hi · Sep 8, 2011 · Viewed 48k times · Source

I'm using the OpenGL Mathematics Library (glm.g-truc.net) and want to initialize a glm::mat4 with a float-array.

float aaa[16];
glm::mat4 bbb(aaa);

This doesn't work.

I guess the solution is trivial, but I don't know how to do it. I couldn't find a good documentation about glm. I would appreciate some helpful links.

Answer

Matthew Marshall picture Matthew Marshall · Sep 13, 2011

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);