VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
makVrv::DtGlBuffer Class Reference

A generic OpenGL buffer. More...

Inheritance diagram for makVrv::DtGlBuffer:
Inheritance graph
[legend]

Public Member Functions

 DtGlBuffer (const char *name, DtBufferType type, DtUsage usage, DtCpuAccess accessType, bool hasStagingBuffer)
 CTOR. More...
 
virtual ~DtGlBuffer ()
 DTOR. More...
 
virtual void tearDown (void)
 releases GL objects and delete GL buffer More...
 
unsigned int releaseHandle (void)
 releases GL handle but does not delete GL buffer More...
 
virtual bool updateBuffer (const int sizeToTransferInBytes, const void *data)
 update the buffer, this can resize it if needed or create it from scratch More...
 
virtual void clearBuffer (unsigned int clearValue)
 clear the buffer to the value specified. More...
 
virtual bool bufferSubData (unsigned int offset, unsigned int sizeInBytes, const void *data)
 Optional API to upload data directly to the buffer, side stepping the staging buffer. More...
 
virtual void resetStagingBuffer ()
 set the whole staging buffer to 0 More...
 
virtual int sizeInBytes (void) const
 The size in bytes of the buffer. More...
 
virtual const unsigned int handle (void) const
 The internal GL handle of the buffer. More...
 
virtual void setResizeMultiplier (float rmul)
 multiplier on how much extra memory should get allocated at gl buffer creation time. More...
 
virtual void setUseIncrementalUpdate (bool incrementalUpdate)
 enable or disable incremental update for this buffer this means that only new data is sent down instead of resending the whole buffer every time. More...
 
virtual bool useIncrementalUpdate ()
 get the current state of incremental update for this buffer. More...
 
virtual float resizeMultiplier ()
 returns multiplier on how much extra memory should get allocated at gl buffer creation time. More...
 
unsigned int type (void) const
 The internal OpenGL type of the buffer of the gl buffer. More...
 
virtual void bind ()
 bind/unbind the buffer bind will not create the buffer if it is not yet created. More...
 
virtual void unbind ()
 
virtual unsigned charstagingBuffer (void) const
 Internally GLBuffer uses a 'staging buffer' This is because map/unmap and directly uploading to the buffer is horribly slow in OpenGL. More...
 
virtual unsigned charstagingBufferWithSize (unsigned int requestedSizeInBytes)
 gets the staging buffer can resize the opengl data. More...
 
virtual void syncStagingBufferToGpu (unsigned int offset, unsigned int sizeInBytes)
 Use when you modified (and hence need to update) only part of the buffer [offset, offset+sizeInBytes]. More...
 
virtual void syncStagingBufferToGpu ()
 Use when you modified (and hence need to update) the whole buffer [0, sizeInBytes()]. More...
 

Protected Member Functions

virtual bool createAndBindBuffer ()
 creates buffer, must be called in main render thread. More...
 
virtual int calculateNewSize (int requestedNewSizeInBytes)
 helper function to calculate the new size a buffer should be based on it's current size and the requested size. More...
 

Protected Attributes

std::string myName
 
unsigned int myHandle
 
unsigned int myType
 
int mySizeInBytes
 
float myResizeMultiplier
 
unsigned charmyStagingBuffer
 
bool myHasStagingBuffer
 
DtUsage myUsage
 
DtCpuAccess myAccessType
 
bool myUseIncrementalUpdate
 
int myLastBufferTransferOffset
 

Private Member Functions

 DtGlBuffer (const DtGlBuffer &other)
 Copy Constructor not implemented – Copy Not Allowed. More...
 
DtGlBufferoperator= (const DtGlBuffer &other)
 Assignment Operator Not implemented – Assignment Not Allowed. More...
 

Detailed Description

A generic OpenGL buffer.

This can be: -> a vertex buffer -> an index buffer -> a shader storage buffer (SSBO), etc

Constructor & Destructor Documentation

makVrv::DtGlBuffer::DtGlBuffer ( const char name,
DtBufferType  type,
DtUsage  usage,
DtCpuAccess  accessType,
bool  hasStagingBuffer 
)

CTOR.

Parameters
nameName of buffer for debugging and nsight.
typeIndicates the type of the buffer this will be (vertex buffer, index buffer, etc)
usageIndicates what the intended usage of this buffer will be (dynamic, const, etc)
accessTypeIndicates what level of CPU access is needed (will CPU only ever write, etc)
hasStagingBufferindicates whether this buffer will have an internal staging buffer
virtual makVrv::DtGlBuffer::~DtGlBuffer ( )
virtual

DTOR.

makVrv::DtGlBuffer::DtGlBuffer ( const DtGlBuffer other)
private

Copy Constructor not implemented – Copy Not Allowed.

Member Function Documentation

DtGlBuffer& makVrv::DtGlBuffer::operator= ( const DtGlBuffer other)
private

Assignment Operator Not implemented – Assignment Not Allowed.

virtual void makVrv::DtGlBuffer::tearDown ( void  )
virtual

releases GL objects and delete GL buffer

unsigned int makVrv::DtGlBuffer::releaseHandle ( void  )

releases GL handle but does not delete GL buffer

virtual bool makVrv::DtGlBuffer::updateBuffer ( const int  sizeToTransferInBytes,
const void *  data 
)
virtual

update the buffer, this can resize it if needed or create it from scratch

Parameters
sizeInBytesRequested size in bytes
datais the data to copy in.
virtual void makVrv::DtGlBuffer::clearBuffer ( unsigned int  clearValue)
virtual

clear the buffer to the value specified.

clears both the GPU data and the staging buffer if there is a staging buffer. requires valid graphics context

virtual void makVrv::DtGlBuffer::bind ( )
virtual

bind/unbind the buffer bind will not create the buffer if it is not yet created.

it will also spew a warning so it is easy to know when it is used incorrectly.

virtual void makVrv::DtGlBuffer::unbind ( )
virtual
virtual unsigned char* makVrv::DtGlBuffer::stagingBuffer ( void  ) const
virtual

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 syncStagingBufferToGpu

virtual unsigned char* makVrv::DtGlBuffer::stagingBufferWithSize ( unsigned int  requestedSizeInBytes)
virtual

gets the staging buffer can resize the opengl data.

FIXME seperate sb size from ogl

virtual void makVrv::DtGlBuffer::syncStagingBufferToGpu ( unsigned int  offset,
unsigned int  sizeInBytes 
)
virtual

Use when you modified (and hence need to update) only part of the buffer [offset, offset+sizeInBytes].

virtual void makVrv::DtGlBuffer::syncStagingBufferToGpu ( )
virtual

Use when you modified (and hence need to update) the whole buffer [0, sizeInBytes()].

virtual bool makVrv::DtGlBuffer::bufferSubData ( unsigned int  offset,
unsigned int  sizeInBytes,
const void *  data 
)
virtual

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)

virtual void makVrv::DtGlBuffer::resetStagingBuffer ( )
virtual

set the whole staging buffer to 0

virtual int makVrv::DtGlBuffer::sizeInBytes ( void  ) const
virtual

The size in bytes of the buffer.

virtual const unsigned int makVrv::DtGlBuffer::handle ( void  ) const
virtual

The internal GL handle of the buffer.

virtual void makVrv::DtGlBuffer::setResizeMultiplier ( float  rmul)
virtual

multiplier on how much extra memory should get allocated at gl buffer creation time.

virtual void makVrv::DtGlBuffer::setUseIncrementalUpdate ( bool  incrementalUpdate)
virtual

enable or disable incremental update for this buffer this means that only new data is sent down instead of resending the whole buffer every time.

On resize all the data is sent down again. use this if the data is static

virtual bool makVrv::DtGlBuffer::useIncrementalUpdate ( )
virtual

get the current state of incremental update for this buffer.

virtual float makVrv::DtGlBuffer::resizeMultiplier ( )
virtual

returns multiplier on how much extra memory should get allocated at gl buffer creation time.

unsigned int makVrv::DtGlBuffer::type ( void  ) const

The internal OpenGL type of the buffer of the gl buffer.

virtual bool makVrv::DtGlBuffer::createAndBindBuffer ( )
protectedvirtual

creates buffer, must be called in main render thread.

returns true if the buffer was created

virtual int makVrv::DtGlBuffer::calculateNewSize ( int  requestedNewSizeInBytes)
protectedvirtual

helper function to calculate the new size a buffer should be based on it's current size and the requested size.

Member Data Documentation

std::string makVrv::DtGlBuffer::myName
protected
unsigned int makVrv::DtGlBuffer::myHandle
protected
unsigned int makVrv::DtGlBuffer::myType
protected
int makVrv::DtGlBuffer::mySizeInBytes
protected
float makVrv::DtGlBuffer::myResizeMultiplier
protected
unsigned char* makVrv::DtGlBuffer::myStagingBuffer
protected
bool makVrv::DtGlBuffer::myHasStagingBuffer
protected
DtUsage makVrv::DtGlBuffer::myUsage
protected
DtCpuAccess makVrv::DtGlBuffer::myAccessType
protected
bool makVrv::DtGlBuffer::myUseIncrementalUpdate
protected
int makVrv::DtGlBuffer::myLastBufferTransferOffset
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)