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.
The default constructor glm::mat4() creates diagonal matrix with 1.0f diagonal, that is, the identity matrix: glm::mat4 m4; // construct identity matrix.
There is a new optimized OpenGL/Graphics Math for C. The original glm library is for C++ only (templates, namespaces, classes…). This new library is targeted to C99 but currently you can use it for C89 safely by language extensions.
OpenGL Mathematics (GLM) GLM is a C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification.
Matrices in GLSL are column-major unless explicitly qualified as row-major. GLM stores matrices in column-major order.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With