Improved the readability and consistency with the rest of the OSG by inserting/removing spaces and line spacing.

This commit is contained in:
Robert Osfield 2017-07-28 13:30:36 +01:00
parent af25f14d73
commit 5a946e218f

View File

@ -21,13 +21,15 @@
namespace osg { namespace osg {
///common interface for IndirectCommandDrawArrayss ///common interface for IndirectCommandDrawArrayss
class OSG_EXPORT IndirectCommandDrawArrays: public BufferData class OSG_EXPORT IndirectCommandDrawArrays: public BufferData
{ {
public: public:
IndirectCommandDrawArrays():BufferData(){setBufferObject(new DrawIndirectBufferObject());} IndirectCommandDrawArrays() : BufferData() { setBufferObject(new DrawIndirectBufferObject()); }
IndirectCommandDrawArrays(const IndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
:BufferData(copy, copyop){ } IndirectCommandDrawArrays(const IndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/) :
BufferData(copy, copyop) {}
virtual unsigned int & count(const unsigned int&index)=0; virtual unsigned int & count(const unsigned int&index)=0;
virtual unsigned int & instanceCount(const unsigned int&index)=0; virtual unsigned int & instanceCount(const unsigned int&index)=0;
@ -37,12 +39,14 @@ public:
virtual unsigned int getElementSize() const = 0; virtual unsigned int getElementSize() const = 0;
virtual unsigned int getNumElements() const = 0; virtual unsigned int getNumElements() const = 0;
}; };
class OSG_EXPORT IndirectCommandDrawElements: public BufferData class OSG_EXPORT IndirectCommandDrawElements: public BufferData
{ {
public: public:
IndirectCommandDrawElements():BufferData(){setBufferObject(new DrawIndirectBufferObject());} IndirectCommandDrawElements() : BufferData() { setBufferObject(new DrawIndirectBufferObject()); }
IndirectCommandDrawElements(const IndirectCommandDrawElements& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/) IndirectCommandDrawElements(const IndirectCommandDrawElements& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
:BufferData(copy, copyop){} : BufferData(copy, copyop) {}
virtual unsigned int & count(const unsigned int&index)=0; virtual unsigned int & count(const unsigned int&index)=0;
virtual unsigned int & instanceCount(const unsigned int&index)=0; virtual unsigned int & instanceCount(const unsigned int&index)=0;
@ -52,15 +56,16 @@ public:
virtual unsigned int getElementSize()const = 0; virtual unsigned int getElementSize()const = 0;
virtual unsigned int getNumElements() const = 0; virtual unsigned int getNumElements() const = 0;
}; };
/// DrawArraysCommand /// DrawArraysCommand
struct DrawArraysIndirectCommand { struct DrawArraysIndirectCommand
DrawArraysIndirectCommand(unsigned int pcount = 0, unsigned int pinstanceCount = 0, unsigned int pfirst = 0, unsigned int pbaseInstance = 0) {
:count(pcount), instanceCount(pinstanceCount), first(pfirst), baseInstance(pbaseInstance){}; DrawArraysIndirectCommand(unsigned int pcount = 0, unsigned int pinstanceCount = 0, unsigned int pfirst = 0, unsigned int pbaseInstance = 0) :
count(pcount), instanceCount(pinstanceCount), first(pfirst), baseInstance(pbaseInstance) {}
unsigned int count; unsigned int count;
unsigned int instanceCount; unsigned int instanceCount;
unsigned int first; unsigned int first;
@ -74,30 +79,28 @@ class OSG_EXPORT DefaultIndirectCommandDrawArrays: public IndirectCommandDrawArr
public: public:
META_Object(osg,DefaultIndirectCommandDrawArrays) META_Object(osg,DefaultIndirectCommandDrawArrays)
DefaultIndirectCommandDrawArrays():IndirectCommandDrawArrays(), MixinVector<DrawArraysIndirectCommand>() {} DefaultIndirectCommandDrawArrays() : IndirectCommandDrawArrays(), MixinVector<DrawArraysIndirectCommand>() {}
DefaultIndirectCommandDrawArrays(const DefaultIndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/) DefaultIndirectCommandDrawArrays(const DefaultIndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/) :
:IndirectCommandDrawArrays(copy, copyop),MixinVector<DrawArraysIndirectCommand>() {} IndirectCommandDrawArrays(copy, copyop),MixinVector<DrawArraysIndirectCommand>() {}
virtual const GLvoid* getDataPointer() const { virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
return empty()?0:&front(); virtual unsigned int getTotalDataSize() const { return 16u*static_cast<unsigned int>(size()); }
} virtual unsigned int getElementSize()const { return 16u; };
virtual unsigned int getTotalDataSize() const { virtual unsigned int & count(const unsigned int&index) { return at(index).count; }
return 16u*static_cast<unsigned int>(size()); virtual unsigned int & instanceCount(const unsigned int&index) { return at(index).instanceCount; }
} virtual unsigned int & first(const unsigned int&index) { return at(index).first; }
virtual unsigned int getElementSize()const {return 16u;}; virtual unsigned int & baseInstance(const unsigned int&index) { return at(index).baseInstance; }
virtual unsigned int & count(const unsigned int&index){return at(index).count;} virtual unsigned int getNumElements() const { return static_cast<unsigned int>(size()); }
virtual unsigned int & instanceCount(const unsigned int&index){return at(index).instanceCount;}
virtual unsigned int & first(const unsigned int&index){return at(index).first;}
virtual unsigned int & baseInstance(const unsigned int&index){return at(index).baseInstance;}
virtual unsigned int getNumElements() const {return static_cast<unsigned int>(size());}
}; };
/// default implementation of IndirectCommandDrawElements /// default implementation of IndirectCommandDrawElements
/// DrawElementsCommand /// DrawElementsCommand
struct DrawElementsIndirectCommand{ struct DrawElementsIndirectCommand
DrawElementsIndirectCommand(unsigned int pcount = 0, unsigned int pinstanceCount = 0, unsigned int pfirstIndex = 0, unsigned int pbaseVertex = 0, unsigned int pbaseInstance = 0) {
:count(pcount), instanceCount(pinstanceCount), firstIndex(pfirstIndex), baseVertex(pbaseVertex), baseInstance(pbaseInstance){}; DrawElementsIndirectCommand(unsigned int pcount = 0, unsigned int pinstanceCount = 0, unsigned int pfirstIndex = 0, unsigned int pbaseVertex = 0, unsigned int pbaseInstance = 0) :
count(pcount), instanceCount(pinstanceCount), firstIndex(pfirstIndex), baseVertex(pbaseVertex), baseInstance(pbaseInstance) {}
unsigned int count; unsigned int count;
unsigned int instanceCount; unsigned int instanceCount;
unsigned int firstIndex; unsigned int firstIndex;
@ -110,23 +113,22 @@ class OSG_EXPORT DefaultIndirectCommandDrawElements: public IndirectCommandDrawE
{ {
public: public:
META_Object(osg,DefaultIndirectCommandDrawElements) META_Object(osg,DefaultIndirectCommandDrawElements)
DefaultIndirectCommandDrawElements():IndirectCommandDrawElements(), MixinVector<DrawElementsIndirectCommand>() {}
DefaultIndirectCommandDrawElements(const DefaultIndirectCommandDrawElements& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
:IndirectCommandDrawElements(copy, copyop), MixinVector<DrawElementsIndirectCommand>(){}
virtual const GLvoid* getDataPointer() const {
return empty()?0:&front();
}
virtual unsigned int getTotalDataSize() const {
return 20u*static_cast<unsigned int>(size());
}
virtual unsigned int getElementSize()const {return 20u;}; DefaultIndirectCommandDrawElements() : IndirectCommandDrawElements(), MixinVector<DrawElementsIndirectCommand>() {}
virtual unsigned int & count(const unsigned int&index){return at(index).count;}
virtual unsigned int & instanceCount(const unsigned int&index){return at(index).instanceCount;} DefaultIndirectCommandDrawElements(const DefaultIndirectCommandDrawElements& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/) :
virtual unsigned int & firstIndex(const unsigned int&index){return at(index).firstIndex;} IndirectCommandDrawElements(copy, copyop), MixinVector<DrawElementsIndirectCommand>() {}
virtual unsigned int & baseVertex(const unsigned int&index){return at(index).baseVertex;}
virtual unsigned int & baseInstance(const unsigned int&index){return at(index).baseInstance;} virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
virtual unsigned int getNumElements() const {return static_cast<unsigned int>(size());} virtual unsigned int getTotalDataSize() const { return 20u*static_cast<unsigned int>(size()); }
virtual unsigned int getElementSize()const { return 20u; };
virtual unsigned int & count(const unsigned int&index) { return at(index).count; }
virtual unsigned int & instanceCount(const unsigned int&index) { return at(index).instanceCount; }
virtual unsigned int & firstIndex(const unsigned int&index) { return at(index).firstIndex; }
virtual unsigned int & baseVertex(const unsigned int&index) { return at(index).baseVertex; }
virtual unsigned int & baseInstance(const unsigned int&index) { return at(index).baseInstance; }
virtual unsigned int getNumElements() const { return static_cast<unsigned int>(size()); }
}; };
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
@ -136,41 +138,40 @@ class OSG_EXPORT DrawElementsIndirect : public DrawElements
{ {
public: public:
DrawElementsIndirect(Type primType=PrimitiveType, GLenum mode = 0,unsigned int firstCommand = 0, GLsizei stride = 0): DrawElementsIndirect(Type primType=PrimitiveType, GLenum mode = 0,unsigned int firstCommand = 0, GLsizei stride = 0) :
DrawElements(primType,mode, 0),_firstCommand(firstCommand),_stride(stride){setIndirectCommandArray(new DefaultIndirectCommandDrawElements());} DrawElements(primType,mode, 0),_firstCommand(firstCommand),_stride(stride) { setIndirectCommandArray(new DefaultIndirectCommandDrawElements()); }
DrawElementsIndirect(const DrawElementsIndirect& rhs,const CopyOp& copyop=CopyOp::SHALLOW_COPY): DrawElementsIndirect(const DrawElementsIndirect& rhs,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
DrawElements(rhs,copyop),_firstCommand(rhs._firstCommand), _stride(rhs._stride) { DrawElements(rhs,copyop),_firstCommand(rhs._firstCommand), _stride(rhs._stride) { _indirectCommandArray=(DefaultIndirectCommandDrawElements*)copyop(rhs._indirectCommandArray.get()); }
_indirectCommandArray=(DefaultIndirectCommandDrawElements*)copyop(rhs._indirectCommandArray.get());
}
/// set command array of this indirect primitive set /// set command array of this indirect primitive set
inline void setIndirectCommandArray(IndirectCommandDrawElements*idc) { inline void setIndirectCommandArray(IndirectCommandDrawElements*idc)
{
_indirectCommandArray = idc; _indirectCommandArray = idc;
//ensure bo of idc is of the correct type //ensure bo of idc is of the correct type
if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject())) if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject()))
_indirectCommandArray->setBufferObject(new DrawIndirectBufferObject()); _indirectCommandArray->setBufferObject(new DrawIndirectBufferObject());
} }
/// get command array of this indirect primitive set /// get command array of this indirect primitive set
inline IndirectCommandDrawElements* getIndirectCommandArray() { return _indirectCommandArray; } inline IndirectCommandDrawElements* getIndirectCommandArray() { return _indirectCommandArray; }
inline const IndirectCommandDrawElements* getIndirectCommandArray() const { return _indirectCommandArray; } inline const IndirectCommandDrawElements* getIndirectCommandArray() const { return _indirectCommandArray; }
///Further methods are for advanced DI when you plan to use your own IndirectCommandElement (stride) ///Further methods are for advanced DI when you plan to use your own IndirectCommandElement (stride)
///or if you want to draw a particular command index of the IndirectCommandElement(FirstCommandToDraw) ///or if you want to draw a particular command index of the IndirectCommandElement(FirstCommandToDraw)
/// set offset of the first command to draw in the IndirectCommandDrawArrays /// set offset of the first command to draw in the IndirectCommandDrawArrays
inline void setFirstCommandToDraw( unsigned int i) { _firstCommand = i; } inline void setFirstCommandToDraw( unsigned int i) { _firstCommand = i; }
/// get offset of the first command in the IndirectCommandDrawArrays /// get offset of the first command in the IndirectCommandDrawArrays
inline unsigned int getFirstCommandToDraw() const { return _firstCommand; } inline unsigned int getFirstCommandToDraw() const { return _firstCommand; }
/// stride (to set if you use custom CommandArray) /// stride (to set if you use custom CommandArray)
inline void setStride( GLsizei i) { inline void setStride( GLsizei i) { _stride=i; }
_stride=i;
}
/// stride (to set if you use custom CommandArray) /// stride (to set if you use custom CommandArray)
inline GLsizei getStride() const { inline GLsizei getStride() const { return _stride; }
return _stride;
}
virtual unsigned int getNumPrimitives() const=0; virtual unsigned int getNumPrimitives() const=0;
protected: protected:
@ -179,8 +180,8 @@ protected:
unsigned int _firstCommand; unsigned int _firstCommand;
GLsizei _stride; GLsizei _stride;
ref_ptr<IndirectCommandDrawElements> _indirectCommandArray; ref_ptr<IndirectCommandDrawElements> _indirectCommandArray;
}; };
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
/// \brief The DrawElementsIndirectUByte PrimitiveSet /// \brief The DrawElementsIndirectUByte PrimitiveSet
/// ///
@ -190,10 +191,10 @@ public:
typedef VectorGLubyte vector_type; typedef VectorGLubyte vector_type;
DrawElementsIndirectUByte(GLenum mode = 0,unsigned int firstCommand = 0, GLsizei stride = 0): DrawElementsIndirectUByte(GLenum mode = 0,unsigned int firstCommand = 0, GLsizei stride = 0) :
DrawElementsIndirect(DrawElementsUByteIndirectPrimitiveType,mode,firstCommand,stride) {} DrawElementsIndirect(DrawElementsUByteIndirectPrimitiveType,mode,firstCommand,stride) {}
DrawElementsIndirectUByte(const DrawElementsIndirectUByte& array, const CopyOp& copyop=CopyOp::SHALLOW_COPY): DrawElementsIndirectUByte(const DrawElementsIndirectUByte& array, const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
DrawElementsIndirect(array,copyop), DrawElementsIndirect(array,copyop),
vector_type(array) {} vector_type(array) {}
@ -214,64 +215,36 @@ public:
DrawElementsIndirect(MultiDrawElementsUByteIndirectPrimitiveType,mode), DrawElementsIndirect(MultiDrawElementsUByteIndirectPrimitiveType,mode),
vector_type(no) {} vector_type(no) {}
virtual Object* cloneType() const { virtual Object* cloneType() const { return new DrawElementsIndirectUByte(); }
return new DrawElementsIndirectUByte(); virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsIndirectUByte(*this,copyop); }
} virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsIndirectUByte*>(obj)!=NULL; }
virtual Object* clone(const CopyOp& copyop) const { virtual const char* libraryName() const { return "osg"; }
return new DrawElementsIndirectUByte(*this,copyop); virtual const char* className() const { return "DrawElementsIndirectUByte"; }
}
virtual bool isSameKindAs(const Object* obj) const {
return dynamic_cast<const DrawElementsIndirectUByte*>(obj)!=NULL;
}
virtual const char* libraryName() const {
return "osg";
}
virtual const char* className() const {
return "DrawElementsIndirectUByte";
}
virtual const GLvoid* getDataPointer() const { virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
return empty()?0:&front(); virtual unsigned int getTotalDataSize() const { return static_cast<unsigned int>(size()); }
} virtual bool supportsBufferObject() const { return false; }
virtual unsigned int getTotalDataSize() const {
return static_cast<unsigned int>(size());
}
virtual bool supportsBufferObject() const {
return false;
}
virtual void draw(State& state, bool useVertexBufferObjects) const; virtual void draw(State& state, bool useVertexBufferObjects) const;
virtual void accept(PrimitiveFunctor& functor) const; virtual void accept(PrimitiveFunctor& functor) const;
virtual void accept(PrimitiveIndexFunctor& functor) const; virtual void accept(PrimitiveIndexFunctor& functor) const;
virtual unsigned int getNumIndices() const { virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
return static_cast<unsigned int>(size()); virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
}
virtual unsigned int index(unsigned int pos) const {
return (*this)[pos];
}
virtual void offsetIndices(int offset); virtual void offsetIndices(int offset);
virtual GLenum getDataType() { virtual GLenum getDataType() { return GL_UNSIGNED_BYTE; }
return GL_UNSIGNED_BYTE;
} virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
virtual void resizeElements(unsigned int numIndices) { virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
resize(numIndices);
} virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
virtual void reserveElements(unsigned int numIndices) { virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
reserve(numIndices);
} virtual void addElement(unsigned int v) { push_back(GLubyte(v)); }
virtual void setElement(unsigned int i, unsigned int v) {
(*this)[i] = v;
}
virtual unsigned int getElement(unsigned int i) {
return (*this)[i];
}
virtual void addElement(unsigned int v) {
push_back(GLubyte(v));
}
virtual unsigned int getNumPrimitives() const; virtual unsigned int getNumPrimitives() const;
protected: protected:
virtual ~DrawElementsIndirectUByte(); virtual ~DrawElementsIndirectUByte();
@ -287,10 +260,10 @@ public:
typedef VectorGLushort vector_type; typedef VectorGLushort vector_type;
DrawElementsIndirectUShort(GLenum mode = 0,unsigned int firstCommand = 0, GLsizei stride = 0): DrawElementsIndirectUShort(GLenum mode = 0,unsigned int firstCommand = 0, GLsizei stride = 0) :
DrawElementsIndirect(DrawElementsUShortIndirectPrimitiveType,mode,firstCommand,stride) {} DrawElementsIndirect(DrawElementsUShortIndirectPrimitiveType,mode,firstCommand,stride) {}
DrawElementsIndirectUShort(const DrawElementsIndirectUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY): DrawElementsIndirectUShort(const DrawElementsIndirectUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
DrawElementsIndirect(array,copyop), DrawElementsIndirect(array,copyop),
vector_type(array) {} vector_type(array) {}
@ -316,64 +289,35 @@ public:
DrawElementsIndirect(MultiDrawElementsUShortIndirectPrimitiveType,mode), DrawElementsIndirect(MultiDrawElementsUShortIndirectPrimitiveType,mode),
vector_type(first,last) {} vector_type(first,last) {}
virtual Object* cloneType() const { virtual Object* cloneType() const { return new DrawElementsIndirectUShort(); }
return new DrawElementsIndirectUShort(); virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsIndirectUShort(*this,copyop); }
} virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsIndirectUShort*>(obj)!=NULL; }
virtual Object* clone(const CopyOp& copyop) const { virtual const char* libraryName() const { return "osg"; }
return new DrawElementsIndirectUShort(*this,copyop); virtual const char* className() const { return "DrawElementsIndirectUShort"; }
}
virtual bool isSameKindAs(const Object* obj) const {
return dynamic_cast<const DrawElementsIndirectUShort*>(obj)!=NULL;
}
virtual const char* libraryName() const {
return "osg";
}
virtual const char* className() const {
return "DrawElementsIndirectUShort";
}
virtual const GLvoid* getDataPointer() const { virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
return empty()?0:&front(); virtual unsigned int getTotalDataSize() const { return 2u*static_cast<unsigned int>(size()); }
} virtual bool supportsBufferObject() const { return false; }
virtual unsigned int getTotalDataSize() const {
return 2u*static_cast<unsigned int>(size());
}
virtual bool supportsBufferObject() const {
return false;
}
virtual void draw(State& state, bool useVertexBufferObjects) const; virtual void draw(State& state, bool useVertexBufferObjects) const;
virtual void accept(PrimitiveFunctor& functor) const; virtual void accept(PrimitiveFunctor& functor) const;
virtual void accept(PrimitiveIndexFunctor& functor) const; virtual void accept(PrimitiveIndexFunctor& functor) const;
virtual unsigned int getNumIndices() const { virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
return static_cast<unsigned int>(size()); virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
}
virtual unsigned int index(unsigned int pos) const {
return (*this)[pos];
}
virtual void offsetIndices(int offset); virtual void offsetIndices(int offset);
virtual GLenum getDataType() { virtual GLenum getDataType() { return GL_UNSIGNED_SHORT; }
return GL_UNSIGNED_SHORT; virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
} virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
virtual void resizeElements(unsigned int numIndices) {
resize(numIndices); virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
} virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
virtual void reserveElements(unsigned int numIndices) {
reserve(numIndices); virtual void addElement(unsigned int v) { push_back(GLushort(v)); }
}
virtual void setElement(unsigned int i, unsigned int v) {
(*this)[i] = v;
}
virtual unsigned int getElement(unsigned int i) {
return (*this)[i];
}
virtual void addElement(unsigned int v) {
push_back(GLushort(v));
}
virtual unsigned int getNumPrimitives() const; virtual unsigned int getNumPrimitives() const;
protected: protected:
virtual ~DrawElementsIndirectUShort(); virtual ~DrawElementsIndirectUShort();
@ -388,10 +332,10 @@ public:
typedef VectorGLuint vector_type; typedef VectorGLuint vector_type;
DrawElementsIndirectUInt(GLenum mode = 0,unsigned int firstCommand = 0, GLsizei stride = 0): DrawElementsIndirectUInt(GLenum mode = 0,unsigned int firstCommand = 0, GLsizei stride = 0) :
DrawElementsIndirect(DrawElementsUIntIndirectPrimitiveType,mode,firstCommand,stride) {} DrawElementsIndirect(DrawElementsUIntIndirectPrimitiveType,mode,firstCommand,stride) {}
DrawElementsIndirectUInt(const DrawElementsIndirectUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY): DrawElementsIndirectUInt(const DrawElementsIndirectUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
DrawElementsIndirect(array,copyop), DrawElementsIndirect(array,copyop),
vector_type(array) {} vector_type(array) {}
@ -417,91 +361,56 @@ public:
DrawElementsIndirect(MultiDrawElementsUIntIndirectPrimitiveType,mode), DrawElementsIndirect(MultiDrawElementsUIntIndirectPrimitiveType,mode),
vector_type(first,last) {} vector_type(first,last) {}
virtual Object* cloneType() const { virtual Object* cloneType() const { return new DrawElementsIndirectUInt(); }
return new DrawElementsIndirectUInt(); virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsIndirectUInt(*this,copyop); }
} virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsIndirectUInt*>(obj)!=NULL; }
virtual Object* clone(const CopyOp& copyop) const { virtual const char* libraryName() const { return "osg"; }
return new DrawElementsIndirectUInt(*this,copyop); virtual const char* className() const { return "DrawElementsIndirectUInt"; }
}
virtual bool isSameKindAs(const Object* obj) const {
return dynamic_cast<const DrawElementsIndirectUInt*>(obj)!=NULL;
}
virtual const char* libraryName() const {
return "osg";
}
virtual const char* className() const {
return "DrawElementsIndirectUInt";
}
virtual const GLvoid* getDataPointer() const { virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
return empty()?0:&front(); virtual unsigned int getTotalDataSize() const { return 4u*static_cast<unsigned int>(size()); }
} virtual bool supportsBufferObject() const { return false; }
virtual unsigned int getTotalDataSize() const {
return 4u*static_cast<unsigned int>(size());
}
virtual bool supportsBufferObject() const {
return false;
}
virtual void draw(State& state, bool useVertexBufferObjects) const; virtual void draw(State& state, bool useVertexBufferObjects) const;
virtual void accept(PrimitiveFunctor& functor) const; virtual void accept(PrimitiveFunctor& functor) const;
virtual void accept(PrimitiveIndexFunctor& functor) const; virtual void accept(PrimitiveIndexFunctor& functor) const;
virtual unsigned int getNumIndices() const { virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
return static_cast<unsigned int>(size()); virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
}
virtual unsigned int index(unsigned int pos) const {
return (*this)[pos];
}
virtual void offsetIndices(int offset); virtual void offsetIndices(int offset);
virtual GLenum getDataType() { virtual GLenum getDataType() { return GL_UNSIGNED_INT; }
return GL_UNSIGNED_INT; virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
} virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
virtual void resizeElements(unsigned int numIndices) { virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
resize(numIndices); virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
} virtual void addElement(unsigned int v) { push_back(GLuint(v)); }
virtual void reserveElements(unsigned int numIndices) {
reserve(numIndices);
}
virtual void setElement(unsigned int i, unsigned int v) {
(*this)[i] = v;
}
virtual unsigned int getElement(unsigned int i) {
return (*this)[i];
}
virtual void addElement(unsigned int v) {
push_back(GLuint(v));
}
virtual unsigned int getNumPrimitives() const; virtual unsigned int getNumPrimitives() const;
protected: protected:
virtual ~DrawElementsIndirectUInt(); virtual ~DrawElementsIndirectUInt();
}; };
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
/// \brief The MultiDrawElementsIndirect PrimitiveSets /// \brief The MultiDrawElementsIndirect PrimitiveSets
/// ///
class OSG_EXPORT MultiDrawElementsIndirectUShort : public DrawElementsIndirectUShort class OSG_EXPORT MultiDrawElementsIndirectUShort : public DrawElementsIndirectUShort
{ {
public: public:
MultiDrawElementsIndirectUShort(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0): MultiDrawElementsIndirectUShort(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0) :
DrawElementsIndirectUShort(mode,firstCommand,stride),_count(commandcount){_primitiveType=(Type(MultiDrawElementsUShortIndirectPrimitiveType));} DrawElementsIndirectUShort(mode,firstCommand,stride),_count(commandcount) { _primitiveType=(Type(MultiDrawElementsUShortIndirectPrimitiveType)); }
MultiDrawElementsIndirectUShort(const MultiDrawElementsIndirectUShort& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
MultiDrawElementsIndirectUShort(const MultiDrawElementsIndirectUShort& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
DrawElementsIndirectUShort(mdi,copyop),_count(mdi._count) {} DrawElementsIndirectUShort(mdi,copyop),_count(mdi._count) {}
virtual osg::Object* cloneType() const {
return new MultiDrawElementsIndirectUShort(); virtual osg::Object* cloneType() const { return new MultiDrawElementsIndirectUShort(); }
} virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new MultiDrawElementsIndirectUShort(*this,copyop); }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const MultiDrawElementsIndirectUShort*>(obj)!=NULL; }
return new MultiDrawElementsIndirectUShort(*this,copyop); virtual const char* className() const { return "MultiDrawElementsIndirectUShort"; }
}
virtual bool isSameKindAs(const osg::Object* obj) const {
return dynamic_cast<const MultiDrawElementsIndirectUShort*>(obj)!=NULL;
}
virtual const char* className() const {
return "MultiDrawElementsIndirectUShort";
}
virtual void draw(State& state, bool useVertexBufferObjects) const; virtual void draw(State& state, bool useVertexBufferObjects) const;
virtual void accept(PrimitiveFunctor& functor) const; virtual void accept(PrimitiveFunctor& functor) const;
virtual void accept(PrimitiveIndexFunctor& functor) const; virtual void accept(PrimitiveIndexFunctor& functor) const;
@ -510,13 +419,10 @@ public:
///if you want to draw a subset of the IndirectCommandElement(FirstCommandToDraw,NumCommandsToDraw) ///if you want to draw a subset of the IndirectCommandElement(FirstCommandToDraw,NumCommandsToDraw)
/// count of Indirect Command to execute /// count of Indirect Command to execute
inline void setNumCommandsToDraw( unsigned int i) { inline void setNumCommandsToDraw( unsigned int i) { _count=i; }
_count=i;
}
/// count of Indirect Command to execute /// count of Indirect Command to execute
inline unsigned int getNumCommandsToDraw()const { inline unsigned int getNumCommandsToDraw()const { return _count; }
return _count;
}
protected: protected:
unsigned int _count; unsigned int _count;
virtual ~MultiDrawElementsIndirectUShort(); virtual ~MultiDrawElementsIndirectUShort();
@ -525,73 +431,61 @@ protected:
class OSG_EXPORT MultiDrawElementsIndirectUByte : public DrawElementsIndirectUByte class OSG_EXPORT MultiDrawElementsIndirectUByte : public DrawElementsIndirectUByte
{ {
public: public:
MultiDrawElementsIndirectUByte(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0): MultiDrawElementsIndirectUByte(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0) :
DrawElementsIndirectUByte(mode,firstCommand,stride),_count(commandcount){_primitiveType=(Type(MultiDrawElementsUByteIndirectPrimitiveType));} DrawElementsIndirectUByte(mode,firstCommand,stride),_count(commandcount) { _primitiveType=(Type(MultiDrawElementsUByteIndirectPrimitiveType)); }
MultiDrawElementsIndirectUByte(const MultiDrawElementsIndirectUByte& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
MultiDrawElementsIndirectUByte(const MultiDrawElementsIndirectUByte& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
DrawElementsIndirectUByte(mdi,copyop),_count(mdi._count) {} DrawElementsIndirectUByte(mdi,copyop),_count(mdi._count) {}
virtual osg::Object* cloneType() const {
return new MultiDrawElementsIndirectUByte(); virtual osg::Object* cloneType() const { return new MultiDrawElementsIndirectUByte(); }
} virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new MultiDrawElementsIndirectUByte(*this,copyop); }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const MultiDrawElementsIndirectUByte*>(obj)!=NULL; }
return new MultiDrawElementsIndirectUByte(*this,copyop); virtual const char* className() const { return "MultiDrawElementsIndirectUByte"; }
}
virtual bool isSameKindAs(const osg::Object* obj) const {
return dynamic_cast<const MultiDrawElementsIndirectUByte*>(obj)!=NULL;
}
virtual const char* className() const {
return "MultiDrawElementsIndirectUByte";
}
virtual void draw(State& state, bool useVertexBufferObjects) const; virtual void draw(State& state, bool useVertexBufferObjects) const;
virtual void accept(PrimitiveFunctor& functor) const; virtual void accept(PrimitiveFunctor& functor) const;
virtual void accept(PrimitiveIndexFunctor& functor) const; virtual void accept(PrimitiveIndexFunctor& functor) const;
virtual unsigned int getNumPrimitives() const; virtual unsigned int getNumPrimitives() const;
/// count of Indirect Command to execute /// count of Indirect Command to execute
inline void setNumCommandsToDraw( unsigned int i) { inline void setNumCommandsToDraw( unsigned int i) { _count=i; }
_count=i;
}
/// count of Indirect Command to execute /// count of Indirect Command to execute
inline unsigned int getNumCommandsToDraw()const { inline unsigned int getNumCommandsToDraw()const { return _count; }
return _count;
}
protected: protected:
unsigned int _count; unsigned int _count;
virtual ~MultiDrawElementsIndirectUByte(); virtual ~MultiDrawElementsIndirectUByte();
}; };
class OSG_EXPORT MultiDrawElementsIndirectUInt : public DrawElementsIndirectUInt class OSG_EXPORT MultiDrawElementsIndirectUInt : public DrawElementsIndirectUInt
{ {
public: public:
MultiDrawElementsIndirectUInt(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0): MultiDrawElementsIndirectUInt(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0) :
DrawElementsIndirectUInt(mode,firstCommand,stride),_count(commandcount){_primitiveType=(Type(MultiDrawElementsUIntIndirectPrimitiveType));} DrawElementsIndirectUInt(mode,firstCommand,stride),_count(commandcount) { _primitiveType=(Type(MultiDrawElementsUIntIndirectPrimitiveType)); }
MultiDrawElementsIndirectUInt(const MultiDrawElementsIndirectUInt& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
MultiDrawElementsIndirectUInt(const MultiDrawElementsIndirectUInt& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
DrawElementsIndirectUInt(mdi,copyop),_count(mdi._count) {} DrawElementsIndirectUInt(mdi,copyop),_count(mdi._count) {}
virtual osg::Object* cloneType() const {
return new MultiDrawElementsIndirectUInt(); virtual osg::Object* cloneType() const { return new MultiDrawElementsIndirectUInt(); }
} virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new MultiDrawElementsIndirectUInt(*this,copyop); }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const MultiDrawElementsIndirectUInt*>(obj)!=NULL; }
return new MultiDrawElementsIndirectUInt(*this,copyop); virtual const char* className() const { return "MultiDrawElementsIndirectUInt"; }
}
virtual bool isSameKindAs(const osg::Object* obj) const {
return dynamic_cast<const MultiDrawElementsIndirectUInt*>(obj)!=NULL;
}
virtual const char* className() const {
return "MultiDrawElementsIndirectUInt";
}
virtual void draw(State& state, bool useVertexBufferObjects) const; virtual void draw(State& state, bool useVertexBufferObjects) const;
virtual void accept(PrimitiveFunctor& functor) const; virtual void accept(PrimitiveFunctor& functor) const;
virtual void accept(PrimitiveIndexFunctor& functor) const; virtual void accept(PrimitiveIndexFunctor& functor) const;
virtual unsigned int getNumPrimitives() const; virtual unsigned int getNumPrimitives() const;
/// count of Indirect Command to execute /// count of Indirect Command to execute
inline void setNumCommandsToDraw( unsigned int i) { inline void setNumCommandsToDraw( unsigned int i) { _count=i; }
_count=i;
}
/// count of Indirect Command to execute /// count of Indirect Command to execute
inline unsigned int getNumCommandsToDraw()const { inline unsigned int getNumCommandsToDraw()const { return _count; }
return _count;
}
protected: protected:
unsigned int _count; unsigned int _count;
virtual ~MultiDrawElementsIndirectUInt(); virtual ~MultiDrawElementsIndirectUInt();
}; };
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
/// \brief The MultiDrawArraysIndirect PrimitiveSet /// \brief The MultiDrawArraysIndirect PrimitiveSet
/// ///
@ -599,32 +493,21 @@ class OSG_EXPORT DrawArraysIndirect : public osg::PrimitiveSet
{ {
public: public:
DrawArraysIndirect(GLenum mode=0, unsigned int firstcommand = 0, GLsizei stride = 0): DrawArraysIndirect(GLenum mode=0, unsigned int firstcommand = 0, GLsizei stride = 0) :
osg::PrimitiveSet(Type(DrawArraysIndirectPrimitiveType), mode), osg::PrimitiveSet(Type(DrawArraysIndirectPrimitiveType), mode),
_firstCommand(firstcommand), _stride(stride) {setIndirectCommandArray(new DefaultIndirectCommandDrawArrays);} _firstCommand(firstcommand), _stride(stride) { setIndirectCommandArray(new DefaultIndirectCommandDrawArrays); }
DrawArraysIndirect(const DrawArraysIndirect& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY): DrawArraysIndirect(const DrawArraysIndirect& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
osg::PrimitiveSet(dal,copyop), osg::PrimitiveSet(dal,copyop),
_firstCommand(dal._firstCommand), _firstCommand(dal._firstCommand),
_stride(dal._stride), _stride(dal._stride),
_indirectCommandArray((DefaultIndirectCommandDrawArrays*)copyop( dal._indirectCommandArray.get())) _indirectCommandArray((DefaultIndirectCommandDrawArrays*)copyop( dal._indirectCommandArray.get())) {}
{}
virtual osg::Object* cloneType() const { virtual osg::Object* cloneType() const { return new DrawArraysIndirect(); }
return new DrawArraysIndirect(); virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new DrawArraysIndirect(*this,copyop); }
} virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const DrawArraysIndirect*>(obj)!=NULL; }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { virtual const char* libraryName() const { return "osg"; }
return new DrawArraysIndirect(*this,copyop); virtual const char* className() const { return "DrawArraysIndirect"; }
}
virtual bool isSameKindAs(const osg::Object* obj) const {
return dynamic_cast<const DrawArraysIndirect*>(obj)!=NULL;
}
virtual const char* libraryName() const {
return "osg";
}
virtual const char* className() const {
return "DrawArraysIndirect";
}
virtual void draw(State& state, bool useVertexBufferObjects) const; virtual void draw(State& state, bool useVertexBufferObjects) const;
@ -638,34 +521,26 @@ public:
virtual unsigned int getNumPrimitives() const; virtual unsigned int getNumPrimitives() const;
/// stride (to set if you use custom CommandArray) /// stride (to set if you use custom CommandArray)
inline void setStride( GLsizei i) { inline void setStride( GLsizei i) { _stride=i; }
_stride=i;
}
/// stride (to set if you use custom CommandArray)
inline GLsizei getStride()const {
return _stride;
}
/// set offset of the first command in the IndirectCommandDrawArrays
inline void setFirstCommandToDraw( unsigned int i) {
_firstCommand=i;
}
/// get offset of the first command in the IndirectCommandDrawArrays
inline unsigned int getFirstCommandToDraw() const {
return _firstCommand;
}
inline void setIndirectCommandArray(IndirectCommandDrawArrays*idc) { /// stride (to set if you use custom CommandArray)
inline GLsizei getStride()const { return _stride; }
/// set offset of the first command in the IndirectCommandDrawArrays
inline void setFirstCommandToDraw( unsigned int i) { _firstCommand=i; }
/// get offset of the first command in the IndirectCommandDrawArrays
inline unsigned int getFirstCommandToDraw() const { return _firstCommand; }
inline void setIndirectCommandArray(IndirectCommandDrawArrays*idc)
{
_indirectCommandArray = idc; _indirectCommandArray = idc;
//ensure bo of idc is of the correct type //ensure bo of idc is of the correct type
if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject())) if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject()))
_indirectCommandArray->setBufferObject(new DrawIndirectBufferObject()); _indirectCommandArray->setBufferObject(new DrawIndirectBufferObject());
} }
inline const IndirectCommandDrawArrays* getIndirectCommandArray() const { inline const IndirectCommandDrawArrays* getIndirectCommandArray() const { return _indirectCommandArray; }
return _indirectCommandArray; inline IndirectCommandDrawArrays* getIndirectCommandArray() { return _indirectCommandArray; }
}
inline IndirectCommandDrawArrays* getIndirectCommandArray(){
return _indirectCommandArray;
}
protected: protected:
@ -682,27 +557,16 @@ class OSG_EXPORT MultiDrawArraysIndirect : public DrawArraysIndirect
{ {
public: public:
MultiDrawArraysIndirect(GLenum mode=0, unsigned int firstcommand = 0, unsigned int count = 0, GLsizei stride = 0): MultiDrawArraysIndirect(GLenum mode=0, unsigned int firstcommand = 0, unsigned int count = 0, GLsizei stride = 0) :
osg::DrawArraysIndirect(mode, firstcommand, stride), _count(count) osg::DrawArraysIndirect(mode, firstcommand, stride), _count(count) { _primitiveType=Type(MultiDrawArraysIndirectPrimitiveType); }
{_primitiveType=Type(MultiDrawArraysIndirectPrimitiveType);}
MultiDrawArraysIndirect(const MultiDrawArraysIndirect& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY): MultiDrawArraysIndirect(const MultiDrawArraysIndirect& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
osg::DrawArraysIndirect(dal,copyop), _count(dal._count) osg::DrawArraysIndirect(dal,copyop), _count(dal._count) {}
{}
virtual osg::Object* cloneType() const { virtual osg::Object* cloneType() const { return new MultiDrawArraysIndirect(); }
return new MultiDrawArraysIndirect(); virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new MultiDrawArraysIndirect(*this,copyop); }
} virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const MultiDrawArraysIndirect*>(obj)!=NULL; }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { virtual const char* className() const { return "MultiDrawArraysIndirect"; }
return new MultiDrawArraysIndirect(*this,copyop);
}
virtual bool isSameKindAs(const osg::Object* obj) const {
return dynamic_cast<const MultiDrawArraysIndirect*>(obj)!=NULL;
}
virtual const char* className() const {
return "MultiDrawArraysIndirect";
}
virtual void draw(State& state, bool useVertexBufferObjects) const; virtual void draw(State& state, bool useVertexBufferObjects) const;
@ -716,13 +580,10 @@ public:
virtual unsigned int getNumPrimitives() const; virtual unsigned int getNumPrimitives() const;
/// count of Indirect Command to execute /// count of Indirect Command to execute
inline void setNumCommandsToDraw( unsigned int i) { inline void setNumCommandsToDraw( unsigned int i) { _count=i; }
_count=i;
}
/// count of Indirect Command to execute /// count of Indirect Command to execute
inline unsigned int getNumCommandsToDraw()const { inline unsigned int getNumCommandsToDraw()const { return _count; }
return _count;
}
protected: protected:
unsigned int _count; unsigned int _count;
@ -731,4 +592,3 @@ protected:
} }
#endif #endif