Addd OsgSceneHandler::s/getCleanUpOnNextFrame() and support for it in the draw() method,

when CleanUpOnNextFrame is enabled the next frame simple deleted OpenGL objects without doing any draw traversal.
This commit is contained in:
Robert Osfield 2005-11-10 11:39:01 +00:00
parent e9c25115fb
commit e8d6df7583
4 changed files with 25 additions and 8 deletions

View File

@ -76,8 +76,15 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
Callback* getCullCallback() { return _cullCallback.get(); } Callback* getCullCallback() { return _cullCallback.get(); }
const Callback* getCullCallback() const { return _cullCallback.get(); } const Callback* getCullCallback() const { return _cullCallback.get(); }
virtual void draw(Producer::Camera& camera) virtual void draw(Producer::Camera& camera)
{
if (_cleanUpOnNextFrame)
{
_sceneView->flushAllDeletedGLObjects();
_flushOfAllDeletedGLObjectsOnNextFrame = false;
_cleanUpOnNextFrame = false;
}
else
{ {
if (_flushOfAllDeletedGLObjectsOnNextFrame && _sceneView.valid()) if (_flushOfAllDeletedGLObjectsOnNextFrame && _sceneView.valid())
{ {
@ -89,6 +96,7 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
_flushOfAllDeletedGLObjectsOnNextFrame = false; _flushOfAllDeletedGLObjectsOnNextFrame = false;
} }
}
virtual void drawImplementation(Producer::Camera& camera); virtual void drawImplementation(Producer::Camera& camera);
@ -102,6 +110,10 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
bool getFlushOfAllDeletedGLObjectsOnNextFrame() const { return _flushOfAllDeletedGLObjectsOnNextFrame; } bool getFlushOfAllDeletedGLObjectsOnNextFrame() const { return _flushOfAllDeletedGLObjectsOnNextFrame; }
void setCleanUpOnNextFrame(bool flag) { _cleanUpOnNextFrame = flag; }
bool getCleanUpOnNextFrame() const { return _cleanUpOnNextFrame; }
protected: protected:
virtual ~OsgSceneHandler() {} virtual ~OsgSceneHandler() {}
@ -117,6 +129,7 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
osg::Timer_t _previousFrameStartTick; osg::Timer_t _previousFrameStartTick;
bool _flushOfAllDeletedGLObjectsOnNextFrame; bool _flushOfAllDeletedGLObjectsOnNextFrame;
bool _cleanUpOnNextFrame;
}; };
} }

View File

@ -736,7 +736,7 @@ void OsgCameraGroup::cleanup_frame()
++itr) ++itr)
{ {
(*itr)->getSceneView()->releaseAllGLObjects(); (*itr)->getSceneView()->releaseAllGLObjects();
(*itr)->setFlushOfAllDeletedGLObjectsOnNextFrame(true); (*itr)->setCleanUpOnNextFrame(true);
} }
// make sure that the registry all flushes all its texture objects. // make sure that the registry all flushes all its texture objects.

View File

@ -26,6 +26,7 @@ OsgSceneHandler::OsgSceneHandler( osg::DisplaySettings *ds) :
_frameStartTick = 0; _frameStartTick = 0;
_previousFrameStartTick = 0; _previousFrameStartTick = 0;
_flushOfAllDeletedGLObjectsOnNextFrame = false; _flushOfAllDeletedGLObjectsOnNextFrame = false;
_cleanUpOnNextFrame = false;
} }
void OsgSceneHandler::init() void OsgSceneHandler::init()

View File

@ -45,6 +45,9 @@ BEGIN_OBJECT_REFLECTOR(osgProducer::OsgSceneHandler)
I_Method1(void, setContextID, IN, int, id); I_Method1(void, setContextID, IN, int, id);
I_Method1(void, setFlushOfAllDeletedGLObjectsOnNextFrame, IN, bool, flag); I_Method1(void, setFlushOfAllDeletedGLObjectsOnNextFrame, IN, bool, flag);
I_Method0(bool, getFlushOfAllDeletedGLObjectsOnNextFrame); I_Method0(bool, getFlushOfAllDeletedGLObjectsOnNextFrame);
I_Method1(void, setCleanUpOnNextFrame, IN, bool, flag);
I_Method0(bool, getCleanUpOnNextFrame);
I_Property(bool, CleanUpOnNextFrame);
I_Property(osgProducer::OsgSceneHandler::Callback *, ClearCallback); I_Property(osgProducer::OsgSceneHandler::Callback *, ClearCallback);
I_WriteOnlyProperty(int, ContextID); I_WriteOnlyProperty(int, ContextID);
I_Property(osgProducer::OsgSceneHandler::Callback *, CullCallback); I_Property(osgProducer::OsgSceneHandler::Callback *, CullCallback);