Further work VertexBufferObject and ElementsBufferObject classes

This commit is contained in:
Robert Osfield
2007-04-26 16:50:06 +00:00
parent 0df82ba60f
commit a3e6d8283d
4 changed files with 333 additions and 16 deletions

View File

@@ -416,7 +416,25 @@ class DrawElements : public PrimitiveSet
/** Set the ElementsBufferObject.*/
inline void setElementsBufferObject(osg::ElementsBufferObject* ebo) { _ebo = ebo; }
inline void setElementsBufferObject(osg::ElementsBufferObject* ebo)
{
if (_ebo == ebo) return;
if (_ebo.valid())
{
_ebo->setDrawElements(_eboIndex,0);
}
_ebo = ebo;
if (_ebo.valid())
{
_eboIndex = _ebo->addDrawElements(this);
}
else
{
_eboIndex = 0;
}
}
/** Get the ElementsBufferObject. If no EBO is assigned returns NULL*/
inline osg::ElementsBufferObject* getElementsBufferObject() { return _ebo.get(); }
@@ -433,6 +451,14 @@ class DrawElements : public PrimitiveSet
protected:
virtual ~DrawElements()
{
if (_ebo.valid())
{
_ebo->setDrawElements(_eboIndex,0);
}
}
osg::ref_ptr<ElementsBufferObject> _ebo;
unsigned int _eboIndex;
};