C4 Engine
C4 Engine API Documentation

VertexBuffer::UpdateBuffer

Defined in:  C4Renderable.h
Copies data to a vertex buffer.
Prototype

void UpdateBuffer(const void *data, uint32 size);

void UpdateBufferSync(const void *data, uint32 size);

Parameters
data A pointer to the data that will be copied into the buffer.
size The size of the data to copy into the buffer, in bytes.
Description
The UpdateBuffer function copies the data specified by the data parameter into a vertex buffer. The number of bytes copied is specified by the size parameter, and the base offset within the vertex buffer to which the data is copied is specified by the offset parameter. The size parameter must not exceed the total size of the vertex buffer, as specified by the value of the size parameter passed to the VertexBuffer::EstablishVertexBuffer function.

The UpdateBufferSync variant of the UpdateBuffer function should normally be called to ensure that the GPU driver is being accessed properly in multithreaded contexts. The UpdateBuffer function should only be called if it's a certainty that it is being called from the main thread. Both functions have the same effect.

The UpdateBuffer function cannot be called for static vertex buffers. For a vertex buffer constructed with the kVertexBufferStatic flag, either the buffer data should be supplied with the EstablishVertexBuffer function or the buffer data should be loaded into the buffer one time using the VertexBuffer::BeginUpdate and VertexBuffer::EndUpdate functions.
See Also

VertexBuffer::BeginUpdate

VertexBuffer::EndUpdate