Introduce new run frame rate management support to allow control of maximum frame rate and to support on demand rendering of frames
This commit is contained in:
@@ -73,9 +73,9 @@ class OSGVIEWER_EXPORT CompositeViewer : public ViewerBase, public virtual osg::
|
||||
const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
|
||||
|
||||
virtual double elapsedTime();
|
||||
|
||||
|
||||
virtual osg::FrameStamp* getViewerFrameStamp() { return getFrameStamp(); }
|
||||
|
||||
|
||||
|
||||
/** Execute a main frame loop.
|
||||
* Equivalent to while (!viewer.done()) viewer.frame();
|
||||
@@ -84,17 +84,20 @@ class OSGVIEWER_EXPORT CompositeViewer : public ViewerBase, public virtual osg::
|
||||
*/
|
||||
virtual int run();
|
||||
|
||||
/** check to see if the new frame is required, called by run(..) when FrameScheme is set to ON_DEMAND.*/
|
||||
virtual bool checkNeedToDoFrame();
|
||||
|
||||
virtual void advance(double simulationTime=USE_REFERENCE_TIME);
|
||||
|
||||
virtual void eventTraversal();
|
||||
|
||||
virtual void updateTraversal();
|
||||
|
||||
|
||||
|
||||
|
||||
void setCameraWithFocus(osg::Camera* camera);
|
||||
osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
|
||||
const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }
|
||||
|
||||
|
||||
osgViewer::View* getViewWithFocus() { return _viewWithFocus.get(); }
|
||||
const osgViewer::View* getViewWithFocus() const { return _viewWithFocus.get(); }
|
||||
|
||||
|
||||
@@ -233,6 +233,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
osg::ref_ptr<osg::DisplaySettings> _displaySettings;
|
||||
osgUtil::SceneView::FusionDistanceMode _fusionDistanceMode;
|
||||
float _fusionDistanceValue;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class OSGVIEWER_EXPORT Viewer : public ViewerBase, public osgViewer::View
|
||||
Viewer(const osgViewer::Viewer& viewer, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual ~Viewer();
|
||||
|
||||
|
||||
META_Object(osgViewer,Viewer);
|
||||
|
||||
/** Take all the settings, Camera and Slaves from the passed in view(er), leaving it empty. */
|
||||
@@ -74,9 +74,8 @@ class OSGVIEWER_EXPORT Viewer : public ViewerBase, public osgViewer::View
|
||||
|
||||
|
||||
virtual double elapsedTime();
|
||||
|
||||
virtual osg::FrameStamp* getViewerFrameStamp() { return getFrameStamp(); }
|
||||
|
||||
virtual osg::FrameStamp* getViewerFrameStamp() { return getFrameStamp(); }
|
||||
|
||||
/** Execute a main frame loop.
|
||||
* Equivalent to while (!viewer.done()) viewer.frame();
|
||||
@@ -85,18 +84,21 @@ class OSGVIEWER_EXPORT Viewer : public ViewerBase, public osgViewer::View
|
||||
*/
|
||||
virtual int run();
|
||||
|
||||
/** check to see if the new frame is required, called by run(..) when FrameScheme is set to ON_DEMAND.*/
|
||||
virtual bool checkNeedToDoFrame();
|
||||
|
||||
virtual void advance(double simulationTime=USE_REFERENCE_TIME);
|
||||
|
||||
virtual void eventTraversal();
|
||||
|
||||
virtual void updateTraversal();
|
||||
|
||||
|
||||
void setCameraWithFocus(osg::Camera* camera) { _cameraWithFocus = camera; }
|
||||
osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
|
||||
const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }
|
||||
|
||||
|
||||
virtual void getCameras(Cameras& cameras, bool onlyActive=true);
|
||||
|
||||
|
||||
virtual void getContexts(Contexts& contexts, bool onlyValid=true);
|
||||
|
||||
virtual void getAllThreads(Threads& threads, bool onlyActive=true);
|
||||
|
||||
@@ -199,14 +199,27 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
|
||||
/** Check to see if windows are still open, if not set viewer done to true. */
|
||||
void checkWindowStatus();
|
||||
|
||||
enum FrameScheme
|
||||
{
|
||||
ON_DEMAND,
|
||||
CONTINUOUS
|
||||
};
|
||||
|
||||
void setRunFrameScheme(FrameScheme fs) { _runFrameScheme = fs; }
|
||||
FrameScheme getRunFrameScheme() const { return _runFrameScheme; }
|
||||
|
||||
void setRunMaxFrameRate(double frameRate) { _runMaxFrameRate = frameRate; }
|
||||
double getRunMaxFrameRate() const { return _runMaxFrameRate; }
|
||||
|
||||
/** Execute a main frame loop.
|
||||
* Equivalent to while (!viewer.done()) viewer.frame();
|
||||
* Also calls realize() if the viewer is not already realized,
|
||||
* and installs trackball manipulator if one is not already assigned.
|
||||
*/
|
||||
virtual int run() = 0;
|
||||
virtual int run();
|
||||
|
||||
/** check to see if the new frame is required, called by run(..) when FrameScheme is set to ON_DEMAND.*/
|
||||
virtual bool checkNeedToDoFrame() = 0;
|
||||
|
||||
/** Render a complete new frame.
|
||||
* Calls advance(), eventTraversal(), updateTraversal(), renderingTraversals(). */
|
||||
@@ -249,16 +262,20 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
|
||||
virtual void getUsage(osg::ApplicationUsage& usage) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
void viewerBaseInit();
|
||||
|
||||
friend class osgViewer::View;
|
||||
|
||||
inline void makeCurrent(osg::GraphicsContext* gc)
|
||||
{
|
||||
if (_currentContext==gc) return;
|
||||
|
||||
|
||||
releaseContext();
|
||||
|
||||
|
||||
if (gc && gc->valid() && gc->makeCurrent()) _currentContext = gc;
|
||||
}
|
||||
|
||||
|
||||
inline void releaseContext()
|
||||
{
|
||||
if (_currentContext.valid() && _currentContext->valid())
|
||||
@@ -275,21 +292,28 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
|
||||
int _keyEventSetsDone;
|
||||
bool _quitEventSetsDone;
|
||||
bool _releaseContextAtEndOfFrameHint;
|
||||
|
||||
|
||||
ThreadingModel _threadingModel;
|
||||
bool _threadsRunning;
|
||||
|
||||
bool _requestRedraw;
|
||||
bool _requestContinousUpdate;
|
||||
|
||||
FrameScheme _runFrameScheme;
|
||||
double _runMaxFrameRate;
|
||||
|
||||
|
||||
BarrierPosition _endBarrierPosition;
|
||||
|
||||
osg::ref_ptr<osg::BarrierOperation> _startRenderingBarrier;
|
||||
osg::ref_ptr<osg::BarrierOperation> _endRenderingDispatchBarrier;
|
||||
osg::ref_ptr<osg::EndOfDynamicDrawBlock> _endDynamicDrawBlock;
|
||||
|
||||
|
||||
osg::ref_ptr<osgGA::EventVisitor> _eventVisitor;
|
||||
|
||||
|
||||
osg::ref_ptr<osg::OperationQueue> _updateOperations;
|
||||
osg::ref_ptr<osgUtil::UpdateVisitor> _updateVisitor;
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Operation> _realizeOperation;
|
||||
osg::ref_ptr<osgUtil::IncrementalCompileOperation> _incrementalCompileOperation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user