View Full Version : Updating part of a uniform array

Etay Meiri
02-28-2011, 11:29 AM

Is it possible to partially update a uniform array?
For example, the shader contains:

uniform float foo[10];

And I want to update a single element.

According to the man page of glUniform*v it should be possible but there is only a pointer to the data and a count.



carsten neumann
02-28-2011, 12:50 PM
I've not tried this, but according to glGetUniformLocation (http://www.opengl.org/sdk/docs/man4/xhtml/glGetUniformLocation.xml) you need to obtain the location of foo[5] and then can use that to update it with something like:

float new_value = 5.f;
GLint foo5_loc = glGetUniformLocation(progId, "foo[5]");
glUniform1fv(foo5_loc, 1, &new_value);