I\'m tinkering with OpenGL using glfw, glad, and glm. In one of the tutorials I\'m using, they demonstrate some simple usage of glm as so:
glm::vec4 vec(1.0f
You have to initialize the matrix variable glm::mat4 trans
.
The glm API documentation refers to The OpenGL Shading Language specification 4.20.
5.4.2 Vector and Matrix Constructors
If there is a single scalar parameter to a vector constructor, it is used to initialize all components of the constructed vector to that scalar’s value. If there is a single scalar parameter to a matrix constructor, it is used to initialize all the components on the matrix’s diagonal, with the remaining components initialized to 0.0.
This means, that an identity matrix can be initialized by the single parameter 1.0: glm::mat4(1.0f)
.
Change your code somehow like this:
glm::mat4 trans(1.0f);
See also OpenGL Mathematics (GLM); 2. Vector and Matrix Constructors
Answering my own question: though the tutorial and other sources said that glm would automatically instantiate an identity vector for
glm::mat4 trans;
it did not. Looking at a different tutorial, it seems that you can do so explicitly with
glm::mat4 trans = glm::mat4(1.0f);
And this solved the problem!