Working with buffers (attributes)
Attributes are per-vertex data in the graphics pipeline. A vertex is made up of attributes. For example, a vertex has a position and a normal, which are both attributes. The most common attributes are as follows:
- Position: Often in local space
- Normal: The direction the vertex points in
- UV or texture coordinate: The normalized (x,y) coordinate on a texture
- Color: A
vector3representing the color of a vertex
Attributes can have different data types. Throughout this book, you will implement support for integers, floats, and vector attributes. For vector attributes, two-, three-, and four-dimensional vectors will be supported.
The Attribute class declaration
Create a new file,
Attribute class will be declared in this new file. The
Attribute class will be templated. This will ensure that if an attribute is meant to be
vec3, you cannot accidentally load
vec2 into it:
- The attribute class will contain...