Workspace 6.21.5
Public Member Functions | Protected Member Functions | List of all members
WSGLBufferObjectCacheItem Class Reference

#include <Rendering/OpenGL/wsglbufferobjectcacheitem.h>

Public Member Functions

void allocate (const void *data, int count)
 Allocates the specified number of bytes to the GL buffer object, copying the provided source data into the buffer. Any pre-existing data in the buffer is deleted.
 
void allocate (int count)
 Allocates the specified number of bytes to the GL buffer object. The data will be uninitialized. Any pre-existing data in the buffer is deleted.
 
bool bind ()
 
template<typename T >
T * bindAllocateAndMap (int size, QOpenGLBuffer::UsagePattern usage, QOpenGLBuffer::Access access)
 
void drawElements (quint64 arrayIndex)
 
void enableVertexArray (quint64 arrayIndex, quint64 glAttributeIndex)
 
const WSGLElementArrayPropertiesgetElementArrayProperties (quint64 index)
 
const QString & getId () const
 
bool getInvalidated () const
 
const QDateTime & getLastUpdated () const
 
int getNumElementArrays () const
 
int getNumVertexArrays () const
 
const WSGLVertexArrayPropertiesgetVertexArrayProperties (quint64 index)
 
GLuint glBufferId () const
 
bool isGlBufferCreated () const
 
bool isMapped () const
 
void * map (QOpenGLBuffer::Access access)
 
bool read (int offset, void *data, int count)
 
void setElementArrayProperties (quint64 arrayIndex, GLenum type, quint64 minIndex, quint64 maxIndex, quint64 numElements, GLenum dataType, quint64 drawCount=0)
 
void setInvalidated (bool b)
 
void setLastUpdated (const QDateTime &timeStamp)
 
void setUsagePattern (QOpenGLBuffer::UsagePattern value)
 
void setVertexArrayProperties (quint64 arrayIndex, quint64 offset, quint64 numComponentsPerAttribute, quint64 componentSize, quint64 stride, GLenum glDataType, bool normalized)
 
int size () const
 
QOpenGLBuffer::Type type () const
 
void unbind ()
 
bool unmap ()
 
QOpenGLBuffer::UsagePattern usagePattern () const
 
void write (int offset, const void *data, int count)
 

Protected Member Functions

bool createGLBuffer ()
 

Detailed Description

Cache items are only created by the Cache. Cache items are responsible for adding themselves to the cache when created, and storing an iterator. Cache items are responsible for removing themselves from the cache when deleted, using the stored iterator.

Member Function Documentation

◆ allocate() [1/2]

void allocate ( const void *  data,
int  count 
)
Exceptions
WSGLCacheCapacityExceededExceptionthrown if there is no capacity available in the cache for this allocation. The allocation will not occur.
Parameters
dataThe source data to copy into the buffer.
countThe number of bytes to allocate in the buffer.

◆ allocate() [2/2]

void allocate ( int  count)
Exceptions
WSGLCacheCapacityExceededExceptionthrown if there is no capacity available in the cache for this allocation. The allocation will not occur.
Parameters
countThe number of bytes to allocate in the buffer.

◆ bind()

bool bind ( )

◆ bindAllocateAndMap()

T * bindAllocateAndMap ( int  size,
QOpenGLBuffer::UsagePattern  usage,
QOpenGLBuffer::Access  access 
)

Binds, allocates and maps a buffer into memory for local use.

Parameters
sizeNum bytes to allocate
usageUsage pattern for the buffer
accessAccess rights to the mapped buffer
Returns
A pointer to the mapped buffer if mapping was successful, otherwise nullptr.

◆ createGLBuffer()

bool createGLBuffer ( )
protected

Creates the internal GL buffer associated with the cache item. Only the WSGLBufferObjectCache should ever call this method. createGLBuffer will only fail if the current GL context is invalid, or the system doesn't support OpenGL buffer objects.

Returns
true If the buffer was created successfully, false otherwise.

◆ drawElements()

void drawElements ( quint64  arrayIndex)
Precondition
Assumes the cache item has already been bound.

◆ enableVertexArray()

void enableVertexArray ( quint64  arrayIndex,
quint64  glAttributeIndex 
)
Precondition
Assumes the cache item has already been bound.

◆ getElementArrayProperties()

const WSGLElementArrayProperties & getElementArrayProperties ( quint64  index)

◆ getId()

const QString & getId ( ) const
Returns
The id for this cache item. The id cannot be changed. Instead, the item should be released and a new item created with the new id.

◆ getInvalidated()

bool getInvalidated ( ) const
Returns
True if this cache item or any of its dependencies is invalidated. When the return value is true, this indicates that the item and/or its dependencies need to be rebuilt. Normally, this means rebuilding the item itself which will in turn rebuild the dependencies as necessary.
See also
setInvalidated()

◆ getLastUpdated()

const QDateTime & getLastUpdated ( ) const
Returns
The timestamp associated with the item. This will be used by the model processor to determine whether the item is outdated needs to be updated.

◆ getNumElementArrays()

int getNumElementArrays ( ) const
Returns
The number of element arrays that this buffer has attached to it.

◆ getNumVertexArrays()

int getNumVertexArrays ( ) const
Returns
The number of vertex arrays that this buffer has attached to it.

◆ getVertexArrayProperties()

const WSGLVertexArrayProperties & getVertexArrayProperties ( quint64  index)

◆ glBufferId()

GLuint glBufferId ( ) const

◆ isGlBufferCreated()

bool isGlBufferCreated ( ) const

◆ isMapped()

bool isMapped ( ) const

◆ map()

void * map ( QOpenGLBuffer::Access  access)

◆ read()

bool read ( int  offset,
void *  data,
int  count 
)

◆ setElementArrayProperties()

void setElementArrayProperties ( quint64  arrayIndex,
GLenum  type,
quint64  minIndex,
quint64  maxIndex,
quint64  numElements,
GLenum  dataType,
quint64  drawCount = 0 
)

◆ setInvalidated()

void setInvalidated ( bool  b)
Parameters
bFlag indicating the state of whether or not this cache item is invalidated.

If b is true, all dependencies are also marked as invalidated to ensure they are also rebuilt the next time they are needed. If it is false, dependencies are not marked as not invalidated. This is because the caller should have already ensured that dependent items have been marked before calling this function (they are responsible for how dependent items are updated, so only they can ensure this occurs).

See also
getInvalidated()

◆ setLastUpdated()

void setLastUpdated ( const QDateTime &  timeStamp)

◆ setUsagePattern()

void setUsagePattern ( QOpenGLBuffer::UsagePattern  value)

◆ setVertexArrayProperties()

void setVertexArrayProperties ( quint64  index,
quint64  offset,
quint64  numComponentsPerAttribute,
quint64  componentSize,
quint64  stride,
GLenum  glDataType,
bool  normalized 
)

Sets the properties of the indexed vertex array information associated with this buffer object.

◆ size()

int size ( ) const

◆ type()

QOpenGLBuffer::Type type ( ) const

◆ unbind()

void unbind ( )

◆ unmap()

bool unmap ( )

◆ usagePattern()

QOpenGLBuffer::UsagePattern usagePattern ( ) const

◆ write()

void write ( int  offset,
const void *  data,
int  count 
)