Data in the graphics memory.
More...
#include <gf/VertexBuffer.h>
|
| VertexBuffer () |
| Default constructor. More...
|
|
| VertexBuffer (const Vertex *vertices, std::size_t count, PrimitiveType type) |
| Load an array of vertices. More...
|
|
| VertexBuffer (const Vertex *vertices, const uint16_t *indices, std::size_t count, PrimitiveType type) |
| Load an array of vertices and their indices. More...
|
|
| VertexBuffer (const void *vertices, std::size_t size, std::size_t count, PrimitiveType type) |
| Load an array of custom vertices. More...
|
|
| VertexBuffer (const void *vertices, std::size_t size, const uint16_t *indices, std::size_t count, PrimitiveType type) |
| Load an array of custom vertices and their indices. More...
|
|
bool | hasArrayBuffer () const |
| Check if there is an array buffer. More...
|
|
bool | hasElementArrayBuffer () const |
| Check if there is an element array buffer. More...
|
|
std::size_t | getVertexSize () const |
| Get the vertex size in the buffer. More...
|
|
std::size_t | getCount () const |
| Get the count of vertices or indices. More...
|
|
PrimitiveType | getPrimitiveType () const |
| Get the primitive type of the data in the buffer. More...
|
|
Data in the graphics memory.
A vertex buffer is a buffer that resides directly in the graphics memory. The advantage is that the draw operations are faster than uploading data each time. The drawback is that the data must not change, i.e. data can be loaded only once.
In gf, a vertex buffer can be used directly. But the main usage is for drawable entities that can upload the final geometry and give the corresponding vertex buffer.
Usage:
renderer.draw(geometry);
A drawable for buffers.
Definition: BufferedGeometry.h:55
void setBuffer(const VertexBuffer &buffer)
Set the vertex buffer.
Definition: BufferedGeometry.h:84
void setTexture(const BareTexture &texture)
Change the source texture of the geometry.
Definition: BufferedGeometry.h:111
A drawable representation of a texture, with its own transformations, color, etc.
Definition: Sprite.h:75
void setTexture(const Texture &texture, bool resetRect)
Change the source texture of the sprite.
VertexBuffer commitGeometry() const
Create a buffer with the current geometry.
void setTextureRect(const RectF &rect)
Set the sub-rectangle of the texture that the sprite will display.
A texture for colored images.
Definition: Texture.h:313
Data in the graphics memory.
Definition: VertexBuffer.h:81
- See also
- gf::BufferedGeometry
◆ VertexBuffer() [1/5]
gf::VertexBuffer::VertexBuffer |
( |
| ) |
|
◆ VertexBuffer() [2/5]
gf::VertexBuffer::VertexBuffer |
( |
const Vertex * |
vertices, |
|
|
std::size_t |
count, |
|
|
PrimitiveType |
type |
|
) |
| |
Load an array of vertices.
- Parameters
-
vertices | Pointer to the vertices |
count | Number of vertices in the array |
type | Type of primitives to draw |
◆ VertexBuffer() [3/5]
gf::VertexBuffer::VertexBuffer |
( |
const Vertex * |
vertices, |
|
|
const uint16_t * |
indices, |
|
|
std::size_t |
count, |
|
|
PrimitiveType |
type |
|
) |
| |
Load an array of vertices and their indices.
- Parameters
-
vertices | Pointer to the vertices |
indices | Pointer to the indices |
count | Number of indices in the array |
type | Type of primitives to draw |
◆ VertexBuffer() [4/5]
gf::VertexBuffer::VertexBuffer |
( |
const void * |
vertices, |
|
|
std::size_t |
size, |
|
|
std::size_t |
count, |
|
|
PrimitiveType |
type |
|
) |
| |
Load an array of custom vertices.
- Parameters
-
vertices | Pointer to the vertices |
size | The size of one vertex |
count | Number of vertices in the array |
type | Type of primitives to draw |
◆ VertexBuffer() [5/5]
gf::VertexBuffer::VertexBuffer |
( |
const void * |
vertices, |
|
|
std::size_t |
size, |
|
|
const uint16_t * |
indices, |
|
|
std::size_t |
count, |
|
|
PrimitiveType |
type |
|
) |
| |
Load an array of custom vertices and their indices.
- Parameters
-
vertices | Pointer to the vertices |
size | The size of one vertex |
indices | Pointer to the indices |
count | Number of indices in the array |
type | Type of primitives to draw |
◆ bind()
static void gf::VertexBuffer::bind |
( |
const VertexBuffer * |
buffer | ) |
|
|
static |
Binds a vertex buffer.
This function is for internal use only.
- Parameters
-
buffer | A pointer to a buffer or nullptr |
◆ getCount()
std::size_t gf::VertexBuffer::getCount |
( |
| ) |
const |
|
inline |
Get the count of vertices or indices.
This function returns the count
parameter given in the constructor.
- Returns
- The count of vertices or indices
- See also
- load()
◆ getPrimitiveType()
Get the primitive type of the data in the buffer.
This function returns the type
parameter given in the constructor.
- Returns
- The primitive type
- See also
- load()
◆ getVertexSize()
std::size_t gf::VertexBuffer::getVertexSize |
( |
| ) |
const |
|
inline |
Get the vertex size in the buffer.
- Returns
- The size of one vertex (custom or not)
◆ hasArrayBuffer()
bool gf::VertexBuffer::hasArrayBuffer |
( |
| ) |
const |
|
inline |
Check if there is an array buffer.
- Returns
- True if an array buffer is defined
◆ hasElementArrayBuffer()
bool gf::VertexBuffer::hasElementArrayBuffer |
( |
| ) |
const |
|
inline |
Check if there is an element array buffer.
- Returns
- True if an array element buffer is defined