Added support for an osgUtil::SceneView::init() traversal which is called once
per scene view. The user can attach a NodeVisitor to do init for them, or leave it to the default which is to use the osgUtil::DisplayListVisitor which compiles all display lists and texture objects. The init traversal is called automatically by the first call to either app() or cull(), so should not be called by user code during initialization. This ensures that a valid graphics context has been established before OpenGL is initialized. osgUtil::DisplayListVisitor has also been updated to use a bit mask for options, and the addition of compilation of texture objects (via StateAttribute::compile) has also been added.
This commit is contained in:
@@ -110,6 +110,10 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
const osg::State* getState() const { return _state.get(); }
|
||||
|
||||
|
||||
void setInitVisitor(osg::NodeVisitor* av) { _initVisitor = av; }
|
||||
osg::NodeVisitor* getInitVisitor() { return _initVisitor.get(); }
|
||||
const osg::NodeVisitor* getInitVisitor() const { return _initVisitor.get(); }
|
||||
|
||||
void setAppVisitor(osg::NodeVisitor* av) { _appVisitor = av; }
|
||||
osg::NodeVisitor* getAppVisitor() { return _appVisitor.get(); }
|
||||
const osg::NodeVisitor* getAppVisitor() const { return _appVisitor.get(); }
|
||||
@@ -181,14 +185,22 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
inline const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
|
||||
|
||||
|
||||
/** Do init traversal of attached scene graph using Init NodeVisitor.
|
||||
* The init traversal is called once for each SceneView, and should
|
||||
* be used to compile display list, texture objects intialize data
|
||||
* not otherwise intializaed during scene graph loading. Note, is
|
||||
* called automatically by app&cull if it hasn't already been called
|
||||
* elsewhere. Also init() should only ever be called within a valid
|
||||
* graphics context.*/
|
||||
virtual void init();
|
||||
|
||||
/** do app traversal of attached scene graph using App NodeVisitor.*/
|
||||
/** Do app traversal of attached scene graph using App NodeVisitor.*/
|
||||
virtual void app();
|
||||
|
||||
/** do cull traversal of attached scene graph using App CullVisitor.*/
|
||||
/** Do cull traversal of attached scene graph using Cull NodeVisitor.*/
|
||||
virtual void cull();
|
||||
|
||||
/** do draw traversal of draw bins generated by cull traversal.*/
|
||||
/** Do draw traversal of draw bins generated by cull traversal.*/
|
||||
virtual void draw();
|
||||
|
||||
protected:
|
||||
@@ -201,6 +213,8 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
osg::ref_ptr<osg::State> _state;
|
||||
|
||||
bool _initCalled;
|
||||
osg::ref_ptr<osg::NodeVisitor> _initVisitor;
|
||||
osg::ref_ptr<osg::NodeVisitor> _appVisitor;
|
||||
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitor;
|
||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraph;
|
||||
|
||||
Reference in New Issue
Block a user