| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/opengl/bufferobjectgl.h>

Public Types | |
| enum | DataType { UNCLASSIFIED, VERTEX_DATA, VERTEX_INDICES, PIXEL_PACK, PIXEL_UNPACK, UNIFORM_DATA, TEXTURE_BUFFER_DATA } |
| enum | UsagePattern { STREAM_DRAW, STATIC_DRAW, DYNAMIC_DRAW, STREAM_READ, STATIC_READ, DYNAMIC_READ, STREAM_COPY, STATIC_COPY, DYNAMIC_COPY } |
| enum | MapAccess { READ_ONLY, WRITE_ONLY, READ_WRITE } |
Public Member Functions | |
| VRS_SERIALIZABLE_CLASS_ENUM (DataType) | |
| VRS_SERIALIZABLE_CLASS_ENUM (UsagePattern) | |
| BufferObjectGL (EngineGL *engine, unsigned int bytes, const void *pointer, DataType type, UsagePattern usagePattern) | |
| BufferObjectGL (unsigned int bytes, const void *pointer, SharedObj *owner=NULL) | |
| virtual | ~BufferObjectGL () |
| Destruct the buffer again and release all associates resources. | |
| unsigned int | bytes () const |
| Returns the number of bytes the buffer was allocated for. | |
| void * | mapPointer (MapAccess access) |
| const void * | mapPointer (MapAccess access) const |
| bool | unmapPointer () const |
| bool | pointerIsMapped () const |
| void | update (unsigned int bytes, const void *pointer, unsigned int byteOffset=0) |
| void | replace (unsigned int bytes, const void *pointer) |
| void | bind (EngineGL *engine) const |
| void * | boundAddress (unsigned int offset=0) |
| const void * | boundAddress (unsigned int offset=0) const |
| void | unbind (EngineGL *engine) const |
| void | changeType (DataType newDataType) |
| DataType | dataType () const |
| Returns the data type specified in the constructor. | |
| VRS_TYPEINFO (BufferObjectGL, SharedObj) | |
| VRS_SERIALIZABLE (BufferObjectGL) | |
Static Public Member Functions | |
| static unsigned int | getMinimumVBOSize () |
| static void | setMimimumVBOSize (unsigned int vboSize=0) |
| static bool | isVBOEnabled () |
| static void | enableVBO (bool yesNo=true) |
Protected Member Functions | |
| BufferObjectGL () | |
| VRS::BufferObjectGL::BufferObjectGL | ( | EngineGL * | engine, | |
| unsigned int | bytes, | |||
| const void * | pointer, | |||
| DataType | type, | |||
| UsagePattern | usagePattern | |||
| ) |
Allocate a buffer of "bytes"-many bytes for the given data "type" and the given "usagePattern". If the given "pointer" is not NULL, "bytes"-many bytes are copied starting at "pointer" into the allocated buffer for initialisation. If "pointer" is NULL, the content of the buffer is NOT initialized to a specific default value!
| VRS::BufferObjectGL::BufferObjectGL | ( | unsigned int | bytes, | |
| const void * | pointer, | |||
| SharedObj * | owner = NULL | |||
| ) |
This constructor provides the BufferObjectGL interface for the data specified by "bytes" and "pointer" without copying it into a new buffer! If the provided raw data belongs to a VRS::SharedObj, this object must be specified as "owner" in order to ensure that the raw data is valid for the whole lifetime of the buffer object!
| virtual VRS::BufferObjectGL::~BufferObjectGL | ( | ) | [virtual] |
Destruct the buffer again and release all associates resources.
| VRS::BufferObjectGL::BufferObjectGL | ( | ) | [protected] |
| VRS::BufferObjectGL::VRS_SERIALIZABLE_CLASS_ENUM | ( | DataType | ) |
Specifies the type of data to be stored in the buffer: VERTEX_DATA: use for vertices, normals, tex coords, colors, ... (fastest: per vertex data should be 4-byte aligned!) VERTEX_INDICES: use for vertex array indices (fastest: unsigned short) PIXEL_PACK: use for transfering pixel/image data from OpenGL (e.g. glReadPixels(), glGetTexImage2D()) PIXEL_UNPACK: use for transfering pixel/image data to OpenGL (e.g. glTexImage2D()) UNCLASSIFIED: for every other data (e.g. ranges or primitives).
| VRS::BufferObjectGL::VRS_SERIALIZABLE_CLASS_ENUM | ( | UsagePattern | ) |
Specifies the usage pattern of the buffer: STREAM: specify once, use only several times STATIC: specify once, use many times DYNAMIC: specify many times, use many times DRAW: from application context to OpenGL context READ: from OpenGL context to application context COPY: from OpenGL context to OpenGL context.
| unsigned int VRS::BufferObjectGL::bytes | ( | ) | const |
Returns the number of bytes the buffer was allocated for.
| void* VRS::BufferObjectGL::mapPointer | ( | MapAccess | access | ) |
| const void* VRS::BufferObjectGL::mapPointer | ( | MapAccess | access | ) | const |
| bool VRS::BufferObjectGL::unmapPointer | ( | ) | const |
| bool VRS::BufferObjectGL::pointerIsMapped | ( | ) | const |
In order to get access to the data stored in the buffer, the buffer has to be mapped to memory by the mapPointer() method. After reading from or writing to the buffer the buffer must be unmapped again via the unmapPointer() method. Note: for best performance use READ_ONLY or WRITE_ONLY as "access" pattern if possible! Note: before the buffer can be used for rendering it must be unmapped. Note: never pass a pointer obtained by the mapPointer() method to an OpenGL function!
| void VRS::BufferObjectGL::update | ( | unsigned int | bytes, | |
| const void * | pointer, | |||
| unsigned int | byteOffset = 0 | |||
| ) |
Updates the content of the buffer by copying "bytes"-many bytes from the address "pointer" into the buffer starting at an offset of "byteOffset"-many bytes.
| void VRS::BufferObjectGL::replace | ( | unsigned int | bytes, | |
| const void * | pointer | |||
| ) |
Replaces the content of the buffer with the data specified by "bytes" and "pointer". If the given "pointer" is not NULL, "bytes"-many bytes are copied starting at "pointer" into the allocated buffer. If "pointer" is NULL, the content of the buffer is NOT initialized to a specific value!
| void VRS::BufferObjectGL::bind | ( | EngineGL * | engine | ) | const |
| void* VRS::BufferObjectGL::boundAddress | ( | unsigned int | offset = 0 |
) |
| const void* VRS::BufferObjectGL::boundAddress | ( | unsigned int | offset = 0 |
) | const |
| void VRS::BufferObjectGL::unbind | ( | EngineGL * | engine | ) | const |
In order to use the buffer content as source or target of OpenGL functions (e.g. glVertexPointer() or glReadPixels()), the buffer must first be bound via the bind() method. After that the buffer content could be specified to an OpenGL function by using the boundAddress() method. And finally the buffer must be unbound via the unbind() method. Note: NEVER use the pointer returned by boundAddress() to access the content of the buffer!
| void VRS::BufferObjectGL::changeType | ( | DataType | newDataType | ) |
This method allows to change the type of an existing buffer object; it is possible to create an PIXEL_PACK-PBO object, do a glReadPixels() into it and change the type to VERTEX_DATA in order to use some kind of render-to-vertex-data. Note: this feature is experimental in VRS 3.3; use at your own risk and only if you know what you do... :-)
| static unsigned int VRS::BufferObjectGL::getMinimumVBOSize | ( | ) | [static] |
| static void VRS::BufferObjectGL::setMimimumVBOSize | ( | unsigned int | vboSize = 0 |
) | [static] |
The minimum VBO size specifies the minimum number of bytes a buffer object must consist of to be transferred to the graphics memory. The default size is 1024 bytes.
| static bool VRS::BufferObjectGL::isVBOEnabled | ( | ) | [static] |
| static void VRS::BufferObjectGL::enableVBO | ( | bool | yesNo = true |
) | [static] |
Due to the current unstable driver support for ARBvbo the default behavior is to NOT transfer the buffer object content to the graphics memory. This can be changed/toggle by the enableVBO() method.
| DataType VRS::BufferObjectGL::dataType | ( | ) | const |
Returns the data type specified in the constructor.
| VRS::BufferObjectGL::VRS_TYPEINFO | ( | BufferObjectGL | , | |
| SharedObj | ||||
| ) |
| VRS::BufferObjectGL::VRS_SERIALIZABLE | ( | BufferObjectGL | ) |