A Buffer whose data is on the GPU. More...
#include <GPUBuffer.h>
Public Member Functions | |
GPUBuffer () | |
Creates a new GPU buffer with no associated data. | |
virtual | ~GPUBuffer () |
Destroys this GPU buffer. | |
GLuint | getId () const |
Returns the id of this buffer. | |
int | getSize () const |
Returns the size of this buffer. | |
void | setData (int size, const void *data, BufferUsage u) |
Sets the content of this buffer. | |
void | setSubData (int target, int offset, int size, const void *data) |
Replaces a part of the content of this buffer. | |
void | getSubData (int target, int offset, int size, void *data) |
Gets a part of the content of this buffer. | |
volatile void * | map (BufferAccess a) |
Maps this buffer into CPU memory and returns a pointer to it. | |
volatile void * | getMappedData () |
Returns the mapped data of this buffer, or NULL if it is currently unmapped. | |
void | unmap () |
Unmaps this buffer from CPU memory. | |
Protected Member Functions | |
virtual void | bind (int target) const |
Binds this buffer to the given target. | |
virtual void * | data (int offset) const |
Returns (void*) offset. | |
virtual void | unbind (int target) const |
Unbinds this buffer from the given target. |
A Buffer whose data is on the GPU.
ork::GPUBuffer::GPUBuffer | ( | ) |
Creates a new GPU buffer with no associated data.
virtual ork::GPUBuffer::~GPUBuffer | ( | ) | [virtual] |
Destroys this GPU buffer.
The buffer data itself is also destroyed.
virtual void ork::GPUBuffer::bind | ( | int | target | ) | const [protected, virtual] |
Binds this buffer to the given target.
target | an OpenGL buffer target (GL_ARRAY_BUFFER, etc). |
Implements ork::Buffer.
virtual void* ork::GPUBuffer::data | ( | int | offset | ) | const [protected, virtual] |
Returns (void*) offset.
Implements ork::Buffer.
GLuint ork::GPUBuffer::getId | ( | ) | const |
Returns the id of this buffer.
volatile void* ork::GPUBuffer::getMappedData | ( | ) |
Returns the mapped data of this buffer, or NULL if it is currently unmapped.
int ork::GPUBuffer::getSize | ( | ) | const |
Returns the size of this buffer.
void ork::GPUBuffer::getSubData | ( | int | target, | |
int | offset, | |||
int | size, | |||
void * | data | |||
) |
Gets a part of the content of this buffer.
target | the target to bind to (use 0 for default). | |
offset | index of the first byte to be replaced. | |
size | number of bytes in 'data'. | |
data | the new buffer data. |
volatile void* ork::GPUBuffer::map | ( | BufferAccess | a | ) |
Maps this buffer into CPU memory and returns a pointer to it.
If the access mode is not READ_ONLY, changes made to the mapped buffer in CPU memory are reflected on GPU when the buffer is unmapped.
a | the read and write permissions for this mapped memory region. |
void ork::GPUBuffer::setData | ( | int | size, | |
const void * | data, | |||
BufferUsage | u | |||
) |
Sets the content of this buffer.
The previous content is erased and replaced by the new one.
size | number of bytes in 'data'. | |
data | the new buffer data. May be NULL. | |
u | how this buffer will be used. |
void ork::GPUBuffer::setSubData | ( | int | target, | |
int | offset, | |||
int | size, | |||
const void * | data | |||
) |
Replaces a part of the content of this buffer.
target | the target to bind to (use 0 for default). | |
offset | index of the first byte to be replaced. | |
size | number of bytes in 'data'. | |
data | the new buffer data. |
virtual void ork::GPUBuffer::unbind | ( | int | target | ) | const [protected, virtual] |
Unbinds this buffer from the given target.
target | an OpenGL buffer target (GL_ARRAY_BUFFER, etc). |
Implements ork::Buffer.
void ork::GPUBuffer::unmap | ( | ) |
Unmaps this buffer from CPU memory.