4

For glGetUniformfv, documentation states that "To query values stored in uniform variables declared as arrays, call glGetUniform for each element of the array"

Any example/hint on how to do that ?

1 Answer 1

3

All you need to know to make this work is that uniform array locations are assigned sequentially beginning with arrayname[0].

For each additional index, you can add 1 to this location. So if you wanted to get the value of arrayname[21], you would find the location of arrayname[0] and then add 21 to that.

Consider the following pseudo-code:

GLint arrayname_0  = glGetUniformLocation (program, "arrayname[0]");
GLint arrayname_21 = glGetUniformLocation (program, "arrayname[21]");

assert (arrayname_0 + 21 == arrayname_21);

You could query the location of the 21st element of arrayname the hard way, or you could take advantage of the property mentioned earlier. In any case, if you want to get the value of specific element in a uniform array, this location is the one you need to pass.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.