diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index 5fe643a88..aff29211b 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -791,6 +791,9 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const if ((*itr)->getBufferObject()) bufferObjects.insert((*itr)->getBufferObject()); } + if (bufferObjects.empty()) + return; // no buffers, nothing to compile + //osg::ElapsedTime timer; // now compile any buffer objects that require it. @@ -808,11 +811,7 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const // OSG_NOTICE<<"Time to compile "<glBindBuffer(GL_ARRAY_BUFFER_ARB,0); - extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); - - if (state.useVertexArrayObject(_useVertexArrayObject) && !bufferObjects.empty()) + if (state.useVertexArrayObject(_useVertexArrayObject)) { VertexArrayState* vas = 0; @@ -826,6 +825,10 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const state.unbindVertexArrayObject(); } + + // unbind the BufferObjects + extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); + extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); } else {