Fixed VertexArrayState::bind*BufferObject(..) methods so they correctly handle dirtied buffer objects

This commit is contained in:
Robert Osfield
2016-09-01 14:38:16 +01:00
parent a5e0398a29
commit 8febae1546
2 changed files with 33 additions and 17 deletions

View File

@@ -60,10 +60,16 @@ public:
inline void bindVertexBufferObject(osg::GLBufferObject* vbo)
{
if (vbo == _currentVBO) return;
if (vbo->isDirty()) vbo->compileBuffer();
else vbo->bindBuffer();
_currentVBO = vbo;
if (vbo->isDirty())
{
vbo->compileBuffer();
_currentVBO = vbo;
}
else if (vbo != _currentVBO)
{
vbo->bindBuffer();
_currentVBO = vbo;
}
}
inline void unbindVertexBufferObject()
@@ -79,10 +85,16 @@ public:
inline void bindElementBufferObject(osg::GLBufferObject* ebo)
{
if (ebo == _currentEBO) return;
if (ebo->isDirty()) ebo->compileBuffer();
else ebo->bindBuffer();
_currentEBO = ebo;
if (ebo->isDirty())
{
ebo->compileBuffer();
_currentEBO = ebo;
}
else if (ebo != _currentEBO)
{
ebo->bindBuffer();
_currentEBO = ebo;
}
}
inline void unbindElementBufferObject()
@@ -104,7 +116,8 @@ public:
void assignTexCoordArrayDispatcher(unsigned int numUnits);
void assignVertexAttribArrayDispatcher(unsigned int numUnits);
inline bool isVertexBufferObjectSupported() const { return true; }
inline void setVertexBufferObjectSupported(bool flag) { _isVertexBufferObjectSupported = flag; }
inline bool isVertexBufferObjectSupported() const { return _isVertexBufferObjectSupported; }
void setArray(ArrayDispatch* vad, osg::State& state, const osg::Array* new_array);
void setArray(ArrayDispatch* vad, osg::State& state, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr, GLboolean normalized);
@@ -173,6 +186,8 @@ public:
osg::State* _state;
osg::ref_ptr<osg::GLExtensions> _ext;
bool _isVertexBufferObjectSupported;
GLuint _vertexArrayObject;