Point with color and texture coordinates. More...
#include <SFML/Graphics/Vertex.hpp>
Public Attributes | |
Vector2f | position |
2D position of the vertex | |
Color | color {Color::White} |
Color of the vertex. | |
Vector2f | texCoords {} |
Coordinates of the texture's pixel to map to the vertex NOLINT(readability-redundant-member-init) | |
Detailed Description
Point with color and texture coordinates.
A vertex is an improved point.
By default, the vertex color is white and texture coordinates are (0, 0).
It has a position and other extra attributes that will be used for drawing: in SFML, vertices also have a color and a pair of texture coordinates.
The vertex is the building block of drawing. Everything which is visible on screen is made of vertices. They are grouped as 2D primitives (lines, triangles, ...), and these primitives are grouped to create even more complex 2D entities such as sprites, texts, etc.
If you use the graphical entities of SFML (sprite, text, shape) you won't have to deal with vertices directly. But if you want to define your own 2D entities, such as tiled maps or particle systems, using vertices will allow you to get maximum performances.
Example:
It is recommended to use aggregate initialization to create vertex objects, which initializes the members in order.
On a C++20-compliant compiler (or where supported as an extension) it is possible to use "designated initializers" to only initialize a subset of members, with the restriction of having to follow the same order in which they are defined.
Example:
Note: Although texture coordinates are supposed to be an integer amount of pixels, their type is float because of some buggy graphics drivers that are not able to process integer coordinates correctly.
- See also
sf::VertexArray
Definition at line 43 of file Vertex.hpp.
Member Data Documentation
◆ color
Color sf::Vertex::color {Color::White} |
Color of the vertex.
Definition at line 49 of file Vertex.hpp.
◆ position
Vector2f sf::Vertex::position |
2D position of the vertex
Definition at line 48 of file Vertex.hpp.
◆ texCoords
Vector2f sf::Vertex::texCoords {} |
Coordinates of the texture's pixel to map to the vertex NOLINT(readability-redundant-member-init)
Definition at line 50 of file Vertex.hpp.
The documentation for this struct was generated from the following file: