diff --git a/examples/osgcamera/osgcamera.cpp b/examples/osgcamera/osgcamera.cpp index 90f6335b8..c47fdec06 100644 --- a/examples/osgcamera/osgcamera.cpp +++ b/examples/osgcamera/osgcamera.cpp @@ -32,6 +32,7 @@ struct FrameOperation : public osg::GraphicsThread::Operation { FrameOperation(osg::CameraNode* camera, osg::FrameStamp* frameStamp): + osg::GraphicsThread::Operation("Frame",true), _camera(camera), _frameStamp(frameStamp) { @@ -174,6 +175,7 @@ int main( int argc, char **argv ) previous_tick = current_tick; + // do the update traversal. loadedModel->accept(updateVisitor); // issue the frame for each camera. diff --git a/include/osg/GraphicsThread b/include/osg/GraphicsThread index e4cba3f4b..64e39ce88 100644 --- a/include/osg/GraphicsThread +++ b/include/osg/GraphicsThread @@ -84,7 +84,27 @@ class OSG_EXPORT GraphicsThread : public Referenced, public OpenThreads::Thread /** Base class for implementing GraphicsThread operations.*/ struct OSG_EXPORT Operation : public Referenced { + Operation(const std::string& name, bool keep): + _name(name), + _keep(true) {} + + /** Set the human readable name of the operation.*/ + void setName(const std::string& name) { _name = name; } + + /** Get the human readable name of the operation.*/ + const std::string& gtName() const { return _name; } + + /** Set whether the operation should be kept once its been applied.*/ + void setKeep(bool keep) { _keep = keep; } + + /** Get whether the operation should be kept once its been applied.*/ + bool getKeep() const { return _keep; } + + /** Do the actual task of this operation.*/ virtual void operator () (GraphicsContext*) {} + + std::string _name; + bool _keep; }; /** Add operation to end of OperationQueue, this will be @@ -118,10 +138,13 @@ class OSG_EXPORT GraphicsThread : public Referenced, public OpenThreads::Thread /** SwapBufferOperation calls swap buffers on the GraphicsContext.*/ struct OSG_EXPORT SwapBuffersOperation : public GraphicsThread::Operation { + SwapBuffersOperation(): + GraphicsThread::Operation("SwapBuffers",true) {} + virtual void operator () (GraphicsContext* context); }; -/** BarrierOperation allows one syncronize multiple GraphicsThreads with each other.*/ +/** BarrierOperation allows one to syncronize multiple GraphicsThreads with each other.*/ struct OSG_EXPORT BarrierOperation : public GraphicsThread::Operation, public OpenThreads::Barrier { enum PreBlockOp @@ -131,7 +154,10 @@ struct OSG_EXPORT BarrierOperation : public GraphicsThread::Operation, public Op GL_FINISH }; - BarrierOperation(int numThreads, PreBlockOp op=NO_OPERATION): OpenThreads::Barrier(numThreads), _preBlockOp(op) {} + BarrierOperation(int numThreads, PreBlockOp op=NO_OPERATION): + GraphicsThread::Operation("Barrier", true), + OpenThreads::Barrier(numThreads), + _preBlockOp(op) {} virtual void operator () (GraphicsContext* context); @@ -142,7 +168,8 @@ struct OSG_EXPORT BarrierOperation : public GraphicsThread::Operation, public Op * then blocks waiting for context to be released, once the block is release the context is re-aqquired.*/ struct OSG_EXPORT ReleaseContext_Block_MakeCurrentOperation : public GraphicsThread::Operation, public Block { - ReleaseContext_Block_MakeCurrentOperation() {} + ReleaseContext_Block_MakeCurrentOperation(): + GraphicsThread::Operation("ReleaseContext_Block_MakeCurrent", false) {} virtual void operator () (GraphicsContext* context); }; diff --git a/include/osgProducer/GraphicsContextImplementation b/include/osgProducer/GraphicsContextImplementation index 7a31a448c..5a964df53 100644 --- a/include/osgProducer/GraphicsContextImplementation +++ b/include/osgProducer/GraphicsContextImplementation @@ -50,7 +50,7 @@ class OSGPRODUCER_EXPORT GraphicsContextImplementation : public osg::GraphicsCon /** Return true if the graphics context has been realised and is ready to use.*/ virtual bool isRealizedImplementation() const { return _rs.valid() && _rs->isRealized(); } - /** Release the graphics context.*/ + /** Close the graphics context.*/ virtual void closeImplementation(); /** Make this graphics context current.*/ diff --git a/src/osg/GraphicsThread.cpp b/src/osg/GraphicsThread.cpp index f459307dc..6de3e889f 100644 --- a/src/osg/GraphicsThread.cpp +++ b/src/osg/GraphicsThread.cpp @@ -21,7 +21,11 @@ using namespace OpenThreads; struct BlockOperation : public GraphicsThread::Operation, public Block { - BlockOperation() { reset(); } + BlockOperation(): + GraphicsThread::Operation("Block",false) + { + reset(); + } virtual void operator () (GraphicsContext*) {