There's more...

Of course, uniform variables can be any valid GLSL type, including complex types such as arrays or structures. OpenGL provides a glUniform function with the usual suffixes, appropriate for each type. For example, to assign to a variable of the vec3 type, one would use glUniform3f or glUniform3fv.

For arrays, one can use the functions ending in v to initialize multiple values within the array. Note that if it is desired, one can query for the location of a particular element of the uniform array using the [] operator. For example, to query for the location of the second element of MyArray:

GLuint location = 
glGetUniformLocation( programHandle, "MyArray[1]" );

For structures, the members of the structure must be initialized individually. As with arrays, one can query for the location of a member of a structure using something like the following:

GLuint location = 
glGetUniformLocation( programHandle, "MyMatrices.Rotation" );

Where the structure variable is MyMatrices and the member of the structure is Rotation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.127.232