Permalink
Browse files

Moved resizeGLObjects/releaseGLObjects out of Referenced to avoid mul…

…tiple inheritance warnings
  • Loading branch information...
robertosfield committed Jan 12, 2019
1 parent 1c3b2d2 commit 32db852c77e1884a9560bca5809d27f8e7f7e0a5
Showing with 37 additions and 13 deletions.
  1. +8 −0 include/osg/GraphicsThread
  2. +2 −2 include/osg/Referenced
  3. +9 −5 include/osgUtil/StateGraph
  4. +18 −6 src/osgUtil/SceneView.cpp
@@ -42,6 +42,14 @@ struct OSG_EXPORT GraphicsOperation : public Operation
virtual void operator () (Object* object);

virtual void operator () (GraphicsContext* context) = 0;

/** 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 {}
};


@@ -115,15 +115,15 @@ class OSG_EXPORT Referenced

/** Remove Observer that is observing this object.*/
void removeObserver(Observer* observer) const;

#if 0
/** 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 {}

#endif
public:

friend class DeleteHandler;
@@ -38,7 +38,7 @@ struct LessDepthSortFunctor

/** StateGraph - contained in a renderBin, defines the scene to be drawn.
*/
class OSGUTIL_EXPORT StateGraph : public osg::Referenced
class OSGUTIL_EXPORT StateGraph : public osg::Object
{
public:

@@ -66,7 +66,6 @@ class OSGUTIL_EXPORT StateGraph : public osg::Referenced
bool _dynamic;

StateGraph():
osg::Referenced(false),
_parent(NULL),
_stateset(NULL),
_depth(0),
@@ -78,7 +77,6 @@ class OSGUTIL_EXPORT StateGraph : public osg::Referenced
}

StateGraph(StateGraph* parent,const osg::StateSet* stateset):
osg::Referenced(false),
_parent(parent),
_stateset(stateset),
_depth(0),
@@ -95,7 +93,13 @@ class OSGUTIL_EXPORT StateGraph : public osg::Referenced

~StateGraph() {}

StateGraph* cloneType() const { return new StateGraph; }

virtual osg::Object* cloneType() const { return new StateGraph(); }
virtual StateGraph* cloneStateGraph() const { return new StateGraph(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return new StateGraph(); }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const StateGraph*>(obj)!=0L; }
virtual const char* libraryName() const { return "osgUtil"; }
virtual const char* className() const { return "StateGraph"; }

void setUserData(osg::Referenced* obj) { _userData = obj; }
osg::Referenced* getUserData() { return _userData.get(); }
@@ -345,7 +349,7 @@ class OSGUTIL_EXPORT StateGraph : public osg::Referenced
private:

/// disallow copy construction.
StateGraph(const StateGraph&):osg::Referenced() {}
StateGraph(const StateGraph&) : osg::Object() {}
/// disallow copy operator.
StateGraph& operator = (const StateGraph&) { return *this; }

@@ -720,11 +720,11 @@ void SceneView::cull()
{

if (!_cullVisitorLeft.valid()) _cullVisitorLeft = _cullVisitor->clone();
if (!_stateGraphLeft.valid()) _stateGraphLeft = _stateGraph->cloneType();
if (!_stateGraphLeft.valid()) _stateGraphLeft = _stateGraph->cloneStateGraph();
if (!_renderStageLeft.valid()) _renderStageLeft = osg::clone(_renderStage.get(), osg::CopyOp::DEEP_COPY_ALL);

if (!_cullVisitorRight.valid()) _cullVisitorRight = _cullVisitor->clone();
if (!_stateGraphRight.valid()) _stateGraphRight = _stateGraph->cloneType();
if (!_stateGraphRight.valid()) _stateGraphRight = _stateGraph->cloneStateGraph();
if (!_renderStageRight.valid()) _renderStageRight = osg::clone(_renderStage.get(), osg::CopyOp::DEEP_COPY_ALL);

_cullVisitorLeft->setDatabaseRequestHandler(_cullVisitor->getDatabaseRequestHandler());
@@ -931,11 +931,15 @@ void SceneView::resizeGLObjectBuffers(unsigned int maxSize)
{
struct Resize
{
unsigned int maxSize = 1;
unsigned int maxSize;

Resize(unsigned int ms) : maxSize(ms) {}

void operator() (osg::Referenced* object)
{
operator()(dynamic_cast<osg::Object*>(object));
}
void operator() (osg::Object* object)
{
if (object) object->resizeGLObjectBuffers(maxSize);
}
@@ -960,11 +964,19 @@ void SceneView::releaseGLObjects(osg::State* state) const

struct Release
{
void operator() (const osg::Referenced* object)
osg::State* _state;

Release(State* state) : _state(state) {}

void operator() (osg::Referenced* object)
{
operator()(dynamic_cast<osg::Object*>(object));
}
void operator() (osg::Object* object)
{
if (object) object->releaseGLObjects();
if (object) object->releaseGLObjects(_state);
}
} operation;
} operation(state);

operation(_localStateSet.get());
operation(_updateVisitor.get());

0 comments on commit 32db852

Please sign in to comment.