Working with uniforms
Unlike attributes, uniforms are constant data; they are set once. The value of a uniform remains the same for all vertices processed. Uniforms can be created as arrays, a feature you will use in later chapters to implement mesh skinning.
Like the Attribute
class, the Uniform
class will also be templated. Unlike attributes, however, there will never be an instance of a Uniform
class. It only needs public static functions. For each uniform type, there are three functions: one to set an individual uniform value, one to set an array of uniform values, and a convenience function that sets an array of values but uses a vector for input.
The Uniform class declaration
Create a new file, Uniform.h
. You will be implementing the Uniform
class in this new file. The Uniform
class will never be instantiated since there won't be any instances of this class. Disable the constructor and copy the constructor, assignment operator, and destructor. What the class will...