From 3eae87854b5eff66e2c870eb3f5c8548ddb64cef Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 23 Jul 2007 16:42:25 +0000 Subject: [PATCH] Added FlushDeletedGLObjectsOperation. --- include/osg/GraphicsThread | 10 ++++++++++ src/osg/GraphicsThread.cpp | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) 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); +}