2
$\begingroup$

I have a call

glUniformMatrix4fv(42, ...other parameters...)

with a shader that has

layout (location = 42) uniform mat4 someMat;

which fails as an invalid operation (glDebugMessageCallback says invalid location).

But when I use glGetUinformLocation(shader, "someMat") the function actually still returns 42, and when using it the same call works and throws no errors.

Why could this be? Is the driver allowed to rearrange locations if they are not requested with glGetUniformLocation? Seems like that would defeat the purpose of giving uniforms predefined locations.

$\endgroup$
3
  • $\begingroup$ What does glGetUniformLocation return? Is it 42 or some other number? $\endgroup$ Jul 31 '21 at 18:35
  • 1
    $\begingroup$ @NathanReed Oh, sorry, I forgot to mention. It returns 42. $\endgroup$
    – cg_guy420
    Jul 31 '21 at 18:37
  • $\begingroup$ Very strange. I guess it could be a driver issue. Perhaps the driver accidentally assumes you will always call glGetUniformLocation first, and it internally doesn't set up some data structures until you call that, or some such. $\endgroup$ Jul 31 '21 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.