Introduced new BufferObject design + implementation in preperation of implementing a pool system for buffer objects
This commit is contained in:
@@ -43,7 +43,7 @@ class ConstArrayVisitor;
|
||||
class ValueVisitor;
|
||||
class ConstValueVisitor;
|
||||
|
||||
class OSG_EXPORT Array : public Object
|
||||
class OSG_EXPORT Array : public BufferData
|
||||
{
|
||||
|
||||
public:
|
||||
@@ -77,17 +77,13 @@ class OSG_EXPORT Array : public Object
|
||||
Array(Type arrayType=ArrayType,GLint dataSize=0,GLenum dataType=0):
|
||||
_arrayType(arrayType),
|
||||
_dataSize(dataSize),
|
||||
_dataType(dataType),
|
||||
_modifiedCount(0),
|
||||
_vboOffset(0) {}
|
||||
_dataType(dataType) {}
|
||||
|
||||
Array(const Array& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Object(array,copyop),
|
||||
BufferData(array,copyop),
|
||||
_arrayType(array._arrayType),
|
||||
_dataSize(array._dataSize),
|
||||
_dataType(array._dataType),
|
||||
_modifiedCount(0),
|
||||
_vboOffset(0) {}
|
||||
_dataType(array._dataType) {}
|
||||
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Array*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
@@ -113,61 +109,22 @@ class OSG_EXPORT Array : public Object
|
||||
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
|
||||
virtual void trim() {}
|
||||
|
||||
/** Dirty the primitive, which increments the modified count, to force buffer objects to update. */
|
||||
inline void dirty() { ++_modifiedCount; if (_vbo.valid()) _vbo->dirty(); }
|
||||
|
||||
/** Set the modified count value.*/
|
||||
inline void setModifiedCount(unsigned int value) { _modifiedCount=value; }
|
||||
|
||||
/** Get modified count value.*/
|
||||
inline unsigned int getModifiedCount() const { return _modifiedCount; }
|
||||
|
||||
/** Set the VertexBufferObject.*/
|
||||
inline void setVertexBufferObject(osg::VertexBufferObject* vbo)
|
||||
{
|
||||
if (_vbo == vbo) return;
|
||||
|
||||
if (_vbo.valid())
|
||||
{
|
||||
_vbo->removeArray(this);
|
||||
}
|
||||
|
||||
_vbo = vbo;
|
||||
|
||||
if (_vbo.valid())
|
||||
{
|
||||
_vbo->addArray(this);
|
||||
}
|
||||
}
|
||||
|
||||
inline void setVertexBufferObject(osg::VertexBufferObject* vbo) { setBufferObject(vbo); }
|
||||
|
||||
/** Get the VertexBufferObject. If no VBO is assigned returns NULL*/
|
||||
inline osg::VertexBufferObject* getVertexBufferObject() { return _vbo.get(); }
|
||||
inline osg::VertexBufferObject* getVertexBufferObject() { return dynamic_cast<osg::VertexBufferObject*>(_bufferObject.get()); }
|
||||
|
||||
/** Get the const VertexBufferObject. If no VBO is assigned returns NULL*/
|
||||
inline const osg::VertexBufferObject* getVertexBufferObject() const { return _vbo.get(); }
|
||||
|
||||
/** Set the offset into the VertexBufferObject, if used.*/
|
||||
void setVertexBufferObjectOffset(const GLvoid* offset ) const { _vboOffset = offset; }
|
||||
|
||||
/** Get the offset into the VertexBufferObject, if used.*/
|
||||
const GLvoid* getVertexBufferObjectOffset() const { return _vboOffset; }
|
||||
inline const osg::VertexBufferObject* getVertexBufferObject() const { return dynamic_cast<const osg::VertexBufferObject*>(_bufferObject.get()); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~Array()
|
||||
{
|
||||
if (_vbo.valid())
|
||||
{
|
||||
_vbo->removeArray(this);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~Array() {}
|
||||
|
||||
Type _arrayType;
|
||||
GLint _dataSize;
|
||||
GLenum _dataType;
|
||||
unsigned int _modifiedCount;
|
||||
osg::ref_ptr<osg::VertexBufferObject> _vbo;
|
||||
mutable const GLvoid* _vboOffset;
|
||||
};
|
||||
|
||||
template<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>
|
||||
|
||||
Reference in New Issue
Block a user