From af19e710245d802e4f5951d15c02091b9ad9fc7c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sat, 14 Jul 2007 09:17:18 +0000 Subject: [PATCH] Changed BarrierOperation so that it isn't limited to jut working within GraphicsContexts. --- include/osg/GraphicsThread | 6 +++--- src/osg/GraphicsThread.cpp | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/osg/GraphicsThread b/include/osg/GraphicsThread index 50e7f6451..2e3df3e3c 100644 --- a/include/osg/GraphicsThread +++ b/include/osg/GraphicsThread @@ -54,7 +54,7 @@ struct OSG_EXPORT SwapBuffersOperation : public GraphicsOperation }; /** BarrierOperation allows one to syncronize multiple GraphicsThreads with each other.*/ -struct OSG_EXPORT BarrierOperation : public GraphicsOperation, public OpenThreads::Barrier +struct OSG_EXPORT BarrierOperation : public Operation, public OpenThreads::Barrier { enum PreBlockOp { @@ -64,13 +64,13 @@ struct OSG_EXPORT BarrierOperation : public GraphicsOperation, public OpenThread }; BarrierOperation(int numThreads, PreBlockOp op=NO_OPERATION): - GraphicsOperation("Barrier", true), + Operation("Barrier", true), OpenThreads::Barrier(numThreads), _preBlockOp(op) {} virtual void release(); - virtual void operator () (GraphicsContext* context); + virtual void operator () (Object* object); PreBlockOp _preBlockOp; }; diff --git a/src/osg/GraphicsThread.cpp b/src/osg/GraphicsThread.cpp index a132ca83c..581f340b7 100644 --- a/src/osg/GraphicsThread.cpp +++ b/src/osg/GraphicsThread.cpp @@ -58,11 +58,15 @@ void BarrierOperation::release() Barrier::release(); } -void BarrierOperation::operator () (GraphicsContext*) +void BarrierOperation::operator () (Object* object) { - if (_preBlockOp==GL_FLUSH) glFlush(); - if (_preBlockOp==GL_FINISH) glFinish(); - + if (_preBlockOp!=NO_OPERATION) + { + GraphicsContext* context = dynamic_cast(object); + if (_preBlockOp==GL_FLUSH) glFlush(); + else if (_preBlockOp==GL_FINISH) glFinish(); + } + block(); }