Added set/getRealizeOperation() to Viewer and CompositeViewer
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user