Further work VertexBufferObject and ElementsBufferObject classes
This commit is contained in:
@@ -117,7 +117,26 @@ class OSG_EXPORT Array : public Object
|
||||
inline unsigned int getModifiedCount() const { return _modifiedCount; }
|
||||
|
||||
/** Set the VertexBufferObject.*/
|
||||
inline void setVertexBufferObject(osg::VertexBufferObject* vbo) { _vbo = vbo; }
|
||||
inline void setVertexBufferObject(osg::VertexBufferObject* vbo)
|
||||
{
|
||||
if (_vbo == vbo) return;
|
||||
|
||||
if (_vbo.valid())
|
||||
{
|
||||
_vbo->setArray(_vboIndex,0);
|
||||
}
|
||||
|
||||
_vbo = vbo;
|
||||
|
||||
if (_vbo.valid())
|
||||
{
|
||||
_vboIndex = _vbo->addArray(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
_vboIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the VertexBufferObject. If no VBO is assigned returns NULL*/
|
||||
inline osg::VertexBufferObject* getVertexBufferObject() { return _vbo.get(); }
|
||||
@@ -133,7 +152,13 @@ class OSG_EXPORT Array : public Object
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~Array() {}
|
||||
virtual ~Array()
|
||||
{
|
||||
if (_vbo.valid())
|
||||
{
|
||||
_vbo->setArray(_vboIndex,0);
|
||||
}
|
||||
}
|
||||
|
||||
Type _arrayType;
|
||||
GLint _dataSize;
|
||||
|
||||
@@ -101,8 +101,8 @@ class OSG_EXPORT BufferObject : public Object
|
||||
BufferEntry& operator = (const BufferEntry& be) { modifiedCount=be.modifiedCount; dataSize=be.dataSize; offset=be.offset; return *this; }
|
||||
|
||||
mutable buffered_value<unsigned int> modifiedCount;
|
||||
unsigned int dataSize;
|
||||
unsigned int offset;
|
||||
mutable unsigned int dataSize;
|
||||
mutable unsigned int offset;
|
||||
};
|
||||
|
||||
inline bool isBufferObjectSupported(unsigned int contextID) const { return getExtensions(contextID,true)->isBufferObjectSupported(); }
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user