diff --git a/include/osg/GraphicsThread b/include/osg/GraphicsThread index 2e3df3e3c..d202abf6a 100644 --- a/include/osg/GraphicsThread +++ b/include/osg/GraphicsThread @@ -96,6 +96,16 @@ struct OSG_EXPORT BlockAndFlushOperation : public GraphicsOperation, public Open virtual void operator () (GraphicsContext*); }; + +struct OSG_EXPORT FlushDeletedGLObjectsOperation : public GraphicsOperation +{ + FlushDeletedGLObjectsOperation(double availableTime, bool keep=false); + + virtual void operator () (GraphicsContext*); + + double _availableTime; +}; + } #endif diff --git a/src/osg/GraphicsThread.cpp b/src/osg/GraphicsThread.cpp index 825b1e248..f32e6c87d 100644 --- a/src/osg/GraphicsThread.cpp +++ b/src/osg/GraphicsThread.cpp @@ -14,6 +14,7 @@ #include #include +#include #include using namespace osg; @@ -110,3 +111,19 @@ void BlockAndFlushOperation::operator () (GraphicsContext*) glFlush(); Block::release(); } + +FlushDeletedGLObjectsOperation::FlushDeletedGLObjectsOperation(double availableTime, bool keep): + GraphicsOperation("FlushDeletedGLObjectsOperation",keep) +{ +} + +void FlushDeletedGLObjectsOperation::operator () (GraphicsContext* context) +{ + State* state = context->getState(); + unsigned int contextID = state ? state->getContextID() : 0; + const FrameStamp* frameStamp = state ? state->getFrameStamp() : 0; + double currentTime = frameStamp ? frameStamp->getReferenceTime() : 0.0; + double availableTime = _availableTime; + + flushDeletedGLObjects(contextID, currentTime, availableTime); +}