From 700e38ba9dca6d67593c5efb6d3c79edbae312e1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 2 Jun 2016 15:35:47 +0100 Subject: [PATCH] Added handling of failure to create ElementBufferObject. --- src/osgTerrain/GeometryPool.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/osgTerrain/GeometryPool.cpp b/src/osgTerrain/GeometryPool.cpp index 9c494d421..b0e237913 100644 --- a/src/osgTerrain/GeometryPool.cpp +++ b/src/osgTerrain/GeometryPool.cpp @@ -958,14 +958,21 @@ void SharedGeometry::drawImplementation(osg::RenderInfo& renderInfo) const osg::GLBufferObject* ebo = _drawElements->getOrCreateGLBufferObject(state.getContextID()); - state.bindElementBufferObject(ebo); + if (ebo) + { + state.bindElementBufferObject(ebo); - glDrawElements(primitiveType, _drawElements->getNumIndices(), _drawElements->getDataType(), (const GLvoid *)(ebo->getOffset(_drawElements->getBufferIndex()))); + glDrawElements(primitiveType, _drawElements->getNumIndices(), _drawElements->getDataType(), (const GLvoid *)(ebo->getOffset(_drawElements->getBufferIndex()))); + state.unbindElementBufferObject(); + } + else + { + glDrawElements(primitiveType, _drawElements->getNumIndices(), _drawElements->getDataType(), _drawElements->getDataPointer()); + } // unbind the VBO's if any are used. state.unbindVertexBufferObject(); - state.unbindElementBufferObject(); if (checkForGLErrors) state.checkGLErrors("end of SharedGeometry::drawImplementation()."); }