A set of primitives.
More...
#include <gf/VertexArray.h>
A set of primitives.
gf::VertexArray is a very simple wrapper around a dynamic array of vertices and a primitive type.
It inherits gf::Drawable, but unlike other drawables it is not transformable.
Example:
- See also
- gf::Vertex
gf::VertexArray::VertexArray |
( |
| ) |
|
|
inline |
gf::VertexArray::VertexArray |
( |
PrimitiveType |
type, |
|
|
std::size_t |
count = 0 |
|
) |
| |
|
inline |
Construct the vertex array with a type and an initial number of vertices.
- Parameters
-
type | Type of primitives |
count | Initial number of vertices in the array |
void gf::VertexArray::append |
( |
const Vertex & |
vertex | ) |
|
|
inline |
Add a vertex to the array.
- Parameters
-
void gf::VertexArray::clear |
( |
| ) |
|
|
inline |
Clear the vertex array.
This function removes all the vertices from the array. It doesn't deallocate the corresponding memory, so that adding new vertices after clearing doesn't involve reallocating all the memory.
Draw the object to a render target.
This is a pure virtual function that has to be implemented by the derived class to define how the drawable should be drawn.
- Parameters
-
target | Render target to draw to |
states | Current render states |
Implements gf::Drawable.
RectF gf::VertexArray::getBounds |
( |
| ) |
const |
Compute the bounding rectangle of the vertex array.
This function returns the minimal axis-aligned rectangle that contains all the vertices of the array.
- Returns
- Bounding rectangle of the vertex array
Get the type of primitives drawn by the vertex array.
- Returns
- Primitive type
std::size_t gf::VertexArray::getVertexCount |
( |
| ) |
const |
|
inline |
Return the vertex count.
- Returns
- Number of vertices in the array
const Vertex* gf::VertexArray::getVertexData |
( |
| ) |
const |
|
inline |
Return the vertex data.
- Returns
- A pointer to the vertices in the array
bool gf::VertexArray::isEmpty |
( |
| ) |
const |
|
inline |
Check if the vertex array is empty.
- Returns
- True if the vertex array is empty
Vertex& gf::VertexArray::operator[] |
( |
std::size_t |
index | ) |
|
|
inline |
Get a read-write access to a vertex by its index.
This function doesn't check index
, it must be in range \( [0, n - 1]\) where \( n \) is the vertex count. The behavior is undefined otherwise.
- Parameters
-
index | Index of the vertex to get |
- Returns
- Reference to the index-th vertex
- See also
- getVertexCount()
const Vertex& gf::VertexArray::operator[] |
( |
std::size_t |
index | ) |
const |
|
inline |
Get a read-only access to a vertex by its index.
This function doesn't check index
, it must be in range \( [0, n - 1]\) where \( n \) is the vertex count. The behavior is undefined otherwise.
- Parameters
-
index | Index of the vertex to get |
- Returns
- Const reference to the index-th vertex
- See also
- getVertexCount()
void gf::VertexArray::reserve |
( |
std::size_t |
capacity | ) |
|
|
inline |
Increase the capacity of the vertex array.
- Parameters
-
capacity | New capacity of the array |
void gf::VertexArray::resize |
( |
std::size_t |
count | ) |
|
|
inline |
Resize the vertex array.
If count
is greater than the current size, the previous vertices are kept and new (default-constructed) vertices are added.
If count
is less than the current size, existing vertices are removed from the array.
- Parameters
-
count | New size of the array (number of vertices) |
Set the type of primitives to draw.
This function defines how the vertices must be interpreted when it's time to draw them:
- As points
- As lines
- As triangles
The default primitive type is gf::PrimitiveType::Points.
- Parameters
-