I'm trying to learn how to program vertex shaders. In Apple's sample project they have a line to set a
glUniform1f(uniforms[UNIFORM_TRANSLATE], (Glfloat)transY);
Then this value is used in
// value passt in f
// glUniform1f(uniforms[UNIFORM_TRANSLATE](Glfloat)transY);
uniform float translate;
void main()
{
gl_Position.y+=sin( translate);
…
I was unable to find a list of all uniforms of all the uniforms.
Does any one know where I can find a list of all the uniforms and a good book or tutorial on learning how to program vertex shaders.
Uniform parameter is a data passed to GL shader, which doesn't change during the draw call.
You can query a linked GLSL program for a list of active uniforms with the following code:
int total = -1;
glGetProgramiv( program_id, GL_ACTIVE_UNIFORMS, &total );
for(int i=0; i<total; ++i) {
int name_len=-1, num=-1;
GLenum type = GL_ZERO;
char name[100];
glGetActiveUniform( program_id, GLuint(i), sizeof(name)-1,
&name_len, &num, &type, name );
name[name_len] = 0;
GLuint location = glGetUniformLocation( program_id, name );
}
This code retrieves a number of active uniforms and iterates though them, extracting name, type, number of values and uniform locations.