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

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

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,
int  sizeInBytes,
DtUsage  usage,
DtCpuAccess  accessType,
bool  hasStagingBuffer,
const GLvoid *  data = 0 
)

CTOR.

Parameters
typeIndicates the type of the buffer this will be (vertex buffer, index buffer, etc)
sizeInBytesRequested size in bytes
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
datais the (optional) initial data
virtual makVrv::DtGlBuffer::~DtGlBuffer ( )
virtual

DTOR.

Member Function Documentation

virtual void makVrv::DtGlBuffer::resizeBuffer ( int  sizeInBytes,
const GLvoid *  data 
)
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 bool makVrv::DtGlBuffer::resizeBufferIfNecessary ( DtGlBuffer *&  buffer,
const char name,
DtBufferType  bufferType,
int  sizeInBytesNeeded,
DtUsage  usage,
DtCpuAccess  accessType,
bool  hasStaging,
const void *  data 
)
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

Member Data Documentation

std::string makVrv::DtGlBuffer::myName
protected
GLuint makVrv::DtGlBuffer::myHandle
mutableprotected
GLenum makVrv::DtGlBuffer::myType
protected
int makVrv::DtGlBuffer::mySizeInBytes
protected
GLubyte* makVrv::DtGlBuffer::myStagingBufffer
protected
bool makVrv::DtGlBuffer::myHasStagingBuffer
protected
DtUsage makVrv::DtGlBuffer::myUsage
protected
DtCpuAccess makVrv::DtGlBuffer::myAccessType
protected

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

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)