Communicating Other Data to a Shader
- When we want to send other data to a shader, we use uniform
variables.
- These are marked in the shader with the modifyer uniform
- The red book says
- They are shared between all stages of the shader.
- They must be global variables (in the shaders)
- They cannot be written to (in the shader)
- see off1.vert for an example.
- Mapping between uniform variables and variables
- GLint glGetUniformLocation( GLuint program, const GLchar *name);
- Returns an integer representing a uniform variable.
- or -1 if the variable does not exist.
- Or if the name starts with gl_
- Or some other conditions.
- The iteger is valid until the shader program is changed.
- Program is the program that was loaded.
- name is the name of the vairable you are looking for.
- They state that the variable location is not known until the program is linked.
- void glUniform*
- Many version of this one
- copy a value from the cpu program to the gpu program.
- void glGetUniform* gets the value of a uniform variable.