O'Reilly logo

Mastering SFML Game Development by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required