Added Viewer::setEndBarrierPosition method, change Viewer::setKeySetsDone(int) to setKeyEventSetDone(int),

added support for toggling threading model and end barrier position into osgviewer
This commit is contained in:
Robert Osfield
2007-01-12 21:05:39 +00:00
parent 5a515914bc
commit 694b304c00
5 changed files with 199 additions and 27 deletions

View File

@@ -57,14 +57,30 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
/** Get the threading model the rendering traversals will use.*/
ThreadingModel getThreadingModel() const { return _threadingModel; }
/** Set the key value that the viewer checks on each frame to see if the viewer's done flag should be set to
enum BarrierPosition
{
BeforeSwapBuffers,
AfterSwapBuffers
};
/** Set the position of the end barrier.
* AfterSwapBuffers will may result is slightly higher framerates, by may
* lead to inconcistent swapping between different windows.
* BeforeSwapBuffers may lead to slightly lower framerate, but improve consistency in timing of swap buffers,
* especially important if you are likely to consistently break frame.*/
void setEndBarrierPosition(BarrierPosition bp);
/** Get the end barrier position.*/
BarrierPosition getEndBarrierPosition() const { return _endBarrierPosition; }
/** Set the key event that the viewer checks on each frame to see if the viewer's done flag should be set to
* signal end of viewers main loop.
* Default value is Escape (osgGA::GUIEVentAdapter::KEY_Escape).
* Setting to 0 switches off the feature.*/
void setKeySetsDone(int key) { _keySetsDone = key; }
void setKeyEventSetsDone(int key) { _keyEventSetsDone = key; }
/** get the key value that the viewer checks on each frame to see if the viewer's done flag.*/
int getKeySetsDone() const { return _keySetsDone; }
/** get the key event that the viewer checks on each frame to see if the viewer's done flag.*/
int getKeyEventSetsDone() const { return _keyEventSetsDone; }
/** if the flag is true, the viewer set its done flag when a QUIT_APPLICATION is received, false disables this feature */
void setQuitEventSetsDone(bool flag) { _quitEventSetsDone = flag; }
@@ -121,11 +137,12 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
bool _firstFrame;
bool _done;
int _keySetsDone;
int _keyEventSetsDone;
bool _quitEventSetsDone;
ThreadingModel _threadingModel;
BarrierPosition _endBarrierPosition;
osg::ref_ptr<osg::BarrierOperation> _startRenderingBarrier;
osg::ref_ptr<osg::BarrierOperation> _endRenderingDispatchBarrier;