diff --git a/include/osg/State b/include/osg/State index f3a098a30..22e5f71bb 100644 --- a/include/osg/State +++ b/include/osg/State @@ -517,10 +517,14 @@ class OSG_EXPORT State : public Referenced const GLBufferObject* getCurrentVertexBufferObject() { return _currentVBO; } inline void bindVertexBufferObject(osg::GLBufferObject* vbo) { - if (vbo == _currentVBO) return; - if (vbo->isDirty()) vbo->compileBuffer(); - else vbo->bindBuffer(); - _currentVBO = vbo; + if (vbo) + { + if (vbo == _currentVBO) return; + if (vbo->isDirty()) vbo->compileBuffer(); + else vbo->bindBuffer(); + _currentVBO = vbo; + } + else unbindVertexBufferObject(); } inline void unbindVertexBufferObject() @@ -535,10 +539,14 @@ class OSG_EXPORT State : public Referenced inline void bindElementBufferObject(osg::GLBufferObject* ebo) { - if (ebo == _currentEBO) return; - if (ebo->isDirty()) ebo->compileBuffer(); - else ebo->bindBuffer(); - _currentEBO = ebo; + if (ebo) + { + if (ebo == _currentEBO) return; + if (ebo->isDirty()) ebo->compileBuffer(); + else ebo->bindBuffer(); + _currentEBO = ebo; + } + else unbindElementBufferObject(); } inline void unbindElementBufferObject() @@ -553,12 +561,19 @@ class OSG_EXPORT State : public Referenced inline void bindPixelBufferObject(osg::GLBufferObject* pbo) { - if (pbo == _currentPBO) return; + if (pbo) + { + if (pbo == _currentPBO) return; - if (pbo->isDirty()) pbo->compileBuffer(); - else pbo->bindBuffer(); + if (pbo->isDirty()) pbo->compileBuffer(); + else pbo->bindBuffer(); - _currentPBO = pbo; + _currentPBO = pbo; + } + else + { + unbindPixelBufferObject(); + } } inline void unbindPixelBufferObject() diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 77f44cbd4..5f52f8034 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -115,6 +115,10 @@ State::State(): _glDisableVertexAttribArray = 0; _glDrawArraysInstanced = 0; _glDrawElementsInstanced = 0; + _glMultiTexCoord4f = 0; + _glVertexAttrib4fv = 0; + _glVertexAttrib4f = 0; + _glBindBuffer = 0; _dynamicObjectCount = 0; @@ -133,6 +137,9 @@ State::State(): _gpuTick = 0; _gpuTimestamp = 0; _timestampBits = 0; + + + } State::~State()