From 605821e655d97b7ad5ab6098b3ec26e2f9ad2ff7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 7 Jan 2020 11:12:18 +0000 Subject: [PATCH] Implemented TextBase::compileGLObjects() with handling of VAO/VBOs to address bugs associated with VAO usage of Text. --- src/osgText/TextBase.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/osgText/TextBase.cpp b/src/osgText/TextBase.cpp index 4a2d887bb..a45e25b7b 100644 --- a/src/osgText/TextBase.cpp +++ b/src/osgText/TextBase.cpp @@ -139,7 +139,34 @@ osg::VertexArrayState* TextBase::createVertexArrayStateImplementation(osg::Rende void TextBase::compileGLObjects(osg::RenderInfo& renderInfo) const { - Drawable::compileGLObjects(renderInfo); + State& state = *renderInfo.getState(); + if (renderInfo.getState()->useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects)) + { + unsigned int contextID = state.getContextID(); + GLExtensions* extensions = state.get(); + if (state.useVertexArrayObject(_useVertexArrayObject)) + { + VertexArrayState* vas = 0; + + _vertexArrayStateList[contextID] = vas = createVertexArrayState(renderInfo); + + State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas); + + state.bindVertexArrayObject(vas); + + drawImplementation(renderInfo); + + state.unbindVertexArrayObject(); + } + else + { + drawImplementation(renderInfo); + } + + // unbind the BufferObjects + extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); + extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0); + } } void TextBase::resizeGLObjectBuffers(unsigned int maxSize)