Updating part of a uniform array


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.



I’ve not tried this, but according to glGetUniformLocation 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);