Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 613
j00hi Avatar asked Sep 08 '11 16:09

j00hi


People also ask

What is glm :: mat4?

The default constructor glm::mat4() creates diagonal matrix with 1.0f diagonal, that is, the identity matrix: glm::mat4 m4; // construct identity matrix.

Can you use glm in C?

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.

What does glm stand for OpenGL?

OpenGL Mathematics (GLM) GLM is a C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification.

Is glm column major?

Matrices in GLSL are column-major unless explicitly qualified as row-major. GLM stores matrices in column-major order.


1 Answers

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); 
like image 146
Matthew Marshall Avatar answered Oct 11 '22 12:10

Matthew Marshall