diff --git a/include/osgUtil/GLObjectsVisitor b/include/osgUtil/GLObjectsVisitor index 4b0eaf0ed..f5de798e6 100644 --- a/include/osgUtil/GLObjectsVisitor +++ b/include/osgUtil/GLObjectsVisitor @@ -33,12 +33,14 @@ class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor /** Operation modes of the.*/ enum ModeValues { - SWITCH_ON_DISPLAY_LISTS = 0x1, - SWITCH_OFF_DISPLAY_LISTS = 0x2, - COMPILE_DISPLAY_LISTS = 0x4, - COMPILE_STATE_ATTRIBUTES = 0x8, - RELEASE_DISPLAY_LISTS = 0x10, - RELEASE_STATE_ATTRIBUTES = 0x20 + SWITCH_ON_DISPLAY_LISTS = 0x1, + SWITCH_OFF_DISPLAY_LISTS = 0x2, + COMPILE_DISPLAY_LISTS = 0x4, + COMPILE_STATE_ATTRIBUTES = 0x8, + RELEASE_DISPLAY_LISTS = 0x10, + RELEASE_STATE_ATTRIBUTES = 0x20, + SWITCH_ON_VERTEX_BUFFER_OBJECTS = 0x40, + SWITCH_OFF_VERTEX_BUFFER_OBJECTS = 0x80 }; typedef unsigned int Mode; @@ -83,7 +85,7 @@ class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor protected: Mode _mode; - + osg::ref_ptr _state; }; diff --git a/src/osgUtil/GLObjectsVisitor.cpp b/src/osgUtil/GLObjectsVisitor.cpp index 66c476d8c..fd380b5fb 100644 --- a/src/osgUtil/GLObjectsVisitor.cpp +++ b/src/osgUtil/GLObjectsVisitor.cpp @@ -20,9 +20,9 @@ using namespace osgUtil; GLObjectsVisitor::GLObjectsVisitor(Mode mode) { setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN); - + _mode = mode; - + _state = NULL; } @@ -79,6 +79,16 @@ void GLObjectsVisitor::apply(osg::Drawable& drawable) { drawable.releaseGLObjects(_state.get()); } + + if (_mode&SWITCH_ON_VERTEX_BUFFER_OBJECTS) + { + drawable.setUseVertexBufferObjects(true); + } + + if (_mode&SWITCH_OFF_VERTEX_BUFFER_OBJECTS) + { + drawable.setUseVertexBufferObjects(false); + } } void GLObjectsVisitor::apply(osg::StateSet& stateset)