diff --git a/include/osg/VertexArrayState b/include/osg/VertexArrayState index 335d5044e..efc96371b 100644 --- a/include/osg/VertexArrayState +++ b/include/osg/VertexArrayState @@ -88,6 +88,8 @@ public: _currentEBO = 0; } + void resetBufferObjectPointers() { _currentVBO = 0; _currentEBO = 0; } + void assignAllDispatchers(); virtual void assignVertexArrayDispatcher(); diff --git a/src/osg/Drawable.cpp b/src/osg/Drawable.cpp index c13fd5c21..bba87a5aa 100644 --- a/src/osg/Drawable.cpp +++ b/src/osg/Drawable.cpp @@ -628,6 +628,15 @@ void Drawable::draw(RenderInfo& renderInfo) const { _vertexArrayStateList[contextID] = vas = setUpVertexArrayState(renderInfo, true); } + else + { + vas->setRequiresSetArrays(getDataVariance()==osg::Object::DYNAMIC); + } + + if (vas->getRequiresSetArrays()) + { + vas->resetBufferObjectPointers(); + } State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas); @@ -635,8 +644,6 @@ void Drawable::draw(RenderInfo& renderInfo) const drawInner(renderInfo); - vas->setRequiresSetArrays(getDataVariance()==osg::Object::DYNAMIC); - return; } #endif diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index 309c20c1a..84377c116 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -699,8 +699,6 @@ VertexArrayState* Geometry::setUpVertexArrayState(RenderInfo& renderInfo, bool u void Geometry::compileGLObjects(RenderInfo& renderInfo) const { State& state = *renderInfo.getState(); - const DisplaySettings* ds = state.getDisplaySettings() ? state.getDisplaySettings() : osg::DisplaySettings::instance(); - bool useVertexArrays = _supportsVertexBufferObjects && _useVertexBufferObjects && renderInfo.getState()->isVertexBufferObjectSupported(); @@ -762,9 +760,19 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); + const DisplaySettings* ds = state.getDisplaySettings() ? state.getDisplaySettings() : osg::DisplaySettings::instance(); if (ds->getGeometryImplementation()==DisplaySettings::VERTEX_ARRAY_OBJECT && !bufferObjects.empty()) { - setUpVertexArrayState(renderInfo, true); + VertexArrayState* vas = 0; + + _vertexArrayStateList[contextID] = vas = setUpVertexArrayState(renderInfo, true); + + State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas); + + vas->bindVertexArrayObject(); + + + drawVertexArraysImplementation(renderInfo); } } else diff --git a/src/osg/VertexArrayState.cpp b/src/osg/VertexArrayState.cpp index e7adc9462..7a317dea6 100644 --- a/src/osg/VertexArrayState.cpp +++ b/src/osg/VertexArrayState.cpp @@ -346,20 +346,6 @@ VertexArrayState::VertexArrayState(osg::GLExtensions* ext): { } -#if 0 -osg::GLBufferObject* VertexArrayState::getGLBufferObject(osg::Array* array) -{ - if (_ext->isBufferObjectSupported && array->getBufferObject()) - { - return array->getBufferObject()->getOrCreateGLBufferObject(_ext->contextID); - } - else - { - return 0; - } -} -#endif - void VertexArrayState::generateVretexArrayObject() { _ext->glGenVertexArrays(1, &_vertexArrayObject);