View Full Version : How to query the value of a uniform block element?

06-22-2011, 08:46 AM
I can't use glGetUniform as uniform blocks don't have locations, and glGetActiveUniformBlock cannot be used to query an element's value. So how do I do it?

Also, is someone else having problems with using arrays in uniform blocks? Is this even supported? I'd like to store bone matrices for skinning in a uniform block but the data is not uploaded properly.

uniform Animation
mat4 boneMatrices[64];
} animation;

Thank you!

Ilian Dinev
06-22-2011, 10:11 AM


06-22-2011, 11:28 AM
The specification (GLSL 3.3) explicitly states that arrays are allowed in uniform blocks. However, there is a limit on how many uniforms you can have, or rather how much memory they can consume. This varies between implementations. 64 matrices would consume 4 kilobytes, which is quite a lot.

Alfonse Reinheart
06-22-2011, 04:59 PM
Uniform block elements don't have values. The whole point of a uniform block is that its values come from a buffer object. Therefore, what Ilian Dinev said is correct: read your buffer object.

06-23-2011, 04:05 AM
ok that makes sense, thank you all! i'll try mapping the buffer.