Added lazy state updating for vertex array object binding/unbinding
This commit is contained in:
parent
a6453ad877
commit
ffbc1167de
@ -563,7 +563,7 @@ class OSG_EXPORT State : public Referenced
|
||||
|
||||
|
||||
void setCurrentPixelBufferObject(osg::GLBufferObject* pbo) { _currentPBO = pbo; }
|
||||
const GLBufferObject* getCurrentPixelBufferObject() { return _currentPBO; }
|
||||
const GLBufferObject* getCurrentPixelBufferObject() const { return _currentPBO; }
|
||||
|
||||
inline void bindPixelBufferObject(osg::GLBufferObject* pbo)
|
||||
{
|
||||
@ -590,6 +590,17 @@ class OSG_EXPORT State : public Referenced
|
||||
_currentPBO = 0;
|
||||
}
|
||||
|
||||
|
||||
void setCurrentVertexArrayObject(GLuint vao) { _currentVAO = vao; }
|
||||
GLuint getCurrentVertexArrayObject() const { return _currentVAO; }
|
||||
|
||||
inline void bindVertexArrayObject(const VertexArrayState* vas) { bindVertexArrayObject(vas->getVertexArrayObject()); }
|
||||
|
||||
inline void bindVertexArrayObject(GLuint vao) { if (_currentVAO!=vao) { _glExtensions->glBindVertexArray(vao); _currentVAO = vao; } }
|
||||
|
||||
inline void unbindVertexArrayObject() { if (_currentVAO!=0) { _glExtensions->glBindVertexArray(0); _currentVAO = 0; } }
|
||||
|
||||
|
||||
typedef std::vector<GLushort> IndicesGLushort;
|
||||
IndicesGLushort _quadIndicesGLushort[4];
|
||||
|
||||
@ -1248,6 +1259,7 @@ class OSG_EXPORT State : public Referenced
|
||||
unsigned int _currentActiveTextureUnit;
|
||||
unsigned int _currentClientActiveTextureUnit;
|
||||
GLBufferObject* _currentPBO;
|
||||
GLuint _currentVAO;
|
||||
|
||||
|
||||
inline ModeMap& getOrCreateTextureModeMap(unsigned int unit)
|
||||
|
@ -164,10 +164,6 @@ public:
|
||||
|
||||
void deleteVertexArrayObject();
|
||||
|
||||
inline void bindVertexArrayObject() const { _ext->glBindVertexArray (_vertexArrayObject); }
|
||||
|
||||
inline void unbindVertexArrayObject() const { _ext->glBindVertexArray (0); }
|
||||
|
||||
GLuint getVertexArrayObject() const { return _vertexArrayObject; }
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -89,6 +89,7 @@ State::State():
|
||||
_currentClientActiveTextureUnit=0;
|
||||
|
||||
_currentPBO = 0;
|
||||
_currentVAO = 0;
|
||||
|
||||
_isSecondaryColorSupported = false;
|
||||
_isFogCoordSupported = false;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user