Fixed for crashes on exit associaciated with VAO usage and vairous niche usage cases
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
namespace osg {
|
||||
|
||||
// forward declare
|
||||
class State;
|
||||
class UserDataContainer;
|
||||
class Node;
|
||||
class NodeVisitor;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace osg {
|
||||
class DeleteHandler;
|
||||
class Observer;
|
||||
class ObserverSet;
|
||||
class State;
|
||||
|
||||
/** template class to help enforce static initialization order. */
|
||||
template <typename T, T M()>
|
||||
@@ -115,7 +116,15 @@ class OSG_EXPORT Referenced
|
||||
/** Remove Observer that is observing this object.*/
|
||||
void removeObserver(Observer* observer) const;
|
||||
|
||||
public:
|
||||
/** Resize any per context GLObject buffers to specified size. */
|
||||
virtual void resizeGLObjectBuffers(unsigned int /*maxSize*/) {}
|
||||
|
||||
/** If State is non-zero, this function releases any associated OpenGL objects for
|
||||
* the specified graphics context. Otherwise, releases OpenGL objects
|
||||
* for all graphics contexts. */
|
||||
virtual void releaseGLObjects(osg::State* = 0) const {}
|
||||
|
||||
public:
|
||||
|
||||
friend class DeleteHandler;
|
||||
|
||||
|
||||
@@ -161,6 +161,9 @@ class OSG_EXPORT View : public virtual osg::Object
|
||||
|
||||
void updateSlaves();
|
||||
|
||||
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||
virtual void releaseGLObjects(osg::State* = 0) const;
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~View();
|
||||
|
||||
@@ -72,6 +72,16 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
|
||||
|
||||
virtual void render(osg::RenderInfo& renderInfo,RenderLeaf* previous);
|
||||
|
||||
virtual void resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
if (_drawable) _drawable->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
virtual void releaseGLObjects(osg::State* state=0) const
|
||||
{
|
||||
if (_drawable) _drawable->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
/// Allow StateGraph to change the RenderLeaf's _parent.
|
||||
friend class osgUtil::StateGraph;
|
||||
|
||||
|
||||
@@ -484,6 +484,9 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
|
||||
* then need to be deleted in OpenGL by SceneView::flushAllDeleteGLObjects(). */
|
||||
virtual void releaseAllGLObjects();
|
||||
|
||||
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||
virtual void releaseGLObjects(osg::State* = 0) const;
|
||||
|
||||
/** Flush all deleted OpenGL objects, such as texture objects, display lists, etc.*/
|
||||
virtual void flushAllDeletedGLObjects();
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ class OSGUTIL_EXPORT StateGraph : public osg::Referenced
|
||||
public:
|
||||
|
||||
|
||||
typedef std::map< const osg::StateSet*, osg::ref_ptr<StateGraph> > ChildList;
|
||||
typedef std::vector< osg::ref_ptr<RenderLeaf> > LeafList;
|
||||
typedef std::map< const osg::StateSet*, osg::ref_ptr<StateGraph> > ChildList;
|
||||
typedef std::vector< osg::ref_ptr<RenderLeaf> > LeafList;
|
||||
|
||||
StateGraph* _parent;
|
||||
|
||||
@@ -172,6 +172,42 @@ class OSGUTIL_EXPORT StateGraph : public osg::Referenced
|
||||
void prune();
|
||||
|
||||
|
||||
void resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
for(ChildList::iterator itr = _children.begin();
|
||||
itr != _children.end();
|
||||
++itr)
|
||||
{
|
||||
(itr->second)->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
for(LeafList::iterator itr = _leaves.begin();
|
||||
itr != _leaves.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
void releaseGLObjects(osg::State* state=0) const
|
||||
{
|
||||
if (_stateset) _stateset->releaseGLObjects(state);
|
||||
|
||||
for(ChildList::const_iterator itr = _children.begin();
|
||||
itr != _children.end();
|
||||
++itr)
|
||||
{
|
||||
(itr->second)->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
for(LeafList::const_iterator itr = _leaves.begin();
|
||||
itr != _leaves.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->releaseGLObjects(state);
|
||||
}
|
||||
}
|
||||
|
||||
inline StateGraph* find_or_insert(const osg::StateSet* stateset)
|
||||
{
|
||||
// search for the appropriate state group, return it if found.
|
||||
|
||||
@@ -60,6 +60,9 @@ class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation
|
||||
|
||||
virtual void compile();
|
||||
|
||||
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
||||
virtual void releaseGLObjects(osg::State* = 0) const;
|
||||
|
||||
void setCompileOnNextDraw(bool flag) { _compileOnNextDraw = flag; }
|
||||
bool getCompileOnNextDraw() const { return _compileOnNextDraw; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user