Search code examples
c++openglglm-math

Coordinates using idenity matrix won't work


Basically i am supplying the vertex shader with an idenify matrix and for some reason it doesn't work.

This is my C++ code:

glm::mat4 trans;
GLuint transformLoc = glGetUniformLocation(program, "transform");
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, glm::value_ptr(trans));

I am doing this after glUseProgram().

This is my vertex shader code:

#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 inColor; 
layout (location = 2) in vec2 texCoord; 

out vec3 ourColor;
out vec2 ourTextCoord;

uniform mat4 transform;

void main()
{   
    gl_Position = transform * vec4(position, 1.0f);
    ourTextCoord = texCoord;
    ourColor = inColor;

};

gl_Position = vec4(position, 1.0f) works fine, but multiplying it with the identify matrix doesn't work...

Edit: All i see is a black screen.


Solution

  • As of 0.9.9.0 GLM no longer identity-initializes (or anything-initialize!) default-constructed vectors/matrices by default.

    You can #define GLM_FORCE_CTOR_INIT before #includeing GLM to restore the old behavior.