title: Can't set uniform value in OpenGL shader
body: <p>I am trying to get simple shaders to work. To be more specific, <strong>I am trying to set a uniform value of the shader</strong>. The shaders compile successfully and work correctly if I eliminate the uniform value. Here is the (vertex) shader code:</p>
  <pre class="lang-cpp prettyprint-override"><code>#version 440 core
  
  layout(location = 0) in vec3 vertex;
  
  uniform mat4 mvp;
  
  void main()
  {
      gl_Position = mvp * vec4(vertex, 1);
  }
  </code></pre>
  <p>And the code I use to set the value (<code>glGetUniformLocation</code> returns 0 as expected):</p>
  <pre class="lang-cpp prettyprint-override"><code>mvp = glm::mat4(
      glm::vec4(3.0f, 0.0f, 0.0f, 0.0f),
      glm::vec4(0.0f, 1.0f, 0.0f, 0.0f),
      glm::vec4(0.0f, 0.0f, 1.0f, 0.0f),
      glm::vec4(0.0f, 0.0f, 0.0f, 2.0f)
  );
  
  GLuint matrix = glGetUniformLocation(program, &quot;mvp&quot;);
  glUniformMatrix4fv(matrix, 1, GL_FALSE, glm::value_ptr(mvp));
  </code></pre>
  <p>The problem is that it doesn't seem to set the value at all. If I query the uniform's value using <code>glGetUniformfv</code>, it returns the default value (not the one I just set), and the geometry doesn't show up at all (but that is just a consequence, that's not the problem here).</p>
  <p>If I hardcode the uniform's value in the shader, the application displays the geometry correctly, and when asked for the value (again, using <code>glGetUniformfv</code>), it returns the correct value.</p>
  <pre class="lang-cpp prettyprint-override"><code>#version 440 core
  
  layout(location = 0) in vec3 vertex;
  
  uniform mat4 mvp = mat4(
      vec4(1.0f, 0.0f, 0.0f, 0.0f),
      vec4(0.0f, 1.0f, 0.0f, 0.0f),
      vec4(0.0f, 0.0f, 1.0f, 0.0f),
      vec4(0.0f, 0.0f, 0.0f, 2.0f)
  );
  
  void main()
  {
      gl_Position = mvp * vec4(vertex, 1);
  }
  </code></pre>
  <p>Any idea why does this happen? I am using OpenGL 4.4, but I have tried many different versions with the same result.</p>