Noob question about uniform arrays, how to fill them?

If I want to fill a uniform array of structures, do I have no choice but to retrieve the location of each variable within each structure of the array? (so I can submit the uniform values individually like a regular uniform variable)

[b]glGetUniformLocation/b;
[b]glGetUniformLocation/b;
[b]glGetUniformLocation/b;
[b]glGetUniformLocation/b;
[b]glGetUniformLocation/b;
[b]glGetUniformLocation/b;
.
.
.
[b]glGetUniformLocation/b;
[b]glGetUniformLocation/b;
[b]glGetUniformLocation/b;

Like that?
Is there an alternative like filling a buffer object or something similar?

Thanks in advance.

No, it should be simplier, declare array in shader and then move the whole content by using one of the functions glUniform (see details here http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml).

In general, by glGetUniformLocation you are getting a kind of a reference to the uniform variable, then you use glUniform to push the value to the GPU, such value can be array. For arrays use glUniform1fv or similar type of functions.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.