-
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)
glGetUniformLocation(programId, "test[0].a");
glGetUniformLocation(programId, "test[0].b");
glGetUniformLocation(programId, "test[0].c");
glGetUniformLocation(programId, "test[1].a");
glGetUniformLocation(programId, "test[1].b");
glGetUniformLocation(programId, "test[1].c");
.
.
.
glGetUniformLocation(programId, "test[n].a");
glGetUniformLocation(programId, "test[n].b");
glGetUniformLocation(programId, "test[n].c");
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules