From d1453a41c20b2430c8e6a0ed42f973d0a8fcde77 Mon Sep 17 00:00:00 2001 From: "Konstantin S. Matveyev" Date: Tue, 22 Aug 2017 10:12:36 +0300 Subject: [PATCH] Geometry::compileGLObjects function VAO fix --- src/osg/Geometry.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 {