Improved handling of VBO/VAO's in Text3D

This commit is contained in:
Robert Osfield
2017-03-09 17:47:27 +00:00
parent 2cad221d80
commit 7f3f995c56

View File

@@ -499,13 +499,17 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
// OSG_NOTICE<<"No need to apply matrix "<<std::endl;
}
osg::VertexArrayState* vas = state.getCurrentVertexArrayState();
bool usingVertexArrayObjects = usingVertexBufferObjects && state.useVertexArrayObject(_useVertexArrayObject);
bool requiresSetArrays = !usingVertexBufferObjects || !usingVertexArrayObjects || vas->getRequiresSetArrays();
state.lazyDisablingOfVertexAttributes();
state.setVertexPointer(_coords.get());
state.setNormalPointer(_normals.get());
state.applyDisablingOfVertexAttributes();
if (requiresSetArrays)
{
vas->lazyDisablingOfVertexAttributes();
vas->setVertexArray(state, _coords.get());
vas->setNormalArray(state, _normals.get());
vas->applyDisablingOfVertexAttributes(state);
}
if ((_drawMode&(~TEXT))!=0)
{
@@ -559,6 +563,13 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
}
}
if (!usingVertexArrayObjects)
{
// unbind the VBO's if any are used.
vas->unbindVertexBufferObject();
vas->unbindElementBufferObject();
}
if (needToApplyMatrix)
{
// restore the previous modelview matrix