What is a vertex array?
First, we need to ask: what is a vertex? A vertex is a single graphical point, that is, a coordinate. This point is defined by a horizontal and vertical position. The plural of vertex is vertices. A vertex array is a whole collection of vertices.
In SFML, each vertex in a vertex array also has a color and a related additional vertex (that is, a pair of coordinates) called texture coordinates. Texture coordinates are the position of the image we want to use in terms of a sprite sheet. Later, we will see how we can position graphics and choose a part of the sprite sheet to display at each position, all with a single vertex array.
The SFML VertexArray
class can hold different types of vertex sets. But each VertexArray
should only hold one type of set. We use the type of set that suits the occasion.
Common scenarios in video games include, but are not limited to, the following primitive types:
- Point: A single vertex per point.
- Line...