SFML 2.5.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | List of all members
sf::Vertex Class Reference
Graphics module

Define a point with color and texture coordinates. More...

`#include <Vertex.hpp>`

## Public Member Functions
| Vertex ()
| Default constructor. More...
| Vertex (const Vector2f &thePosition)
| Construct the vertex from its position. More...
| Vertex (const Vector2f &thePosition, const Color &theColor)
| Construct the vertex from its position and color. More...
| Vertex (const Vector2f &thePosition, const Vector2f &theTexCoords)
| Construct the vertex from its position and texture coordinates. More...
| Vertex (const Vector2f &thePosition, const Color &theColor, const Vector2f &theTexCoords)
| Construct the vertex from its position, color and texture coordinates. More...

## Public Attributes
Vector2f | position
| 2D position of the vertex More...
Color | color
| Color of the vertex. More...
Vector2f | texCoords
| Point of the texture's pixel to map to the vertex. More...

## Detailed Description

Define a point with color and texture coordinates.

A vertex is an improved point.

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 (triangles, quads, ...), 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:

// define a 100x100 square, red, with a 10x10 texture mapped on it
sf::Vertex vertices[] =
{
sf::Vertex(sf::Vector2f( 0, 0), sf::Color::Red, sf::Vector2f( 0, 0)),
sf::Vertex(sf::Vector2f( 0, 100), sf::Color::Red, sf::Vector2f( 0, 10)),
sf::Vertex(sf::Vector2f(100, 100), sf::Color::Red, sf::Vector2f(10, 10)),
sf::Vertex(sf::Vector2f(100, 0), sf::Color::Red, sf::Vector2f(10, 0))
};
// draw it
window.draw(vertices, 4, sf::Quads);

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 42 of file Vertex.hpp.

## Constructor & Destructor Documentation

## ◆ Vertex() [1/5]

sf::Vertex::Vertex | ( |  | ) |

Default constructor.

## ◆ Vertex() [2/5]

sf::Vertex::Vertex | ( | const Vector2f & | thePosition | ) |

Construct the vertex from its position.

The vertex color is white and texture coordinates are (0, 0).

Parameters

  thePosition | Vertex position

## ◆ Vertex() [3/5]

sf::Vertex::Vertex | ( | const Vector2f & | thePosition,
|  | const Color & | theColor
| ) |  |

Construct the vertex from its position and color.

The texture coordinates are (0, 0).

Parameters

  thePosition | Vertex position
  theColor | Vertex color

## ◆ Vertex() [4/5]

sf::Vertex::Vertex | ( | const Vector2f & | thePosition,
|  | const Vector2f & | theTexCoords
| ) |  |

Construct the vertex from its position and texture coordinates.

The vertex color is white.

Parameters

  thePosition | Vertex position
  theTexCoords | Vertex texture coordinates

## ◆ Vertex() [5/5]

sf::Vertex::Vertex | ( | const Vector2f & | thePosition,
|  | const Color & | theColor,
|  | const Vector2f & | theTexCoords
| ) |  |

Construct the vertex from its position, color and texture coordinates.

Parameters

  thePosition | Vertex position
  theColor | Vertex color
  theTexCoords | Vertex texture coordinates

## Member Data Documentation

## ◆ color

Color sf::Vertex::color

Color of the vertex.

Definition at line 98 of file Vertex.hpp.

## ◆ position

Vector2f sf::Vertex::position

2D position of the vertex

Definition at line 97 of file Vertex.hpp.

## ◆ texCoords

Vector2f sf::Vertex::texCoords

Point of the texture's pixel to map to the vertex.

Definition at line 99 of file Vertex.hpp.

The documentation for this class was generated from the following file:

- Vertex.hpp