CSFML - C binding of the Simple and Fast Multimedia Library

CSFML 3.0.0
Loading...
Searching...
No Matches
Enumerations | Functions
VertexBuffer.h File Reference
`#include <CSFML/Graphics/Export.h>`
`#include <CSFML/Graphics/PrimitiveType.h>`
`#include <CSFML/Graphics/Types.h>`
`#include <CSFML/Graphics/Vertex.h>`
`#include <stddef.h>`

Go to the source code of this file.

## Enumerations
enum | sfVertexBufferUsage { sfVertexBufferStream , sfVertexBufferDynamic , sfVertexBufferStatic }
| Usage specifiers. More...

## Functions
sfVertexBuffer * | sfVertexBuffer_create (size_t vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage)
| Create a new vertex buffer with a specific sfPrimitiveType and usage specifier.
sfVertexBuffer * | sfVertexBuffer_copy (const sfVertexBuffer *vertexBuffer)
| Copy an existing vertex buffer.
void | sfVertexBuffer_destroy (const sfVertexBuffer *vertexBuffer)
| Destroy an existing vertex buffer.
size_t | sfVertexBuffer_getVertexCount (const sfVertexBuffer *vertexBuffer)
| Return the vertex count.
bool | sfVertexBuffer_update (sfVertexBuffer *vertexBuffer, const sfVertex *vertices, unsigned int vertexCount, unsigned int offset)
| Update a part of the buffer from an array of vertices.
bool | sfVertexBuffer_updateFromVertexBuffer (sfVertexBuffer *vertexBuffer, const sfVertexBuffer *other)
| Copy the contents of another buffer into this buffer.
void | sfVertexBuffer_swap (sfVertexBuffer *left, sfVertexBuffer *right)
| Swap the contents of this vertex buffer with those of another.
unsigned int | sfVertexBuffer_getNativeHandle (const sfVertexBuffer *vertexBuffer)
| Get the underlying OpenGL handle of the vertex buffer.
void | sfVertexBuffer_setPrimitiveType (sfVertexBuffer *vertexBuffer, sfPrimitiveType type)
| Set the type of primitives to draw.
sfPrimitiveType | sfVertexBuffer_getPrimitiveType (const sfVertexBuffer *vertexBuffer)
| Get the type of primitives drawn by the vertex buffer.
void | sfVertexBuffer_setUsage (sfVertexBuffer *vertexBuffer, sfVertexBufferUsage usage)
| Set the usage specifier of this vertex buffer.
sfVertexBufferUsage | sfVertexBuffer_getUsage (const sfVertexBuffer *vertexBuffer)
| Get the usage specifier of this vertex buffer.
void | sfVertexBuffer_bind (const sfVertexBuffer *vertexBuffer)
| Bind a vertex buffer for rendering.
bool | sfVertexBuffer_isAvailable (void)
| Tell whether or not the system supports vertex buffers.

## Enumeration Type Documentation

## ◆ sfVertexBufferUsage

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.

Enumerator
sfVertexBufferStream | Constantly changing data.
sfVertexBufferDynamic | Occasionally changing data.
sfVertexBufferStatic | Rarely changing data.

Definition at line 50 of file VertexBuffer.h.

## Function Documentation

## ◆ sfVertexBuffer_bind()

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...
sfVertexBuffer
struct sfVertexBuffer sfVertexBuffer
Definition Graphics/Types.h:42
sfVertexBuffer_bind
void sfVertexBuffer_bind(const sfVertexBuffer *vertexBuffer)
Bind a vertex buffer for rendering.

Parameters

  vertexBuffer | Pointer to the vertex buffer to bind, can be null to use no vertex buffer

## ◆ sfVertexBuffer_copy()

sfVertexBuffer * sfVertexBuffer_copy | ( | const sfVertexBuffer * | vertexBuffer | ) |

Copy an existing vertex buffer.

Parameters

  vertexBuffer | Vertex buffer to copy

Returns
  Copied object

## ◆ sfVertexBuffer_create()

sfVertexBuffer * sfVertexBuffer_create | ( | size_t | vertexCount,
|  | sfPrimitiveType | type,
|  | sfVertexBufferUsage | usage )

Create a new vertex buffer with a specific sfPrimitiveType and usage specifier.

Creates the vertex buffer, allocating enough graphics memory to hold `vertexCount` vertices, and sets its primitive type to `type` and usage to `usage`.

Parameters

  vertexCount | Amount of vertices
  type | Type of primitive
  usage | Usage specifier

Returns
  A new sfVertexBuffer object

## ◆ sfVertexBuffer_destroy()

void sfVertexBuffer_destroy | ( | const sfVertexBuffer * | vertexBuffer | ) |

Destroy an existing vertex buffer.

Parameters

  vertexBuffer | Vertex buffer to delete

## ◆ sfVertexBuffer_getNativeHandle()

unsigned int sfVertexBuffer_getNativeHandle | ( | const 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

## ◆ sfVertexBuffer_getPrimitiveType()

sfPrimitiveType sfVertexBuffer_getPrimitiveType | ( | const sfVertexBuffer * | vertexBuffer | ) |

Get the type of primitives drawn by the vertex buffer.

Parameters

  vertexBuffer | Vertex buffer object

Returns
  Primitive type

## ◆ sfVertexBuffer_getUsage()

sfVertexBufferUsage sfVertexBuffer_getUsage | ( | const sfVertexBuffer * | vertexBuffer | ) |

Get the usage specifier of this vertex buffer.

Parameters

  vertexBuffer | Vertex buffer object

Returns
  Usage specifier

## ◆ sfVertexBuffer_getVertexCount()

size_t sfVertexBuffer_getVertexCount | ( | const sfVertexBuffer * | vertexBuffer | ) |

Return the vertex count.

Parameters

  vertexBuffer | Vertex buffer object

Returns
  Number of vertices in the vertex buffer

## ◆ sfVertexBuffer_isAvailable()

bool sfVertexBuffer_isAvailable | ( | void |  | ) |

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 sfVertexBuffer will fail.

Returns
  True if vertex buffers are supported, false otherwise

## ◆ sfVertexBuffer_setPrimitiveType()

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 sfPoints.

Parameters

  vertexBuffer | Vertex buffer object
  type | Type of primitive

## ◆ sfVertexBuffer_setUsage()

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

## ◆ sfVertexBuffer_swap()

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

## ◆ sfVertexBuffer_update()

bool 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 and `vertexCount` is equal to the size of the currently created buffer, its whole contents are replaced.

If `offset` is 0 and `vertexCount` is greater than the size of the currently created buffer, a new buffer is created containing the vertex data.

If `offset` is 0 and `vertexCount` is less than the size of the currently created buffer, only the corresponding region is updated.

If `offset` is not 0 and `offset` + `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

  vertexBuffer | Vertex buffer object
  vertices | Array of vertices to copy to the buffer
  vertexCount | Number of vertices to copy
  offset | Offset in the buffer to copy to

Returns
  true if the update was successful

## ◆ sfVertexBuffer_updateFromVertexBuffer()

bool 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
  true if the copy was successful