VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions
makVrv::DtGlVaoManager Class Reference

This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl contexts.

background: VAO's cannot be shared between OpenGL contexts. This class helps manage that situation by creating and tracking VAO handles for each unique context.

Basically, the user should call getOrCreateVao with a graphics context active (typically during draw) to get a handle for a VAO for that specific graphics context. getOrCreateVao will indicate if a new context was encountered and at that time the user should bind buffers associated with the VAO. When the VAO is not longer needed (for example, during shutdown), clearVao(0), and deleteQueuedVaos(0) should be called. These are also called in the destructor of this class so no need to call if destorying this manager.

Methods clearVao, deleteQueuedVaos can also be called for a specific graphics context to just modify that context.

Public Member Functions

 DtGlVaoManager (makVrv::DtDe &de)
 
virtual ~DtGlVaoManager ()
 
virtual DtGlVaoAndContext getOrCreateVao (const osg::GraphicsContext *graphicsContext, bool &created) const
 
virtual void clearVao (const osg::GraphicsContext *graphicsContext) const
 
virtual void deleteQueuedVaos (const osg::GraphicsContext *graphicsContext) const
 

Protected Types

typedef std::map
< osg::observer_ptr< const
osg::GraphicsContext >
, DtGlVaoAndContext
MapContextToVao
 
typedef std::vector
< DtGlVaoAndContext
VaoArray
 
typedef std::map
< osg::observer_ptr< const
osg::GraphicsContext >
, VaoArray
MapContextsToVaoArray
 

Protected Member Functions

virtual void deleteQueuedVaosInAllGc (osg::GraphicsContext *graphicsContext) const
 
virtual void slot_windowToBeDestroyed (DtWindow *window)
 
virtual void attemptToDeleteVao (const void *glContext, DtGlVaoAndContext &fbo) const
 

Protected Attributes

DtDemyDe
 
DtSignalConnectionManager myConnections
 
MapContextToVao myMutableGraphicsContextToVao
 
MapContextsToVaoArray myMutableGraphicsContextToVaoArrayToDelete
 

Private Member Functions

 DtGlVaoManager ()
 
 DtGlVaoManager (const DtGlVaoManager &other)
 
DtGlVaoManageroperator= (const DtGlVaoManager &other)
 

Member Typedef Documentation

typedef std::map<osg::observer_ptr<const osg::GraphicsContext>, DtGlVaoAndContext> makVrv::DtGlVaoManager::MapContextToVao
protected

Mutables below. These are mutable due to the fact that osg has drawImplementation as const These mutables are protected instead of private so they can be used by any future derived classes.

typedef std::vector<DtGlVaoAndContext> makVrv::DtGlVaoManager::VaoArray
protected
typedef std::map<osg::observer_ptr<const osg::GraphicsContext>, VaoArray > makVrv::DtGlVaoManager::MapContextsToVaoArray
protected

Constructor & Destructor Documentation

makVrv::DtGlVaoManager::DtGlVaoManager ( makVrv::DtDe de)

CTOR.

virtual makVrv::DtGlVaoManager::~DtGlVaoManager ( )
virtual

DTOR.

makVrv::DtGlVaoManager::DtGlVaoManager ( )
private

Default Constructor not implemented - not allowed.

makVrv::DtGlVaoManager::DtGlVaoManager ( const DtGlVaoManager other)
private

Copy Constructor not implemented - Copy not allowed.

Member Function Documentation

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

Assignment Operator not implemented - Assignment not allowed.

virtual DtGlVaoAndContext makVrv::DtGlVaoManager::getOrCreateVao ( const osg::GraphicsContext *  graphicsContext,
bool created 
) const
virtual

Gets or creates a vertex array object (VAO) and returns the handle to it.

Parameters
stateThe state object that contains the graphics context.
createdThis value is set to true if the VAO is newly created.
virtual void makVrv::DtGlVaoManager::clearVao ( const osg::GraphicsContext *  graphicsContext) const
virtual

Clears the VAO from graphics context mapping and queues it to be deleted. If state is NULL(0), then VAO is cleared from all contexts.

Parameters
graphicsContextThe graphics context.
virtual void makVrv::DtGlVaoManager::deleteQueuedVaos ( const osg::GraphicsContext *  graphicsContext) const
virtual

Removes the VAO for a specific graphics context. Assumes the graphics context is active. If graphicsContext is NULL(0), then VAO is removed from all contexts.

Parameters
graphicsContextThe graphics context.
virtual void makVrv::DtGlVaoManager::deleteQueuedVaosInAllGc ( osg::GraphicsContext *  graphicsContext) const
protectedvirtual

Removes the VAO for all contexts. This should be called when destructing or releasing OpenGL resources. For non-active contexts, the VAO's are handed off to a DtGlDeleteObjectManager to be deleted when appropriate.

Parameters
graphicsContextThe graphics context.
virtual void makVrv::DtGlVaoManager::slot_windowToBeDestroyed ( DtWindow window)
protectedvirtual

Handles window closing (context destroyed).

virtual void makVrv::DtGlVaoManager::attemptToDeleteVao ( const void *  glContext,
DtGlVaoAndContext fbo 
) const
protectedvirtual

internal

Member Data Documentation

DtDe& makVrv::DtGlVaoManager::myDe
protected
DtSignalConnectionManager makVrv::DtGlVaoManager::myConnections
protected
MapContextToVao makVrv::DtGlVaoManager::myMutableGraphicsContextToVao
mutableprotected
MapContextsToVaoArray makVrv::DtGlVaoManager::myMutableGraphicsContextToVaoArrayToDelete
mutableprotected

Keep track of what vertex array objects (VAOs) we have seen per context so that we can delete the Vaos in the right context.


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

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)