Added set/getRealizeOperation() to Viewer and CompositeViewer

This commit is contained in:
Robert Osfield
2007-01-28 17:11:21 +00:00
parent 25e4fd32ac
commit af6de09ab4
4 changed files with 54 additions and 9 deletions

View File

@@ -138,11 +138,21 @@ class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced
typedef std::vector<osgViewer::Scene*> Scenes;
void getScenes(Scenes& scenes, bool onlyValid=true);
void stopThreading();
void startThreading();
void setUpRenderingSupport();
public:
/** Set the graphics operation to call on realization of the viewers graphics windows.*/
void setRealizeOperation(osg::GraphicsOperation* op) { _realizeOperation = op; }
/** Get the graphics operation to call on realization of the viewers graphics windows.*/
osg::GraphicsOperation* getRealizeOperation() { return _realizeOperation.get(); }
/** Stop any threads begin run by viewer.*/
void stopThreading();
/** Start any threads required by the viewer, as per viewers ThreadingModel.*/
void startThreading();
/** Set up the GraphicsOperations to render the various viewer cameras on the viewers graphics windows.*/
void setUpRenderingSupport();
protected:
@@ -180,6 +190,8 @@ class OSGVIEWER_EXPORT CompositeViewer : public osg::Referenced
osg::ref_ptr<osgGA::EventQueue> _eventQueue;
osg::ref_ptr<osgGA::EventVisitor> _eventVisitor;
osg::ref_ptr<osg::GraphicsOperation> _realizeOperation;
};

View File

@@ -123,8 +123,19 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
typedef std::vector<osgViewer::GraphicsWindow*> Windows;
void getWindows(Windows& windows, bool onlyValid=true);
/** Set the graphics operation to call on realization of the viewers graphics windows.*/
void setRealizeOperation(osg::GraphicsOperation* op) { _realizeOperation = op; }
/** Get the graphics operation to call on realization of the viewers graphics windows.*/
osg::GraphicsOperation* getRealizeOperation() { return _realizeOperation.get(); }
/** Stop any threads begin run by viewer.*/
void stopThreading();
/** Start any threads required by the viewer, as per viewers ThreadingModel.*/
void startThreading();
/** Set up the GraphicsOperations to render the various viewer cameras on the viewers graphics windows.*/
void setUpRenderingSupport();
protected:
@@ -156,6 +167,8 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
osg::observer_ptr<osg::Camera> _cameraWithFocus;
osg::ref_ptr<osgGA::EventVisitor> _eventVisitor;
osg::ref_ptr<osg::GraphicsOperation> _realizeOperation;
};

View File

@@ -694,7 +694,17 @@ void CompositeViewer::realize()
citr != contexts.end();
++citr)
{
(*citr)->realize();
osg::GraphicsContext* gc = *citr;
gc->realize();
if (_realizeOperation.valid())
{
gc->makeCurrent();
(*_realizeOperation)(gc);
gc->releaseContext();
}
}
bool grabFocus = true;

View File

@@ -756,7 +756,17 @@ void Viewer::realize()
citr != contexts.end();
++citr)
{
(*citr)->realize();
osg::GraphicsContext* gc = *citr;
gc->realize();
if (_realizeOperation.valid())
{
gc->makeCurrent();
(*_realizeOperation)(gc);
gc->releaseContext();
}
}
bool grabFocus = true;
@@ -774,14 +784,14 @@ void Viewer::realize()
}
}
startThreading();
// initialize the global timer to be relative to the current time.
osg::Timer::instance()->setStartTick();
// pass on the start tick to all the associated eventqueues
setStartTick(osg::Timer::instance()->getStartTick());
startThreading();
}