VertexBuffer#
Enums
-
enum sfVertexBufferUsage#
Usage specifiers.
If data is going to be updated once or more every frame, set the usage to sfVertexBufferStream. If data is going to be set once and used for a long time without being modified, set the usage to sfVertexBufferUsageStatic. For everything else sfVertexBufferUsageDynamic should be a good compromise.
Values:
-
enumerator sfVertexBufferStream#
Constantly changing data.
-
enumerator sfVertexBufferDynamic#
Occasionally changing data.
-
enumerator sfVertexBufferStatic#
Rarely changing data.
-
enumerator sfVertexBufferStream#
Functions
-
sfVertexBuffer *sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage)#
Create a new vertex buffer with a specific sfPrimitiveType and usage specifier.
Creates the vertex buffer, allocating enough graphcis memory to hold
vertexCount
vertices, and sets its primitive type totype
and usage tousage
.- Parameters:
vertexCount – Amount of vertices
type – Type of primitive
usage – Usage specifier
- Returns:
A new sfVertexBuffer object
-
sfVertexBuffer *sfVertexBuffer_copy(const sfVertexBuffer *vertexBuffer)#
Copy an existing vertex buffer.
- Parameters:
vertexBuffer – Vertex buffer to copy
- Returns:
Copied object
-
void sfVertexBuffer_destroy(sfVertexBuffer *vertexBuffer)#
Destroy an existing vertex buffer.
- Parameters:
vertexBuffer – Vertex buffer to delete
-
unsigned int sfVertexBuffer_getVertexCount(const sfVertexBuffer *vertexBuffer)#
Return the vertex count.
- Parameters:
vertexBuffer – Vertex buffer object
- Returns:
Number of vertices in the vertex buffer
-
sfBool sfVertexBuffer_update(sfVertexBuffer *vertexBuffer, const sfVertex *vertices, unsigned int vertexCount, unsigned int offset)#
Update a part of the buffer from an array of vertices.
offset
is specified as the number of vertices to skip from the beginning of the buffer.If
offset
is 0 andvertexCount
is equal to the size of the currently created buffer, its whole contents are replaced.If
offset
is 0 andvertexCount
is greater than the size of the currently created buffer, a new buffer is created containing the vertex data.If
offset
is 0 andvertexCount
is less than the size of the currently created buffer, only the corresponding region is updated.If
offset
is not 0 andoffset
+vertexCount
is greater than the size of the currently created buffer, the update fails.No additional check is performed on the size of the vertex array, passing invalid arguments will lead to undefined behavior.
- Parameters:
vertices – Array of vertices to copy to the buffer
vertexCount – Number of vertices to copy
offset – Offset in the buffer to copy to
- Returns:
sfTrue if the update was successful
-
sfBool sfVertexBuffer_updateFromVertexBuffer(sfVertexBuffer *vertexBuffer, const sfVertexBuffer *other)#
Copy the contents of another buffer into this buffer.
- Parameters:
vertexBuffer – Vertex buffer object
other – Vertex buffer whose contents to copy into first vertex buffer
- Returns:
sfTrue if the copy was successful
-
void sfVertexBuffer_swap(sfVertexBuffer *left, sfVertexBuffer *right)#
Swap the contents of this vertex buffer with those of another.
- Parameters:
left – Instance to swap
right – Instance to swap with
-
unsigned int sfVertexBuffer_getNativeHandle(sfVertexBuffer *vertexBuffer)#
Get the underlying OpenGL handle of the vertex buffer.
You shouldn’t need to use this function, unless you have very specific stuff to implement that SFML doesn’t support, or implement a temporary workaround until a bug is fixed.
- Returns:
OpenGL handle of the vertex buffer or 0 if not yet created
-
void sfVertexBuffer_setPrimitiveType(sfVertexBuffer *vertexBuffer, sfPrimitiveType type)#
Set the type of primitives to draw.
This function defines how the vertices must be interpreted when it’s time to draw them.
The default primitive type is sf::Points.
- Parameters:
vertexBuffer – Vertex buffer object
type – Type of primitive
-
sfPrimitiveType sfVertexBuffer_getPrimitiveType(const sfVertexBuffer *vertexBuffer)#
Get the type of primitives drawn by the vertex buffer.
- Parameters:
vertexBuffer – Vertex buffer object
- Returns:
Primitive type
-
void sfVertexBuffer_setUsage(sfVertexBuffer *vertexBuffer, sfVertexBufferUsage usage)#
Set the usage specifier of this vertex buffer.
This function provides a hint about how this vertex buffer is going to be used in terms of data update frequency.
After changing the usage specifier, the vertex buffer has to be updated with new data for the usage specifier to take effect.
The default primitive type is sfVertexBufferStream.
- Parameters:
vertexBuffer – Vertex buffer object
usage – Usage specifier
-
sfVertexBufferUsage sfVertexBuffer_getUsage(const sfVertexBuffer *vertexBuffer)#
Get the usage specifier of this vertex buffer.
- Parameters:
vertexBuffer – Vertex buffer object
- Returns:
Usage specifier
-
void sfVertexBuffer_bind(const sfVertexBuffer *vertexBuffer)#
Bind a vertex buffer for rendering.
This function is not part of the graphics API, it mustn’t be used when drawing SFML entities. It must be used only if you mix sfVertexBuffer with OpenGL code.
sfVertexBuffer* vb1, vb2; ... sfVertexBuffer_bind(vb1); // draw OpenGL stuff that use vb1... sfVertexBuffer_bind(vb2); // draw OpenGL stuff that use vb2... sfVertexBuffer_bind(NULL); // draw OpenGL stuff that use no vertex buffer...
- Parameters:
vertexBuffer – Pointer to the vertex buffer to bind, can be null to use no vertex buffer
-
sfBool sfVertexBuffer_isAvailable()#
Tell whether or not the system supports vertex buffers.
This function should always be called before using the vertex buffer features. If it returns false, then any attempt to use sf::VertexBuffer will fail.
- Returns:
True if vertex buffers are supported, false otherwise