Storing and drawing primitives
All of our primitive data has to be represented as a set of vertices. Whether we are dealing with a triangle or a sprite on screen, or if it is a huge, complex model of a monster, it can all be broken down to this fundamental type. Let us take a look at a class that represents it:
enum class VertexAttribute{ Position, COUNT }; struct GL_Vertex { GL_Vertex(const glm::vec3& l_pos): m_pos(l_pos) {} glm::vec3 m_pos; // Attribute 1. // ... };
As you can see, it is only a simple struct
that holds a 3D vector that represents a position. Later on, we might want to store other information about a vertex, such as texture coordinates, its color, and so on. These different pieces of information about a specific vertex are usually referred to as attributes. For convenience, we are also enumerating different attributes to make the rest of our code more clear.
Vertex storage
Before any primitives can be drawn, their data must be stored on the GPU. In OpenGL...