Added initializers and handling of null case

This commit is contained in:
Robert Osfield 2016-06-23 11:03:38 +01:00
parent 79f174aee4
commit bc8452512f
2 changed files with 34 additions and 12 deletions

View File

@ -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()

View File

@ -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()