Refactored the GL object deletion management to use new osg::GraphicsObjectManager/GLObjectManager base classes, and osg::ContextData container.

This approach unifies much of the code handling the clean up of OpenGL graphics data, avoids lots of local mutexes and static variables that were previously required,
and enables the clean up scheme to be easily extended by users providing their own GraphicsObjectManager subclasses.


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@15130 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2015-09-23 09:47:34 +00:00
parent cb3396b0e5
commit 161246d864
37 changed files with 1339 additions and 1374 deletions

View File

@@ -155,7 +155,7 @@ class OSG_EXPORT State : public Referenced
typedef std::map<const std::type_info*, osg::ref_ptr<osg::Referenced> > ExtensionMap;
ExtensionMap _extensionMap;
/** Get a specific GL extensions object, initialize if not already present.
/** Get a specific GL extensions object or GraphicsObjectManager, initialize if not already present.
* Note, must only be called from a the graphics context thread associated with this osg::State. */
template<typename T>
T* get()
@@ -169,7 +169,7 @@ class OSG_EXPORT State : public Referenced
return static_cast<T*>(ptr.get());
}
/** Get a specific GL extensions object if it already exists in the extension map.
/** Get a specific GL extensions object or GraphicsObjectManager if it already exists in the extension map.
* Note, safe to call outwith a the graphics context thread associated with this osg::State.
* Returns NULL if the desired extension object has not been created yet.*/
template<typename T>
@@ -181,6 +181,13 @@ class OSG_EXPORT State : public Referenced
else return itr->second.get();
}
/** Set a specific GL extensions object pr GraphicsObjectManager. */
template<typename T>
void set(T* ptr)
{
const std::type_info* id(&typeid(T));
_extensionMap[id] = ptr;
}
/* Set whether shader composition is enabled.*/
void setShaderCompositionEnabled(bool flag) { _shaderCompositionEnabled = flag; }
@@ -2945,6 +2952,7 @@ inline bool State::setActiveTextureUnit( unsigned int unit )
// forward declare speciailization of State::get() method
template<> inline GLExtensions* State::get<GLExtensions>() { return _glExtensions.get(); }
template<> inline const GLExtensions* State::get<GLExtensions>() const { return _glExtensions.get(); }
template<> inline void State::set<GLExtensions>(GLExtensions* ptr) { _glExtensions = ptr; }
}