Skip to content

Instantly share code, notes, and snippets.

@aras-p
Created September 5, 2011 19:43
Show Gist options
  • Save aras-p/1195754 to your computer and use it in GitHub Desktop.
Save aras-p/1195754 to your computer and use it in GitHub Desktop.
GLSL uniforms foo
// i = uniform location of vec4 array
// this is fine
glUniform4fv (i, 4, GL_FALSE, ptr); // load 4 elements of an array
// this is NOT fine!
glUniform4fv (i+0, 1, GL_FALSE, ptr); // this will set one element of an array
glUniform4fv (i+1, 1, GL_FALSE, ptr+4); // this and following may or might not work!
glUniform4fv (i+2, 1, GL_FALSE, ptr+8);
glUniform4fv (i+3, 1, GL_FALSE, ptr+12);
// i.e. you can't do arithmetic on uniform locations. To get uniform location of any individual
// array element you have to explicitly query it's location!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment