![]() |
VR-Forces 4.6.1 Class Documentation
|
A generic OpenGL buffer. More...
Public Member Functions | |
| DtGlBuffer (const char *name, DtBufferType type, int sizeInBytes, DtUsage usage, DtCpuAccess accessType, bool hasStagingBuffer, const GLvoid *data=0) | |
| CTOR. | |
| virtual | ~DtGlBuffer () |
| DTOR. | |
| virtual void | resizeBuffer (int sizeInBytes, const GLvoid *data) |
| Resize the buffer so that the GPU know about a resize instead of deleting and recreating the buffer. | |
| int | sizeInBytes (void) const |
| The size in bytes of the buffer. | |
| GLenum | type (void) const |
| The internal OpenGL type of the buffer of the gl buffer. | |
| void | bufferSubData (GLuint offset, GLuint sizeInBytes, const GLvoid *data) |
| Optional API to upload data directly to the buffer, side stepping the staging buffer. | |
| GLuint | handle (void) const |
| The internal GL handle of the buffer. | |
| void | tearDown (void) const |
| void | bind () |
| bind/unbind the buffer | |
| void | unbind () |
| void | bind (GLenum type) |
| Bind/Unbind the buffer. | |
| void | unbind (GLenum type) |
| GLubyte * | findStagingBuffer (void) const |
| Internally GLBuffer uses a 'staging buffer' This is because map/unmap and directly uploading to the buffer is horribly slow in OpenGL. | |
| void | syncToGpu (GLuint offset, GLuint sizeInBytes) |
| Use when you modified (and hence need to update) only part of the buffer [offset, offset+sizeInBytes]. | |
| void | syncToGpu () |
| Use when you modified (and hence need to update) the whole buffer [0, sizeInBytes()]. | |
Static Public Member Functions | |
| static bool | resizeBufferIfNecessary (DtGlBuffer *&buffer, const char *name, DtBufferType bufferType, int sizeInBytesNeeded, DtUsage usage, DtCpuAccess accessType, bool hasStaging, const void *data) |
| Resize the buffer, only if necessary If buffer is null, will create a DtGlBuffer with the requested type and size If buffer is not null and requested size is < its actual size it will resize the buffer to be the requested size. | |
Protected Attributes | |
| std::string | myName |
| GLuint | myHandle |
| GLenum | myType |
| int | mySizeInBytes |
| GLubyte * | myStagingBufffer |
| bool | myHasStagingBuffer |
| DtUsage | myUsage |
| DtCpuAccess | myAccessType |
A generic OpenGL buffer.
This can be: -> a vertex buffer -> an index buffer -> a shader storage buffer (SSBO), etc
| makVrv::DtGlBuffer::DtGlBuffer | ( | const char * | name, |
| DtBufferType | type, | ||
| int | sizeInBytes, | ||
| DtUsage | usage, | ||
| DtCpuAccess | accessType, | ||
| bool | hasStagingBuffer, | ||
| const GLvoid * | data = 0 |
||
| ) |
CTOR.
| type | Indicates the type of the buffer this will be (vertex buffer, index buffer, etc) |
| sizeInBytes | Requested size in bytes |
| usage | Indicates what the intended usage of this buffer will be (dynamic, const, etc) |
| accessType | Indicates what level of CPU access is needed (will CPU only ever write, etc) |
| hasStagingBuffer | indicates whether this buffer will have an internal staging buffer |
| data | is the (optional) initial data |
|
virtual |
DTOR.
|
virtual |
Resize the buffer so that the GPU know about a resize instead of deleting and recreating the buffer.
| void makVrv::DtGlBuffer::bind | ( | ) |
bind/unbind the buffer
| void makVrv::DtGlBuffer::unbind | ( | ) |
| void makVrv::DtGlBuffer::bind | ( | GLenum | type | ) |
Bind/Unbind the buffer.
A buffer created as one type can be bound/interpreted as a completely different type by OpenGL
| void makVrv::DtGlBuffer::unbind | ( | GLenum | type | ) |
| int makVrv::DtGlBuffer::sizeInBytes | ( | void | ) | const |
The size in bytes of the buffer.
| GLenum makVrv::DtGlBuffer::type | ( | void | ) | const |
The internal OpenGL type of the buffer of the gl buffer.
| GLubyte* makVrv::DtGlBuffer::findStagingBuffer | ( | void | ) | const |
Internally GLBuffer uses a 'staging buffer' This is because map/unmap and directly uploading to the buffer is horribly slow in OpenGL.
The usage therefore is to get the staging buffer, modify it and then call syncToGPU
| void makVrv::DtGlBuffer::syncToGpu | ( | GLuint | offset, |
| GLuint | sizeInBytes | ||
| ) |
Use when you modified (and hence need to update) only part of the buffer [offset, offset+sizeInBytes].
| void makVrv::DtGlBuffer::syncToGpu | ( | ) |
Use when you modified (and hence need to update) the whole buffer [0, sizeInBytes()].
| void makVrv::DtGlBuffer::bufferSubData | ( | GLuint | offset, |
| GLuint | sizeInBytes, | ||
| const GLvoid * | data | ||
| ) |
Optional API to upload data directly to the buffer, side stepping the staging buffer.
You can use one or the other. That is to say you cannot use this API if you specified that this buffer has a staging buffer, which means you'll use that API (getStagingBuffer, syncToGPU)
| GLuint makVrv::DtGlBuffer::handle | ( | void | ) | const |
The internal GL handle of the buffer.
| void makVrv::DtGlBuffer::tearDown | ( | void | ) | const |
|
static |
Resize the buffer, only if necessary If buffer is null, will create a DtGlBuffer with the requested type and size If buffer is not null and requested size is < its actual size it will resize the buffer to be the requested size.
This used to completely recreate the buffer but that does not work will with large buffers. It causes opengl to allocate way too much memory
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |