Improved the readability and consistency with the rest of the OSG by inserting/removing spaces and line spacing.
This commit is contained in:
parent
af25f14d73
commit
5a946e218f
@ -21,13 +21,15 @@
|
||||
|
||||
|
||||
namespace osg {
|
||||
|
||||
///common interface for IndirectCommandDrawArrayss
|
||||
class OSG_EXPORT IndirectCommandDrawArrays: public BufferData
|
||||
{
|
||||
public:
|
||||
IndirectCommandDrawArrays():BufferData(){setBufferObject(new DrawIndirectBufferObject());}
|
||||
IndirectCommandDrawArrays(const IndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
|
||||
:BufferData(copy, copyop){ }
|
||||
IndirectCommandDrawArrays() : BufferData() { setBufferObject(new DrawIndirectBufferObject()); }
|
||||
|
||||
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 & instanceCount(const unsigned int&index)=0;
|
||||
@ -37,12 +39,14 @@ public:
|
||||
virtual unsigned int getElementSize() const = 0;
|
||||
virtual unsigned int getNumElements() const = 0;
|
||||
};
|
||||
|
||||
class OSG_EXPORT IndirectCommandDrawElements: public BufferData
|
||||
{
|
||||
public:
|
||||
IndirectCommandDrawElements():BufferData(){setBufferObject(new DrawIndirectBufferObject());}
|
||||
IndirectCommandDrawElements() : BufferData() { setBufferObject(new DrawIndirectBufferObject()); }
|
||||
|
||||
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 & instanceCount(const unsigned int&index)=0;
|
||||
@ -52,15 +56,16 @@ public:
|
||||
|
||||
virtual unsigned int getElementSize()const = 0;
|
||||
virtual unsigned int getNumElements() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// DrawArraysCommand
|
||||
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){};
|
||||
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) {}
|
||||
|
||||
unsigned int count;
|
||||
unsigned int instanceCount;
|
||||
unsigned int first;
|
||||
@ -74,30 +79,28 @@ class OSG_EXPORT DefaultIndirectCommandDrawArrays: public IndirectCommandDrawArr
|
||||
public:
|
||||
META_Object(osg,DefaultIndirectCommandDrawArrays)
|
||||
|
||||
DefaultIndirectCommandDrawArrays():IndirectCommandDrawArrays(), MixinVector<DrawArraysIndirectCommand>() {}
|
||||
DefaultIndirectCommandDrawArrays(const DefaultIndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
|
||||
:IndirectCommandDrawArrays(copy, copyop),MixinVector<DrawArraysIndirectCommand>() {}
|
||||
DefaultIndirectCommandDrawArrays() : IndirectCommandDrawArrays(), MixinVector<DrawArraysIndirectCommand>() {}
|
||||
DefaultIndirectCommandDrawArrays(const DefaultIndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/) :
|
||||
IndirectCommandDrawArrays(copy, copyop),MixinVector<DrawArraysIndirectCommand>() {}
|
||||
|
||||
virtual const GLvoid* getDataPointer() const {
|
||||
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 & count(const unsigned int&index){return at(index).count;}
|
||||
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());}
|
||||
virtual const GLvoid* getDataPointer() const { 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 & count(const unsigned int&index) { return at(index).count; }
|
||||
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
|
||||
/// DrawElementsCommand
|
||||
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){};
|
||||
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) {}
|
||||
|
||||
unsigned int count;
|
||||
unsigned int instanceCount;
|
||||
unsigned int firstIndex;
|
||||
@ -110,23 +113,22 @@ class OSG_EXPORT DefaultIndirectCommandDrawElements: public IndirectCommandDrawE
|
||||
{
|
||||
public:
|
||||
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;};
|
||||
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());}
|
||||
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; };
|
||||
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,21 +138,21 @@ class OSG_EXPORT DrawElementsIndirect : public DrawElements
|
||||
{
|
||||
public:
|
||||
|
||||
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());}
|
||||
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()); }
|
||||
|
||||
DrawElementsIndirect(const DrawElementsIndirect& rhs,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
DrawElements(rhs,copyop),_firstCommand(rhs._firstCommand), _stride(rhs._stride) {
|
||||
_indirectCommandArray=(DefaultIndirectCommandDrawElements*)copyop(rhs._indirectCommandArray.get());
|
||||
}
|
||||
DrawElementsIndirect(const DrawElementsIndirect& rhs,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
|
||||
DrawElements(rhs,copyop),_firstCommand(rhs._firstCommand), _stride(rhs._stride) { _indirectCommandArray=(DefaultIndirectCommandDrawElements*)copyop(rhs._indirectCommandArray.get()); }
|
||||
|
||||
/// set command array of this indirect primitive set
|
||||
inline void setIndirectCommandArray(IndirectCommandDrawElements*idc) {
|
||||
inline void setIndirectCommandArray(IndirectCommandDrawElements*idc)
|
||||
{
|
||||
_indirectCommandArray = idc;
|
||||
//ensure bo of idc is of the correct type
|
||||
if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject()))
|
||||
_indirectCommandArray->setBufferObject(new DrawIndirectBufferObject());
|
||||
}
|
||||
|
||||
/// get command array of this indirect primitive set
|
||||
inline IndirectCommandDrawElements* getIndirectCommandArray() { return _indirectCommandArray; }
|
||||
inline const IndirectCommandDrawElements* getIndirectCommandArray() const { return _indirectCommandArray; }
|
||||
@ -160,17 +162,16 @@ public:
|
||||
|
||||
/// set offset of the first command to draw 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; }
|
||||
|
||||
/// stride (to set if you use custom CommandArray)
|
||||
inline void setStride( GLsizei i) {
|
||||
_stride=i;
|
||||
}
|
||||
inline void setStride( GLsizei i) { _stride=i; }
|
||||
|
||||
/// stride (to set if you use custom CommandArray)
|
||||
inline GLsizei getStride() const {
|
||||
return _stride;
|
||||
}
|
||||
inline GLsizei getStride() const { return _stride; }
|
||||
|
||||
virtual unsigned int getNumPrimitives() const=0;
|
||||
|
||||
protected:
|
||||
@ -179,8 +180,8 @@ protected:
|
||||
unsigned int _firstCommand;
|
||||
GLsizei _stride;
|
||||
ref_ptr<IndirectCommandDrawElements> _indirectCommandArray;
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \brief The DrawElementsIndirectUByte PrimitiveSet
|
||||
///
|
||||
@ -190,10 +191,10 @@ public:
|
||||
|
||||
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) {}
|
||||
|
||||
DrawElementsIndirectUByte(const DrawElementsIndirectUByte& array, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
DrawElementsIndirectUByte(const DrawElementsIndirectUByte& array, const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
|
||||
DrawElementsIndirect(array,copyop),
|
||||
vector_type(array) {}
|
||||
|
||||
@ -214,64 +215,36 @@ public:
|
||||
DrawElementsIndirect(MultiDrawElementsUByteIndirectPrimitiveType,mode),
|
||||
vector_type(no) {}
|
||||
|
||||
virtual Object* cloneType() const {
|
||||
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 const char* libraryName() const {
|
||||
return "osg";
|
||||
}
|
||||
virtual const char* className() const {
|
||||
return "DrawElementsIndirectUByte";
|
||||
}
|
||||
virtual Object* cloneType() const { 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 const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "DrawElementsIndirectUByte"; }
|
||||
|
||||
virtual const GLvoid* getDataPointer() const {
|
||||
return empty()?0:&front();
|
||||
}
|
||||
virtual unsigned int getTotalDataSize() const {
|
||||
return static_cast<unsigned int>(size());
|
||||
}
|
||||
virtual bool supportsBufferObject() const {
|
||||
return false;
|
||||
}
|
||||
virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
|
||||
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 accept(PrimitiveFunctor& functor) const;
|
||||
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
||||
|
||||
virtual unsigned int getNumIndices() const {
|
||||
return static_cast<unsigned int>(size());
|
||||
}
|
||||
virtual unsigned int index(unsigned int pos) const {
|
||||
return (*this)[pos];
|
||||
}
|
||||
virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
virtual GLenum getDataType() {
|
||||
return GL_UNSIGNED_BYTE;
|
||||
}
|
||||
virtual void resizeElements(unsigned int numIndices) {
|
||||
resize(numIndices);
|
||||
}
|
||||
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(GLubyte(v));
|
||||
}
|
||||
virtual GLenum getDataType() { return GL_UNSIGNED_BYTE; }
|
||||
|
||||
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
||||
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(GLubyte(v)); }
|
||||
virtual unsigned int getNumPrimitives() const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DrawElementsIndirectUByte();
|
||||
@ -287,10 +260,10 @@ public:
|
||||
|
||||
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) {}
|
||||
|
||||
DrawElementsIndirectUShort(const DrawElementsIndirectUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
DrawElementsIndirectUShort(const DrawElementsIndirectUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
|
||||
DrawElementsIndirect(array,copyop),
|
||||
vector_type(array) {}
|
||||
|
||||
@ -316,64 +289,35 @@ public:
|
||||
DrawElementsIndirect(MultiDrawElementsUShortIndirectPrimitiveType,mode),
|
||||
vector_type(first,last) {}
|
||||
|
||||
virtual Object* cloneType() const {
|
||||
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 const char* libraryName() const {
|
||||
return "osg";
|
||||
}
|
||||
virtual const char* className() const {
|
||||
return "DrawElementsIndirectUShort";
|
||||
}
|
||||
virtual Object* cloneType() const { 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 const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "DrawElementsIndirectUShort"; }
|
||||
|
||||
virtual const GLvoid* getDataPointer() const {
|
||||
return empty()?0:&front();
|
||||
}
|
||||
virtual unsigned int getTotalDataSize() const {
|
||||
return 2u*static_cast<unsigned int>(size());
|
||||
}
|
||||
virtual bool supportsBufferObject() const {
|
||||
return false;
|
||||
}
|
||||
virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
|
||||
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 accept(PrimitiveFunctor& functor) const;
|
||||
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
||||
|
||||
virtual unsigned int getNumIndices() const {
|
||||
return static_cast<unsigned int>(size());
|
||||
}
|
||||
virtual unsigned int index(unsigned int pos) const {
|
||||
return (*this)[pos];
|
||||
}
|
||||
virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
virtual GLenum getDataType() {
|
||||
return GL_UNSIGNED_SHORT;
|
||||
}
|
||||
virtual void resizeElements(unsigned int numIndices) {
|
||||
resize(numIndices);
|
||||
}
|
||||
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(GLushort(v));
|
||||
}
|
||||
virtual GLenum getDataType() { return GL_UNSIGNED_SHORT; }
|
||||
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
||||
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(GLushort(v)); }
|
||||
virtual unsigned int getNumPrimitives() const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DrawElementsIndirectUShort();
|
||||
@ -388,10 +332,10 @@ public:
|
||||
|
||||
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) {}
|
||||
|
||||
DrawElementsIndirectUInt(const DrawElementsIndirectUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
DrawElementsIndirectUInt(const DrawElementsIndirectUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
|
||||
DrawElementsIndirect(array,copyop),
|
||||
vector_type(array) {}
|
||||
|
||||
@ -417,91 +361,56 @@ public:
|
||||
DrawElementsIndirect(MultiDrawElementsUIntIndirectPrimitiveType,mode),
|
||||
vector_type(first,last) {}
|
||||
|
||||
virtual Object* cloneType() const {
|
||||
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 const char* libraryName() const {
|
||||
return "osg";
|
||||
}
|
||||
virtual const char* className() const {
|
||||
return "DrawElementsIndirectUInt";
|
||||
}
|
||||
virtual Object* cloneType() const { 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 const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "DrawElementsIndirectUInt"; }
|
||||
|
||||
virtual const GLvoid* getDataPointer() const {
|
||||
return empty()?0:&front();
|
||||
}
|
||||
virtual unsigned int getTotalDataSize() const {
|
||||
return 4u*static_cast<unsigned int>(size());
|
||||
}
|
||||
virtual bool supportsBufferObject() const {
|
||||
return false;
|
||||
}
|
||||
virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
|
||||
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 accept(PrimitiveFunctor& functor) const;
|
||||
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
||||
|
||||
virtual unsigned int getNumIndices() const {
|
||||
return static_cast<unsigned int>(size());
|
||||
}
|
||||
virtual unsigned int index(unsigned int pos) const {
|
||||
return (*this)[pos];
|
||||
}
|
||||
virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
|
||||
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
||||
virtual void offsetIndices(int offset);
|
||||
|
||||
virtual GLenum getDataType() {
|
||||
return GL_UNSIGNED_INT;
|
||||
}
|
||||
virtual void resizeElements(unsigned int numIndices) {
|
||||
resize(numIndices);
|
||||
}
|
||||
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 GLenum getDataType() { return GL_UNSIGNED_INT; }
|
||||
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
||||
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;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DrawElementsIndirectUInt();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \brief The MultiDrawElementsIndirect PrimitiveSets
|
||||
///
|
||||
class OSG_EXPORT MultiDrawElementsIndirectUShort : public DrawElementsIndirectUShort
|
||||
{
|
||||
public:
|
||||
MultiDrawElementsIndirectUShort(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0):
|
||||
DrawElementsIndirectUShort(mode,firstCommand,stride),_count(commandcount){_primitiveType=(Type(MultiDrawElementsUShortIndirectPrimitiveType));}
|
||||
MultiDrawElementsIndirectUShort(const MultiDrawElementsIndirectUShort& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
MultiDrawElementsIndirectUShort(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0) :
|
||||
DrawElementsIndirectUShort(mode,firstCommand,stride),_count(commandcount) { _primitiveType=(Type(MultiDrawElementsUShortIndirectPrimitiveType)); }
|
||||
|
||||
MultiDrawElementsIndirectUShort(const MultiDrawElementsIndirectUShort& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
|
||||
DrawElementsIndirectUShort(mdi,copyop),_count(mdi._count) {}
|
||||
virtual osg::Object* cloneType() const {
|
||||
return new MultiDrawElementsIndirectUShort();
|
||||
}
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const {
|
||||
return new MultiDrawElementsIndirectUShort(*this,copyop);
|
||||
}
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const {
|
||||
return dynamic_cast<const MultiDrawElementsIndirectUShort*>(obj)!=NULL;
|
||||
}
|
||||
virtual const char* className() const {
|
||||
return "MultiDrawElementsIndirectUShort";
|
||||
}
|
||||
|
||||
virtual osg::Object* cloneType() const { return new MultiDrawElementsIndirectUShort(); }
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new MultiDrawElementsIndirectUShort(*this,copyop); }
|
||||
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 accept(PrimitiveFunctor& 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)
|
||||
|
||||
/// count of Indirect Command to execute
|
||||
inline void setNumCommandsToDraw( unsigned int i) {
|
||||
_count=i;
|
||||
}
|
||||
inline void setNumCommandsToDraw( unsigned int i) { _count=i; }
|
||||
/// count of Indirect Command to execute
|
||||
inline unsigned int getNumCommandsToDraw()const {
|
||||
return _count;
|
||||
}
|
||||
inline unsigned int getNumCommandsToDraw()const { return _count; }
|
||||
|
||||
protected:
|
||||
unsigned int _count;
|
||||
virtual ~MultiDrawElementsIndirectUShort();
|
||||
@ -525,73 +431,61 @@ protected:
|
||||
class OSG_EXPORT MultiDrawElementsIndirectUByte : public DrawElementsIndirectUByte
|
||||
{
|
||||
public:
|
||||
MultiDrawElementsIndirectUByte(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0):
|
||||
DrawElementsIndirectUByte(mode,firstCommand,stride),_count(commandcount){_primitiveType=(Type(MultiDrawElementsUByteIndirectPrimitiveType));}
|
||||
MultiDrawElementsIndirectUByte(const MultiDrawElementsIndirectUByte& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
MultiDrawElementsIndirectUByte(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0) :
|
||||
DrawElementsIndirectUByte(mode,firstCommand,stride),_count(commandcount) { _primitiveType=(Type(MultiDrawElementsUByteIndirectPrimitiveType)); }
|
||||
|
||||
MultiDrawElementsIndirectUByte(const MultiDrawElementsIndirectUByte& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
|
||||
DrawElementsIndirectUByte(mdi,copyop),_count(mdi._count) {}
|
||||
virtual osg::Object* cloneType() const {
|
||||
return new MultiDrawElementsIndirectUByte();
|
||||
}
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const {
|
||||
return new MultiDrawElementsIndirectUByte(*this,copyop);
|
||||
}
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const {
|
||||
return dynamic_cast<const MultiDrawElementsIndirectUByte*>(obj)!=NULL;
|
||||
}
|
||||
virtual const char* className() const {
|
||||
return "MultiDrawElementsIndirectUByte";
|
||||
}
|
||||
|
||||
virtual osg::Object* cloneType() const { return new MultiDrawElementsIndirectUByte(); }
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new MultiDrawElementsIndirectUByte(*this,copyop); }
|
||||
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 accept(PrimitiveFunctor& functor) const;
|
||||
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
||||
virtual unsigned int getNumPrimitives() const;
|
||||
|
||||
/// count of Indirect Command to execute
|
||||
inline void setNumCommandsToDraw( unsigned int i) {
|
||||
_count=i;
|
||||
}
|
||||
inline void setNumCommandsToDraw( unsigned int i) { _count=i; }
|
||||
/// count of Indirect Command to execute
|
||||
inline unsigned int getNumCommandsToDraw()const {
|
||||
return _count;
|
||||
}
|
||||
inline unsigned int getNumCommandsToDraw()const { return _count; }
|
||||
|
||||
protected:
|
||||
unsigned int _count;
|
||||
virtual ~MultiDrawElementsIndirectUByte();
|
||||
};
|
||||
|
||||
class OSG_EXPORT MultiDrawElementsIndirectUInt : public DrawElementsIndirectUInt
|
||||
{
|
||||
public:
|
||||
MultiDrawElementsIndirectUInt(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0):
|
||||
DrawElementsIndirectUInt(mode,firstCommand,stride),_count(commandcount){_primitiveType=(Type(MultiDrawElementsUIntIndirectPrimitiveType));}
|
||||
MultiDrawElementsIndirectUInt(const MultiDrawElementsIndirectUInt& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
MultiDrawElementsIndirectUInt(GLenum mode = 0,unsigned int firstCommand = 0,unsigned int commandcount = 0, GLsizei stride = 0) :
|
||||
DrawElementsIndirectUInt(mode,firstCommand,stride),_count(commandcount) { _primitiveType=(Type(MultiDrawElementsUIntIndirectPrimitiveType)); }
|
||||
|
||||
MultiDrawElementsIndirectUInt(const MultiDrawElementsIndirectUInt& mdi,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
|
||||
DrawElementsIndirectUInt(mdi,copyop),_count(mdi._count) {}
|
||||
virtual osg::Object* cloneType() const {
|
||||
return new MultiDrawElementsIndirectUInt();
|
||||
}
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const {
|
||||
return new MultiDrawElementsIndirectUInt(*this,copyop);
|
||||
}
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const {
|
||||
return dynamic_cast<const MultiDrawElementsIndirectUInt*>(obj)!=NULL;
|
||||
}
|
||||
virtual const char* className() const {
|
||||
return "MultiDrawElementsIndirectUInt";
|
||||
}
|
||||
|
||||
virtual osg::Object* cloneType() const { return new MultiDrawElementsIndirectUInt(); }
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new MultiDrawElementsIndirectUInt(*this,copyop); }
|
||||
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 accept(PrimitiveFunctor& functor) const;
|
||||
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
||||
virtual unsigned int getNumPrimitives() const;
|
||||
|
||||
/// count of Indirect Command to execute
|
||||
inline void setNumCommandsToDraw( unsigned int i) {
|
||||
_count=i;
|
||||
}
|
||||
inline void setNumCommandsToDraw( unsigned int i) { _count=i; }
|
||||
/// count of Indirect Command to execute
|
||||
inline unsigned int getNumCommandsToDraw()const {
|
||||
return _count;
|
||||
}
|
||||
inline unsigned int getNumCommandsToDraw()const { return _count; }
|
||||
|
||||
protected:
|
||||
unsigned int _count;
|
||||
virtual ~MultiDrawElementsIndirectUInt();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
/// \brief The MultiDrawArraysIndirect PrimitiveSet
|
||||
///
|
||||
@ -599,32 +493,21 @@ class OSG_EXPORT DrawArraysIndirect : public osg::PrimitiveSet
|
||||
{
|
||||
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),
|
||||
_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),
|
||||
_firstCommand(dal._firstCommand),
|
||||
_stride(dal._stride),
|
||||
_indirectCommandArray((DefaultIndirectCommandDrawArrays*)copyop( dal._indirectCommandArray.get()))
|
||||
{}
|
||||
_indirectCommandArray((DefaultIndirectCommandDrawArrays*)copyop( dal._indirectCommandArray.get())) {}
|
||||
|
||||
virtual osg::Object* cloneType() const {
|
||||
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 const char* libraryName() const {
|
||||
return "osg";
|
||||
}
|
||||
virtual const char* className() const {
|
||||
return "DrawArraysIndirect";
|
||||
}
|
||||
virtual osg::Object* cloneType() const { 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 const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "DrawArraysIndirect"; }
|
||||
|
||||
virtual void draw(State& state, bool useVertexBufferObjects) const;
|
||||
|
||||
@ -638,34 +521,26 @@ public:
|
||||
virtual unsigned int getNumPrimitives() const;
|
||||
|
||||
/// stride (to set if you use custom CommandArray)
|
||||
inline void setStride( GLsizei 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 setStride( GLsizei i) { _stride=i; }
|
||||
|
||||
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;
|
||||
//ensure bo of idc is of the correct type
|
||||
if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject()))
|
||||
_indirectCommandArray->setBufferObject(new DrawIndirectBufferObject());
|
||||
}
|
||||
inline const IndirectCommandDrawArrays* getIndirectCommandArray() const {
|
||||
return _indirectCommandArray;
|
||||
}
|
||||
inline IndirectCommandDrawArrays* getIndirectCommandArray(){
|
||||
return _indirectCommandArray;
|
||||
}
|
||||
inline const IndirectCommandDrawArrays* getIndirectCommandArray() const { return _indirectCommandArray; }
|
||||
inline IndirectCommandDrawArrays* getIndirectCommandArray() { return _indirectCommandArray; }
|
||||
|
||||
protected:
|
||||
|
||||
@ -682,27 +557,16 @@ class OSG_EXPORT MultiDrawArraysIndirect : public DrawArraysIndirect
|
||||
{
|
||||
public:
|
||||
|
||||
MultiDrawArraysIndirect(GLenum mode=0, unsigned int firstcommand = 0, unsigned int count = 0, GLsizei stride = 0):
|
||||
osg::DrawArraysIndirect(mode, firstcommand, stride), _count(count)
|
||||
{_primitiveType=Type(MultiDrawArraysIndirectPrimitiveType);}
|
||||
MultiDrawArraysIndirect(GLenum mode=0, unsigned int firstcommand = 0, unsigned int count = 0, GLsizei stride = 0) :
|
||||
osg::DrawArraysIndirect(mode, firstcommand, stride), _count(count) { _primitiveType=Type(MultiDrawArraysIndirectPrimitiveType); }
|
||||
|
||||
MultiDrawArraysIndirect(const MultiDrawArraysIndirect& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
osg::DrawArraysIndirect(dal,copyop), _count(dal._count)
|
||||
{}
|
||||
MultiDrawArraysIndirect(const MultiDrawArraysIndirect& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
|
||||
osg::DrawArraysIndirect(dal,copyop), _count(dal._count) {}
|
||||
|
||||
virtual osg::Object* cloneType() const {
|
||||
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 const char* className() const {
|
||||
return "MultiDrawArraysIndirect";
|
||||
}
|
||||
virtual osg::Object* cloneType() const { 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 const char* className() const { return "MultiDrawArraysIndirect"; }
|
||||
|
||||
virtual void draw(State& state, bool useVertexBufferObjects) const;
|
||||
|
||||
@ -716,13 +580,10 @@ public:
|
||||
virtual unsigned int getNumPrimitives() const;
|
||||
|
||||
/// count of Indirect Command to execute
|
||||
inline void setNumCommandsToDraw( unsigned int i) {
|
||||
_count=i;
|
||||
}
|
||||
inline void setNumCommandsToDraw( unsigned int i) { _count=i; }
|
||||
/// count of Indirect Command to execute
|
||||
inline unsigned int getNumCommandsToDraw()const {
|
||||
return _count;
|
||||
}
|
||||
inline unsigned int getNumCommandsToDraw()const { return _count; }
|
||||
|
||||
protected:
|
||||
unsigned int _count;
|
||||
|
||||
@ -731,4 +592,3 @@ protected:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user