Added support for AbortRendering flag pointer in osg::State which is used

by osgUtil::RenderLeaf to test if any abort state has been set, if so it
doesn't do any further drawing.

The osgProducer::Viewer has been set up to set the osg::State's it manages
with their AbortRendering flag pointers set to the osgProducer::Viewer::_done
memeber varaible.  Now when escape is pressed the rendering is aborted early.
This commit is contained in:
Robert Osfield
2003-03-11 15:25:49 +00:00
parent 78de76f17f
commit e51c7f1587
5 changed files with 29 additions and 2 deletions

View File

@@ -565,6 +565,14 @@ class SG_EXPORT State : public Referenced
typedef std::vector<StateAttribute::GLModeValue> ValueVec;
/** Set flag for early termination of the draw traversal.*/
void setAbortRenderingPtr(bool* abortPtr) { _abortRenderingPtr = abortPtr; }
/** Get flag for early termination of the draw traversal,
* if true steps should be taken to complete rendering early.*/
bool getAbortRendering() const { return _abortRenderingPtr!=0?(*_abortRenderingPtr):false; }
void setReportGLErrors(bool flag) { _reportGLErrors = flag; }
bool getReportGLErrors() const { return _reportGLErrors; }
@@ -572,6 +580,7 @@ class SG_EXPORT State : public Referenced
bool checkGLErrors(StateAttribute::GLMode mode) const;
bool checkGLErrors(const StateAttribute* attribute) const;
protected:
virtual ~State();
@@ -585,7 +594,7 @@ class SG_EXPORT State : public Referenced
ref_ptr<DisplaySettings> _displaySettings;
bool* _abortRenderingPtr;
bool _reportGLErrors;
struct ModeStack

View File

@@ -23,7 +23,8 @@ State::State()
_identity = new osg::RefMatrix(); // default RefMatrix constructs to identity.
_projection = _identity;
_modelView = _identity;
_abortRenderingPtr = false;
_reportGLErrors = true;
_currentActiveTextureUnit=0;

View File

@@ -26,6 +26,11 @@ void KeyboardMouseCallback::keyPress( Producer::KeySymbol key )
#endif
}
if (_done)
{
// need to contact the viewer so pass on the abort..
}
osg::ref_ptr<EventAdapter> event = new EventAdapter;
event->adaptKeyPress(getTime(),key);

View File

@@ -187,6 +187,12 @@ void Viewer::realize( ThreadingModel thread_model)
OsgCameraGroup::realize( thread_model );
// set up osg::State objects with a the _done prt to allow early termination of
// draw traversal.
for(SceneHandlerList::iterator p=_shvec.begin(); p!=_shvec.end(); p++ )
{
(*p)->getState()->setAbortRenderingPtr(&_done);
}
}

View File

@@ -18,6 +18,12 @@ using namespace osgUtil;
void RenderLeaf::render(State& state,RenderLeaf* previous)
{
// don't draw this leaf if the abort rendering flag has been set.
if (state.getAbortRendering())
{
//cout << "early abort"<<endl;
return;
}
if (previous)
{