OpenGL buffer object class. More...
#include <Inventor/devices/SoGLBufferObject.h>
Public Types | |
enum | BufferObjectTarget { PIXEL_PACK_BUFFER , PIXEL_UNPACK_BUFFER , ARRAY_BUFFER , ELEMENT_ARRAY_BUFFER , SHADER_STORAGE_BUFFER } |
This enum declares the possible targets of the buffer. More... | |
enum | Usage { STREAM_DRAW , STREAM_READ , STREAM_COPY , STATIC_DRAW , STATIC_READ , STATIC_COPY , DYNAMIC_DRAW , DYNAMIC_READ , DYNAMIC_COPY } |
This enum declares the possible usages of the memory allocated for the buffer. More... | |
Public Types inherited from SoBufferObject | |
enum | AccessMode { READ_ONLY , SET , READ_WRITE } |
This enum provides the possible access modes for a mapped buffer object. More... | |
Public Member Functions | |
SoGLBufferObject (Usage usage) | |
Constructor. | |
void | setTarget (BufferObjectTarget target) |
Specify the buffer target, which defines possible usage of the buffer. | |
BufferObjectTarget | getTarget () const |
Returns the current buffer target. | |
virtual bool | setSize (size_t size) |
Set the size of the buffer in bytes. | |
virtual void | map (SoBufferObject *targetBufferObject, AccessMode accessMode, size_t startPosition=0, size_t mappingSize=SO_BUFFER_SIZE_ALL) |
Map the current buffer object into the specified buffer object. | |
virtual void | unmap (SoBufferObject *bufferObject) |
Unmap the specified buffer object. | |
void | bind () |
Bind the current buffer to the specified target so it's usable by OpenGL operations. | |
void | unbind () |
Unbind the buffer. | |
virtual void * | map (AccessMode accessMode, size_t offset=0, size_t count=SO_BUFFER_SIZE_ALL) |
This function extends the map(AccessMode) method by allowing the mapping of a sub part of the buffer object into CPU memory. | |
virtual void | unmap () |
Unmaps the buffer using the regular unmap function. | |
bool | isValid () |
Query if the buffer is valid in the current context. | |
GLuint | getId () const |
Returns the OpenGL id of the buffer. | |
virtual SoBufferObject * | createInstance () const |
Create a new buffer with the same properties as the current one. | |
virtual void | clearInstance () |
Free the memory allocated in the buffer object. | |
void | memcpy (SoBufferObject *source, size_t destOffset=0, size_t sourceOffset=0, size_t copySize=SO_BUFFER_SIZE_ALL) |
Copy data from a buffer into this GL buffer. | |
Public Member Functions inherited from SoInteropBufferObject | |
SoInteropBufferObject () | |
Default constructor. | |
Public Member Functions inherited from SoBufferObject | |
void | lockBuffer () |
Locks the buffer against concurrent calls from different threads. | |
void | unlockBuffer () |
Unlocks the buffer object. | |
virtual size_t | getSize () const |
Returns the size, in bytes, of the buffer object. | |
virtual void | memset (void *value, size_t valueSize=1, size_t offset=0, size_t count=SO_BUFFER_SIZE_ALL) |
This function sets the contents of (or a portion of) this buffer object to the specified value. | |
SoDeviceContext * | getContext () const |
Returns the device context where this buffer is valid. | |
SoBufferObject * | getMappedBufferObject () const |
Returns a pointer to the buffer object which is mapped by the actual object. | |
AccessMode | getMappedBufferObjectAccessMode () |
Returns the access mode used for the buffer mapping. | |
size_t | getMappedBufferObjectPosition () const |
Returns the position in the source buffer mapped in this buffer. | |
size_t | getMappedBufferObjectSize () const |
Returns the size of the mapped area in bytes. | |
Public Member Functions inherited from SoRefCounter | |
void | ref () const |
Adds a reference to an instance. | |
void | unref () const |
Removes a reference from an instance. | |
void | unrefNoDelete () const |
unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero. | |
int | getRefCount () const |
Returns current reference count. | |
void | lock () const |
lock this instance. | |
void | unlock () const |
unlock this instance. | |
Public Member Functions inherited from SoTypedObject | |
virtual SoType | getTypeId () const =0 |
Returns the type identifier for a specific instance. | |
SbBool | isOfType (const SoType &type) const |
Returns TRUE if this object is of the type specified in type or is derived from that type. | |
template<typename TypedObjectClass > | |
SbBool | isOfType () const |
Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class. | |
Static Public Member Functions | |
static bool | isAvailable () |
Query if SoGLBufferObjects are available on this system. | |
Static Public Member Functions inherited from SoBufferObject | |
static SoCpuBufferObjectCache * | getBufferObjectCache () |
Returns the cache manager object. | |
Static Public Member Functions inherited from SoTypedObject | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
This class provides management functions for OpenGL memory buffers.
NOTE: Since Open Inventor 10.4, applications should use SoGPUBufferObject, instead of SoGLBufferObject, in most cases. For example to store vertex data in GPU memory for use with SoBufferedShape or SoVertexShaderParameterBufferObject.
This class can be used as a wrapper for GL memory buffer management when the application manages OpenGL code directly.
NOTES:
See SoBufferObject for general information about buffer objects.
See SoBufferedShape for an example of storing vertices in an OpenGL buffer.
Create a GPU buffer object and load data from an array in memory:
Load data into an existing GPU buffer from a CPU buffer:
Or
Definition at line 227 of file SoGLBufferObject.h.
This enum declares the possible targets of the buffer.
Definition at line 237 of file SoGLBufferObject.h.
This enum declares the possible usages of the memory allocated for the buffer.
This is a hint to the OpenGL driver implementation as to how a buffer object's data store will be accessed. This enables the OpenGL implementation to make more intelligent decisions that may significantly impact buffer object performance. It does not, however, constrain the actual usage of the data store. usage can be broken down into two parts: first, the frequency of access (modification and usage - STATIC, STREAM, DYNAMIC), and second, the nature of that access - DRAW, COPY, READ.
Definition at line 279 of file SoGLBufferObject.h.
SoGLBufferObject::SoGLBufferObject | ( | Usage | usage | ) |
Constructor.
usage | The intended usage of this buffer. Use enum Usage |
void SoGLBufferObject::bind | ( | ) |
Bind the current buffer to the specified target so it's usable by OpenGL operations.
Notes:
|
virtual |
Free the memory allocated in the buffer object.
Notes:
Implements SoInteropBufferObject.
|
virtual |
Create a new buffer with the same properties as the current one.
The new instance will have the same context and device properties, but no memory is allocated so the new buffer is initially invalid.
Implements SoInteropBufferObject.
GLuint SoGLBufferObject::getId | ( | ) | const |
Returns the OpenGL id of the buffer.
BufferObjectTarget SoGLBufferObject::getTarget | ( | ) | const |
Returns the current buffer target.
|
static |
Query if SoGLBufferObjects are available on this system.
bool SoGLBufferObject::isValid | ( | ) |
Query if the buffer is valid in the current context.
Notes:
|
virtual |
This function extends the map(AccessMode) method by allowing the mapping of a sub part of the buffer object into CPU memory.
On some systems this method has better performance.
Notes:
Reimplemented from SoBufferObject.
|
virtual |
Map the current buffer object into the specified buffer object.
targetBufferObject | The buffer object which will be the mapped version of this buffer. |
accessMode | The access mode used for the mapping. Use enum AccessMode |
startPosition | offset in source buffer to map from (default is start of buffer). |
mappingSize | size from the startPosition, if SO_BUFFER_SIZE_ALL then the whole buffer is mapped. |
Reimplemented from SoBufferObject.
|
virtual |
Copy data from a buffer into this GL buffer.
Notes:
This function is a specialized function for speed-up.
source | The buffer object to be copied. |
destOffset | The starting offset in the destination buffer object, useful for data subsets. |
sourceOffset | The starting offset in the source buffer object, useful for data subsets. |
copySize | The number of bytes to copy from the source buffer object (SO_BUFFER_SIZE_ALL means all). |
Reimplemented from SoBufferObject.
|
virtual |
Set the size of the buffer in bytes.
size | New size in bytes of the buffer. |
Notes:
Reimplemented from SoBufferObject.
void SoGLBufferObject::setTarget | ( | BufferObjectTarget | target | ) |
Specify the buffer target, which defines possible usage of the buffer.
WARNING: The function setTarget must be called before any operation for which OpenGL requires the target to be specified.
target | The new target of the buffer. Use enum BufferObjectTarget |
void SoGLBufferObject::unbind | ( | ) |
Unbind the buffer.
Notes:
|
virtual |
Unmaps the buffer using the regular unmap function.
Reimplemented from SoBufferObject.
|
virtual |
Unmap the specified buffer object.
Reimplemented from SoBufferObject.