Added lazy state updating for vertex array object binding/unbinding

This commit is contained in:
Robert Osfield
2017-03-13 11:44:34 +00:00
parent a6453ad877
commit ffbc1167de
6 changed files with 26 additions and 9 deletions

View File

@@ -642,7 +642,7 @@ void Drawable::draw(RenderInfo& renderInfo) const
State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas);
vas->bindVertexArrayObject();
state.bindVertexArrayObject(vas);
drawInner(renderInfo);
@@ -652,7 +652,11 @@ void Drawable::draw(RenderInfo& renderInfo) const
}
// TODO, add check against whether VAO is active and supported
if (state.getCurrentVertexArrayState()) state.getCurrentVertexArrayState()->bindVertexArrayObject();
if (state.getCurrentVertexArrayState())
{
//OSG_NOTICE<<"state.getCurrentVertexArrayState()->getVertexArrayObject()="<< state.getCurrentVertexArrayState()->getVertexArrayObject()<<std::endl;
state.bindVertexArrayObject(state.getCurrentVertexArrayState());
}
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE

View File

@@ -820,9 +820,11 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const
State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas);
vas->bindVertexArrayObject();
state.bindVertexArrayObject(vas);
drawVertexArraysImplementation(renderInfo);
state.unbindVertexArrayObject();
}
}
else

View File

@@ -89,6 +89,7 @@ State::State():
_currentClientActiveTextureUnit=0;
_currentPBO = 0;
_currentVAO = 0;
_isSecondaryColorSupported = false;
_isFogCoordSupported = false;

View File

@@ -861,10 +861,12 @@ void SharedGeometry::compileGLObjects(osg::RenderInfo& renderInfo) const
osg::State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas);
vas->bindVertexArrayObject();
state.bindVertexArrayObject(vas);
if (vbo_glBufferObject) vas->bindVertexBufferObject(vbo_glBufferObject);
if (ebo_glBufferObject) vas->bindElementBufferObject(ebo_glBufferObject);
state.unbindVertexArrayObject();
}
}