Buffer

Manages a OpenGL vertex buffer object (Vbo).

Contains both a Vbo!T object and a T[], which it can keep in sync.

Basically, a Vbo!T has data stored in the GPU memory (for OpenGL), while the T[] has data stored in the CPU memory (for us). If you modify the T[] and want the changes to be reflected on the GPU, call markDirty(). Then, the next call to sync() will (re)upload the data to the GPU. If you don't want to keep a copy of the data in the CPU memory, just empty the T[] and don't call markDirty(). syncBack() can be used to download the data again from the GPU into the CPU memory.

Note that a Vbo!T is only allocated on the GPU (in OpenGL) the first time it is used. So until the first time sync() uploads the data, there is nothing allocated in OpenGL, not even an empty Vbo. (Unless vbo.create() is called explicitly, of course.)

Constructors

this
this(T[] d)

Allocate a new Buffer to hold the given data.

Alias This

data

Members

Functions

markDirty
void markDirty()

Mark the Buffer as dirty, such that the next call to sync() will upload the data to the GPU memory.

sync
void sync()

If the Buffer is marked as dirty, uploads the data from the T[] (CPU/us) to the Vbo!T (GPU/OpenGL). Resets is_dirty.

syncBack
void syncBack()

Download the data form the Vbo!T (GPU/OpenGL) to the T[] (CPU/us).

Properties

is_dirty
bool is_dirty [@property getter]

Check if the Buffer is marked as dirty. (i.e. sync() would do anything.)

vbo
auto ref vbo [@property getter]

The Vbo!T holding the GPU's (OpenGL's) copy of the data.

Variables

data
T[] data;

The T[] containing the CPU's (our) copy of the data.

Inherited Members

From GenericBuffer

vbo_
GenericVbo vbo_;
Undocumented in source.
sync
void sync()

If the Buffer is marked as dirty, uploads the data from the T[] (CPU/us) to the Vbo!T (GPU/OpenGL). Resets is_dirty.

vbo
auto ref vbo [@property getter]

The GenericVbo holding the GPU's (OpenGL's) copy of the data.

Meta