From 859bcf3c4b521d0f478429cd8ff15386694d898f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 1 May 2007 18:03:32 +0000 Subject: [PATCH] Further perfomrmance optimizations and clean up on new VBO/EBO/PBO API. --- include/osg/Array | 24 ++-- include/osg/BufferObject | 38 ++++--- include/osg/Drawable | 1 - include/osg/Geometry | 34 +++--- include/osg/PrimitiveSet | 63 +++++------ include/osg/State | 28 ++++- src/osg/BufferObject.cpp | 161 ++++++++++++--------------- src/osg/Drawable.cpp | 9 -- src/osg/Geometry.cpp | 139 +++++++++-------------- src/osg/PrimitiveSet.cpp | 93 +--------------- src/osg/Texture.cpp | 11 +- src/osg/TextureRectangle.cpp | 10 +- src/osgWrappers/osg/Array.cpp | 18 +-- src/osgWrappers/osg/BufferObject.cpp | 67 +++++------ src/osgWrappers/osg/Geometry.cpp | 13 ++- src/osgWrappers/osg/PrimitiveSet.cpp | 58 ++++------ 16 files changed, 306 insertions(+), 461 deletions(-) diff --git a/include/osg/Array b/include/osg/Array index 7eae17957..10a3685ff 100644 --- a/include/osg/Array +++ b/include/osg/Array @@ -73,7 +73,7 @@ class OSG_EXPORT Array : public Object _dataSize(dataSize), _dataType(dataType), _modifiedCount(0), - _vboIndex(0) {} + _vboOffset(0) {} Array(const Array& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY): Object(array,copyop), @@ -81,7 +81,7 @@ class OSG_EXPORT Array : public Object _dataSize(array._dataSize), _dataType(array._dataType), _modifiedCount(0), - _vboIndex(0) {} + _vboOffset(0) {} virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } virtual const char* libraryName() const { return "osg"; } @@ -123,18 +123,14 @@ class OSG_EXPORT Array : public Object if (_vbo.valid()) { - _vbo->setArray(_vboIndex,0); + _vbo->removeArray(this); } _vbo = vbo; if (_vbo.valid()) { - _vboIndex = _vbo->addArray(this); - } - else - { - _vboIndex = 0; + _vbo->addArray(this); } } @@ -144,11 +140,11 @@ class OSG_EXPORT Array : public Object /** Get the const VertexBufferObject. If no VBO is assigned returns NULL*/ inline const osg::VertexBufferObject* getVertexBufferObject() const { return _vbo.get(); } - /** Set the index into the VertexBufferObject, if used.*/ - inline void setVertexBufferObjectIndex(unsigned int index) { _vboIndex = index; } + /** Set the offset into the VertexBufferObject, if used.*/ + void setVertexBufferObjectOffset(const GLvoid* offset ) const { _vboOffset = offset; } - /** Get the index into the VertexBufferObject, if used.*/ - inline unsigned int getVertexBufferObjectIndex() const { return _vboIndex; } + /** Get the offset into the VertexBufferObject, if used.*/ + const GLvoid* getVertexBufferObjectOffset() const { return _vboOffset; } protected: @@ -156,7 +152,7 @@ class OSG_EXPORT Array : public Object { if (_vbo.valid()) { - _vbo->setArray(_vboIndex,0); + _vbo->removeArray(this); } } @@ -165,7 +161,7 @@ class OSG_EXPORT Array : public Object GLenum _dataType; unsigned int _modifiedCount; osg::ref_ptr _vbo; - unsigned int _vboIndex; + mutable const GLvoid* _vboOffset; }; template diff --git a/include/osg/BufferObject b/include/osg/BufferObject index 12db68bf7..46b35be81 100644 --- a/include/osg/BufferObject +++ b/include/osg/BufferObject @@ -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 modifiedCount; - mutable unsigned int dataSize; - mutable unsigned int offset; + mutable unsigned int dataSize; + mutable unsigned int offset; }; inline bool isBufferObjectSupported(unsigned int contextID) const { return getExtensions(contextID,true)->isBufferObjectSupported(); } @@ -126,16 +126,15 @@ class OSG_EXPORT BufferObject : public Object bool isDirty(unsigned int contextID) const { return _compiledList[contextID]==0; } - virtual bool needsCompile(unsigned int contextID) const = 0; - - inline void compileBuffer(unsigned int contextID, State& state) const - { - if (isDirty(contextID)) compileBufferImplementation(state); - } - - virtual void compileBufferImplementation(State& state) const = 0; + virtual void compileBuffer(State& state) const = 0; - void releaseBuffer(State* state) const; + /** Resize any per context GLObject buffers to specified size. */ + virtual void resizeGLObjectBuffers(unsigned int maxSize); + + /** If State is non-zero, this function releases OpenGL objects for + * the specified graphics context. Otherwise, releases OpenGL objexts + * for all graphics contexts. */ + void releaseGLObjects(State* state=0) const; /** Use deleteVertexBufferObject instead of glDeleteBuffers to allow @@ -250,6 +249,7 @@ class OSG_EXPORT VertexBufferObject : public BufferObject typedef std::vector< BufferEntryArrayPair > BufferEntryArrayPairs; unsigned int addArray(osg::Array* array); + void removeArray(osg::Array* array); void setArray(unsigned int i, Array* array); Array* getArray(unsigned int i) { return _bufferEntryArrayPairs[i].second; } @@ -257,9 +257,10 @@ class OSG_EXPORT VertexBufferObject : public BufferObject const GLvoid* getOffset(unsigned int i) const { return (const GLvoid*)(_bufferEntryArrayPairs[i].first.offset); } - virtual bool needsCompile(unsigned int contextID) const; + virtual void compileBuffer(State& state) const; - virtual void compileBufferImplementation(State& state) const; + /** Resize any per context GLObject buffers to specified size. */ + virtual void resizeGLObjectBuffers(unsigned int maxSize); protected: @@ -284,6 +285,7 @@ class OSG_EXPORT ElementBufferObject : public BufferObject typedef std::vector< BufferEntryDrawElementstPair > BufferEntryDrawElementsPairs; unsigned int addDrawElements(osg::DrawElements* PrimitiveSet); + void removeDrawElements(osg::DrawElements* PrimitiveSet); void setDrawElements(unsigned int i, DrawElements* PrimitiveSet); DrawElements* getDrawElements(unsigned int i) { return _bufferEntryDrawElementsPairs[i].second; } @@ -291,9 +293,10 @@ class OSG_EXPORT ElementBufferObject : public BufferObject const GLvoid* getOffset(unsigned int i) const { return (const GLvoid*)(_bufferEntryDrawElementsPairs[i].first.offset); } - virtual bool needsCompile(unsigned int contextID) const; + virtual void compileBuffer(State& state) const; - virtual void compileBufferImplementation(State& state) const; + /** Resize any per context GLObject buffers to specified size. */ + virtual void resizeGLObjectBuffers(unsigned int maxSize); protected: @@ -323,9 +326,10 @@ class OSG_EXPORT PixelBufferObject : public BufferObject unsigned int offset() const { return _bufferEntryImagePair.first.offset; } - virtual bool needsCompile(unsigned int contextID) const; + virtual void compileBuffer(State& state) const; - virtual void compileBufferImplementation(State& state) const; + /** Resize any per context GLObject buffers to specified size. */ + virtual void resizeGLObjectBuffers(unsigned int maxSize); protected: diff --git a/include/osg/Drawable b/include/osg/Drawable index f0b7eb017..3af22fcbf 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -803,7 +803,6 @@ class OSG_EXPORT Drawable : public Object typedef osg::buffered_value GLObjectList; mutable GLObjectList _globjList; - mutable GLObjectList _vboList; ref_ptr _updateCallback; unsigned int _numChildrenRequiringUpdateTraversal; diff --git a/include/osg/Geometry b/include/osg/Geometry index b1012ab9b..84cb94568 100644 --- a/include/osg/Geometry +++ b/include/osg/Geometry @@ -57,8 +57,7 @@ class OSG_EXPORT Geometry : public Drawable { ArrayData(): binding(BIND_OFF), - normalize(GL_FALSE), - offset(0) {} + normalize(GL_FALSE) {} ArrayData(const ArrayData& data,const CopyOp& copyop=CopyOp::SHALLOW_COPY); @@ -66,15 +65,13 @@ class OSG_EXPORT Geometry : public Drawable array(a), indices(0), binding(b), - normalize(n), - offset(0) {} + normalize(n) {} ArrayData(Array* a, IndexArray* i, AttributeBinding b, GLboolean n = GL_FALSE): array(a), indices(i), binding(b), - normalize(n), - offset(0) {} + normalize(n) {} ArrayData& operator = (const ArrayData& rhs) { @@ -82,7 +79,6 @@ class OSG_EXPORT Geometry : public Drawable indices = rhs.indices; binding = rhs.binding; normalize = rhs.normalize; - offset = rhs.offset; return *this; } @@ -92,15 +88,13 @@ class OSG_EXPORT Geometry : public Drawable ref_ptr indices; AttributeBinding binding; GLboolean normalize; - mutable unsigned long offset; }; struct OSG_EXPORT Vec3ArrayData { Vec3ArrayData(): binding(BIND_OFF), - normalize(GL_FALSE), - offset(0) {} + normalize(GL_FALSE) {} Vec3ArrayData(const Vec3ArrayData& data,const CopyOp& copyop=CopyOp::SHALLOW_COPY); @@ -108,15 +102,13 @@ class OSG_EXPORT Geometry : public Drawable array(a), indices(0), binding(b), - normalize(n), - offset(0) {} + normalize(n) {} Vec3ArrayData(Vec3Array* a, IndexArray* i, AttributeBinding b, GLboolean n = GL_FALSE): array(a), indices(i), binding(b), - normalize(n), - offset(0) {} + normalize(n) {} Vec3ArrayData& operator = (const Vec3ArrayData& rhs) { @@ -124,7 +116,6 @@ class OSG_EXPORT Geometry : public Drawable indices = rhs.indices; binding = rhs.binding; normalize = rhs.normalize; - offset = rhs.offset; return *this; } @@ -134,7 +125,6 @@ class OSG_EXPORT Geometry : public Drawable ref_ptr indices; AttributeBinding binding; GLboolean normalize; - mutable unsigned long offset; }; /** Static ArrayData which is returned from getTexCoordData(i) const and getVertexAttribData(i) const @@ -300,11 +290,19 @@ class OSG_EXPORT Geometry : public Drawable virtual void dirtyDisplayList(); + /** Resize any per context GLObject buffers to specified size. */ + virtual void resizeGLObjectBuffers(unsigned int maxSize); + + /** If State is non-zero, this function releases OpenGL objects for + * the specified graphics context. Otherwise, releases OpenGL objexts + * for all graphics contexts. */ + virtual void releaseGLObjects(State* state=0) const; + typedef std::vector ArrayList; - bool getArrayList(ArrayList& arrayList); + bool getArrayList(ArrayList& arrayList) const; typedef std::vector DrawElementsList; - bool getDrawElementsList(DrawElementsList& drawElementsList); + bool getDrawElementsList(DrawElementsList& drawElementsList) const; osg::VertexBufferObject* getOrCreateVertexBufferObject(); diff --git a/include/osg/PrimitiveSet b/include/osg/PrimitiveSet index 69c39c9d3..354013513 100644 --- a/include/osg/PrimitiveSet +++ b/include/osg/PrimitiveSet @@ -413,11 +413,11 @@ class DrawElements : public PrimitiveSet DrawElements(Type primType=PrimitiveType, GLenum mode=0): PrimitiveSet(primType,mode), - _eboIndex(0) {} + _eboOffset(0) {} DrawElements(const DrawElements& copy,const CopyOp& copyop=CopyOp::SHALLOW_COPY): PrimitiveSet(copy,copyop), - _eboIndex(0) {} + _eboOffset(0) {} virtual DrawElements* getDrawElements() { return this; } @@ -432,17 +432,14 @@ class DrawElements : public PrimitiveSet if (_ebo.valid()) { - _ebo->setDrawElements(_eboIndex,0); + _ebo->removeDrawElements(this); } + _ebo = ebo; if (_ebo.valid()) { - _eboIndex = _ebo->addDrawElements(this); - } - else - { - _eboIndex = 0; + _ebo->addDrawElements(this); } } @@ -452,25 +449,40 @@ class DrawElements : public PrimitiveSet /** Get the const ElementBufferObject. If no EBO is assigned returns NULL*/ inline const osg::ElementBufferObject* getElementBufferObject() const { return _ebo.get(); } - /** Set the index into the ElementBufferObject, if used.*/ - inline void setElementBufferObjectIndex(unsigned int index) { _eboIndex = index; } + /** Set the offset into the ElementBufferObject, if used.*/ + inline void setElementBufferObjectOffset(const GLvoid* offset) const { _eboOffset = offset; } - /** Get the index into the ElementBufferObject, if used.*/ - inline unsigned int getElementBufferObjectIndex() const { return _eboIndex; } + /** Get the offset into the ElementBufferOffset, if used.*/ + inline const GLvoid* getElementBufferObjectOffset() const { return _eboOffset; } + /** Resize any per context GLObject buffers to specified size. */ + virtual void resizeGLObjectBuffers(unsigned int maxSize) + { + if (_ebo.valid()) _ebo->resizeGLObjectBuffers(maxSize); + } + + /** If State is non-zero, this function releases OpenGL objects for + * the specified graphics context. Otherwise, releases OpenGL objexts + * for all graphics contexts. */ + virtual void releaseGLObjects(State* state=0) const + { + if (_ebo.valid()) _ebo->releaseGLObjects(state); + } + protected: virtual ~DrawElements() { if (_ebo.valid()) { - _ebo->setDrawElements(_eboIndex,0); + _ebo->removeDrawElements(this); } } - osg::ref_ptr _ebo; - unsigned int _eboIndex; + osg::ref_ptr _ebo; + mutable const GLvoid* _eboOffset; + }; class OSG_EXPORT DrawElementsUByte : public DrawElements, public VectorGLubyte @@ -512,11 +524,6 @@ class OSG_EXPORT DrawElementsUByte : public DrawElements, public VectorGLubyte virtual unsigned int getNumIndices() const { return size(); } virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; } virtual void offsetIndices(int offset); - - /** Resize any per context GLObject buffers to specified size. */ - virtual void resizeGLObjectBuffers(unsigned int maxSize); - - virtual void releaseGLObjects(State* state=0) const; virtual void computeRange() const { @@ -545,9 +552,6 @@ class OSG_EXPORT DrawElementsUByte : public DrawElements, public VectorGLubyte mutable unsigned int _minIndex; mutable unsigned int _maxIndex; - - mutable GLObjectList _vboList; - }; @@ -596,11 +600,6 @@ class OSG_EXPORT DrawElementsUShort : public DrawElements, public VectorGLushort virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; } virtual void offsetIndices(int offset); - /** Resize any per context GLObject buffers to specified size. */ - virtual void resizeGLObjectBuffers(unsigned int maxSize); - - virtual void releaseGLObjects(State* state=0) const; - virtual void computeRange() const { if (empty()) @@ -628,8 +627,6 @@ class OSG_EXPORT DrawElementsUShort : public DrawElements, public VectorGLushort mutable unsigned int _minIndex; mutable unsigned int _maxIndex; - - mutable GLObjectList _vboList; }; class OSG_EXPORT DrawElementsUInt : public DrawElements, public VectorGLuint @@ -677,10 +674,6 @@ class OSG_EXPORT DrawElementsUInt : public DrawElements, public VectorGLuint virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; } virtual void offsetIndices(int offset); - /** Resize any per context GLObject buffers to specified size. */ - virtual void resizeGLObjectBuffers(unsigned int maxSize); - - virtual void releaseGLObjects(State* state=0) const; virtual void computeRange() const { @@ -709,8 +702,6 @@ class OSG_EXPORT DrawElementsUInt : public DrawElements, public VectorGLuint mutable unsigned int _minIndex; mutable unsigned int _maxIndex; - - mutable GLObjectList _vboList; }; } diff --git a/include/osg/State b/include/osg/State index 9a9c9066c..d1da97c95 100644 --- a/include/osg/State +++ b/include/osg/State @@ -409,7 +409,7 @@ class OSG_EXPORT State : public Referenced inline void bindVertexBufferObject(const osg::VertexBufferObject* vbo) { if (vbo == _currentVBO) return; - if (vbo->isDirty(_contextID)) vbo->compileBuffer(_contextID, *this); + if (vbo->isDirty(_contextID)) vbo->compileBuffer(*this); else _glBindBuffer(GL_ARRAY_BUFFER_ARB,vbo->buffer(_contextID)); _currentVBO = vbo; } @@ -427,7 +427,7 @@ class OSG_EXPORT State : public Referenced inline void bindElementBufferObject(const osg::ElementBufferObject* ebo) { if (ebo == _currentEBO) return; - if (ebo->isDirty(_contextID)) ebo->compileBuffer(_contextID, *this); + if (ebo->isDirty(_contextID)) ebo->compileBuffer(*this); else _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,ebo->buffer(_contextID)); _currentEBO = ebo; } @@ -446,7 +446,7 @@ class OSG_EXPORT State : public Referenced { if (pbo == _currentPBO) return; - if (pbo->isDirty(_contextID)) pbo->compileBuffer(_contextID, *this); + if (pbo->isDirty(_contextID)) pbo->compileBuffer(*this); else _glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,pbo->buffer(_contextID)); _currentPBO = pbo; @@ -474,7 +474,7 @@ class OSG_EXPORT State : public Referenced if (vbo) { bindVertexBufferObject(vbo); - setVertexPointer(array->getDataSize(),array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex())); + setVertexPointer(array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset()); } else { @@ -531,7 +531,7 @@ class OSG_EXPORT State : public Referenced if (vbo) { bindVertexBufferObject(vbo); - setNormalPointer(array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex())); + setNormalPointer(array->getDataType(),0,array->getVertexBufferObjectOffset()); } else { @@ -587,7 +587,7 @@ class OSG_EXPORT State : public Referenced if (vbo) { bindVertexBufferObject(vbo); - setColorPointer(array->getDataSize(),array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex())); + setColorPointer(array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset()); } else { @@ -648,7 +648,11 @@ class OSG_EXPORT State : public Referenced if (vbo) { bindVertexBufferObject(vbo); +#if 0 setSecondaryColorPointer(array->getDataSize(),array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex())); +#else + setSecondaryColorPointer(array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset()); +#endif } else { @@ -730,7 +734,11 @@ class OSG_EXPORT State : public Referenced if (vbo) { bindVertexBufferObject(vbo); +#if 0 setFogCoordPointer(array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex())); +#else + setFogCoordPointer(array->getDataType(),0,array->getVertexBufferObjectOffset()); +#endif } else { @@ -775,7 +783,11 @@ class OSG_EXPORT State : public Referenced if (vbo) { bindVertexBufferObject(vbo); +#if 0 setTexCoordPointer(unit, array->getDataSize(),array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex())); +#else + setTexCoordPointer(unit, array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset()); +#endif } else { @@ -893,7 +905,11 @@ class OSG_EXPORT State : public Referenced if (vbo) { bindVertexBufferObject(vbo); +#if 0 setVertexAttribPointer(unit, array->getDataSize(),array->getDataType(),normalized,0,vbo->getOffset(array->getVertexBufferObjectIndex())); +#else + setVertexAttribPointer(unit, array->getDataSize(),array->getDataType(),normalized,0,array->getVertexBufferObjectOffset()); +#endif } else { diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index a0ad8fa3d..6400295ef 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -101,10 +101,15 @@ BufferObject::BufferObject(const BufferObject& bo,const CopyOp& copyop): BufferObject::~BufferObject() { - releaseBuffer(0); + releaseGLObjects(0); } -void BufferObject::releaseBuffer(State* state) const +void BufferObject::resizeGLObjectBuffers(unsigned int maxSize) +{ + _bufferObjectList.resize(maxSize); +} + +void BufferObject::releaseGLObjects(State* state) const { if (state) { @@ -313,6 +318,18 @@ unsigned int VertexBufferObject::addArray(osg::Array* array) return i; } +void VertexBufferObject::removeArray(osg::Array* array) +{ + BufferEntryArrayPairs::iterator itr; + for(itr = _bufferEntryArrayPairs.begin(); + itr != _bufferEntryArrayPairs.end(); + ++itr) + { + if (itr->second == array) break; + } + if (itr != _bufferEntryArrayPairs.end()) _bufferEntryArrayPairs.erase(itr); +} + void VertexBufferObject::setArray(unsigned int i, Array* array) { if (i+1>=_bufferEntryArrayPairs.size()) _bufferEntryArrayPairs.resize(i+1); @@ -323,41 +340,7 @@ void VertexBufferObject::setArray(unsigned int i, Array* array) dirty(); } - -bool VertexBufferObject::needsCompile(unsigned int contextID) const -{ - if (isDirty(contextID)) return true; - - unsigned int numValidArray = 0; - for(BufferEntryArrayPairs::const_iterator itr = _bufferEntryArrayPairs.begin(); - itr != _bufferEntryArrayPairs.end(); - ++itr) - { - const BufferEntryArrayPair& bep = *itr; - if (bep.second) - { - ++numValidArray; - - if (bep.first.modifiedCount[contextID] != bep.second->getModifiedCount()) - { - return true; - } - - if (bep.first.dataSize != bep.second->getTotalDataSize()) - { - return true; - } - } - } - - if (numValidArray==0) return false; - - if (_bufferObjectList[contextID]==0) return true; - - return false; -} - -void VertexBufferObject::compileBufferImplementation(State& state) const +void VertexBufferObject::compileBuffer(State& state) const { unsigned int contextID = state.getContextID(); @@ -365,7 +348,7 @@ void VertexBufferObject::compileBufferImplementation(State& state) const Extensions* extensions = getExtensions(contextID,true); - osg::notify(osg::NOTICE)<<"VertexBufferObject::compileBuffer frameNumber="<getFrameNumber()<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<first.modifiedCount.resize(maxSize); + } +} + ////////////////////////////////////////////////////////////////////////////////// // // ElementBufferObject @@ -492,6 +488,18 @@ unsigned int ElementBufferObject::addDrawElements(osg::DrawElements* drawElement return i; } +void ElementBufferObject::removeDrawElements(osg::DrawElements* drawElements) +{ + BufferEntryDrawElementsPairs::iterator itr; + for(itr = _bufferEntryDrawElementsPairs.begin(); + itr != _bufferEntryDrawElementsPairs.end(); + ++itr) + { + if (itr->second == drawElements) break; + } + if (itr != _bufferEntryDrawElementsPairs.end()) _bufferEntryDrawElementsPairs.erase(itr); +} + void ElementBufferObject::setDrawElements(unsigned int i, DrawElements* drawElements) { if (i+1>=_bufferEntryDrawElementsPairs.size()) _bufferEntryDrawElementsPairs.resize(i+1); @@ -501,48 +509,13 @@ void ElementBufferObject::setDrawElements(unsigned int i, DrawElements* drawElem _bufferEntryDrawElementsPairs[i].first.dataSize = 0; } -bool ElementBufferObject::needsCompile(unsigned int contextID) const -{ - if (isDirty(contextID)) return true; - -#if 1 - unsigned int numValidDrawElements = 0; - for(BufferEntryDrawElementsPairs::const_iterator itr = _bufferEntryDrawElementsPairs.begin(); - itr != _bufferEntryDrawElementsPairs.end(); - ++itr) - { - const BufferEntryDrawElementstPair& bep = *itr; - if (bep.second) - { - ++numValidDrawElements; - - if (bep.first.modifiedCount[contextID] != bep.second->getModifiedCount()) - { - return true; - } - - if (bep.first.dataSize != bep.second->getTotalDataSize()) - { - return true; - } - } - } - - if (numValidDrawElements==0) return false; -#endif - - if (_bufferObjectList[contextID]==0) return true; - - return false; -} - -void ElementBufferObject::compileBufferImplementation(State& state) const +void ElementBufferObject::compileBuffer(State& state) const { unsigned int contextID = state.getContextID(); _compiledList[contextID] = 1; - osg::notify(osg::NOTICE)<<"ElementBufferObject::compile"<setElementBufferObjectOffset((GLvoid*)offset); offset += bep.first.dataSize; } @@ -639,6 +613,18 @@ void ElementBufferObject::compileBufferImplementation(State& state) const // osg::notify(osg::NOTICE)<<"pbo "<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<first.modifiedCount.resize(maxSize); + } +} + ////////////////////////////////////////////////////////////////////////////////// // // PixelBufferObject @@ -670,23 +656,7 @@ void PixelBufferObject::setImage(osg::Image* image) dirty(); } - -bool PixelBufferObject::needsCompile(unsigned int contextID) const -{ - if (isDirty(contextID)) return true; - - if (!_bufferEntryImagePair.second) - return false; - - if (_bufferEntryImagePair.first.modifiedCount[contextID]!=_bufferEntryImagePair.second->getModifiedCount()) - return true; - - if (_bufferObjectList[contextID]==0) return true; - - return false; -} - -void PixelBufferObject::compileBufferImplementation(State& state) const +void PixelBufferObject::compileBuffer(State& state) const { unsigned int contextID = state.getContextID(); @@ -742,3 +712,10 @@ void PixelBufferObject::compileBufferImplementation(State& state) const // osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<(copyop(data.indices.get()))), binding(data.binding), - normalize(data.normalize), - offset(data.offset) + normalize(data.normalize) { } @@ -367,8 +366,7 @@ Geometry::Vec3ArrayData::Vec3ArrayData(const Vec3ArrayData& data,const CopyOp& c array(dynamic_cast(copyop(data.array.get()))), indices(dynamic_cast(copyop(data.indices.get()))), binding(data.binding), - normalize(data.normalize), - offset(data.offset) + normalize(data.normalize) { } @@ -981,7 +979,7 @@ unsigned int Geometry::getGLObjectSizeHint() const return totalSize; } -bool Geometry::getArrayList(ArrayList& arrayList) +bool Geometry::getArrayList(ArrayList& arrayList) const { unsigned int startSize = arrayList.size(); @@ -1006,11 +1004,11 @@ bool Geometry::getArrayList(ArrayList& arrayList) return arrayList.size()!=startSize; } -bool Geometry::getDrawElementsList(DrawElementsList& drawElementsList) +bool Geometry::getDrawElementsList(DrawElementsList& drawElementsList) const { unsigned int startSize = drawElementsList.size(); - for(PrimitiveSetList::iterator itr = _primitives.begin(); + for(PrimitiveSetList::const_iterator itr = _primitives.begin(); itr != _primitives.end(); ++itr) { @@ -1088,7 +1086,7 @@ osg::ElementBufferObject* Geometry::getOrCreateElementBufferObject() void Geometry::setUseVertexBufferObjects(bool flag) { - flag = true; + // flag = true; // osg::notify(osg::NOTICE)<<"Geometry::setUseVertexBufferObjects("<getVertexBufferObject() : 0; \ - if (new_vbo) \ - { \ - if (new_vbo!=prev_vbo) new_vbo->bindBuffer(contextID); \ - prev_vbo = new_vbo; \ - setVertexPointer(vertexData.array->getDataSize(),vertexData.array->getDataType(),0,new_vbo->getOffset(vertexData.array->getVertexBufferObjectIndex())); \ - } \ - else \ - { \ - extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); \ - prev_vbo = 0; \ - setVertexPointer(vertexData.array->getDataSize(),vertexData.array->getDataType(),0,vertexData.array->getDataPointer()); \ - } \ - } \ - else \ - disableVertexPointer(); + ArrayList arrays; + if (getArrayList(arrays)) + { + for(ArrayList::iterator itr = arrays.begin(); + itr != arrays.end(); + ++itr) + { + (*itr)->resizeGLObjectBuffers(maxSize); + } + } -#define SETNORMALPOINTER_IFPERVERTEXBINDING(vertexData, setVertexPointer, disableVertexPointer) \ - if( vertexData.array.valid() && vertexData.binding==BIND_PER_VERTEX) \ - { \ - new_vbo = vertexData.array.valid() ? vertexData.array->getVertexBufferObject() : 0; \ - if (new_vbo) \ - { \ - if (new_vbo!=prev_vbo) new_vbo->bindBuffer(contextID); \ - prev_vbo = new_vbo; \ - setVertexPointer(vertexData.array->getDataType(),0,new_vbo->getOffset(vertexData.array->getVertexBufferObjectIndex())); \ - } \ - else \ - { \ - extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); \ - prev_vbo = 0; \ - setVertexPointer(vertexData.array->getDataType(),0,vertexData.array->getDataPointer()); \ - } \ - } \ - else \ - disableVertexPointer(); + DrawElementsList drawElements; + if (getDrawElementsList(drawElements)) + { + for(DrawElementsList::iterator itr = drawElements.begin(); + itr != drawElements.end(); + ++itr) + { + (*itr)->resizeGLObjectBuffers(maxSize); + } + } +} +void Geometry::releaseGLObjects(State* state) const +{ + Drawable::releaseGLObjects(state); -#define SETARRAYPOINTER_IFPERVERTEXBINDING(vertexData, setVertexPointer, disableVertexPointer) \ - if( vertexData.array.valid() && vertexData.binding==BIND_PER_VERTEX) \ - { \ - new_vbo = vertexData.array.valid() ? vertexData.array->getVertexBufferObject() : 0; \ - if (new_vbo) \ - { \ - if (new_vbo!=prev_vbo) new_vbo->bindBuffer(contextID); \ - prev_vbo = new_vbo; \ - setVertexPointer(vertexData.array->getDataSize(),vertexData.array->getDataType(),0,new_vbo->getOffset(vertexData.array->getVertexBufferObjectIndex())); \ - } \ - else \ - { \ - extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); \ - prev_vbo = 0; \ - setVertexPointer(vertexData.array->getDataSize(),vertexData.array->getDataType(),0,vertexData.array->getDataPointer()); \ - } \ - } \ - else \ - disableVertexPointer(); + ArrayList arrays; + if (getArrayList(arrays)) + { + for(ArrayList::iterator itr = arrays.begin(); + itr != arrays.end(); + ++itr) + { + (*itr)->releaseGLObjects(state); + } + } + DrawElementsList drawElements; + if (getDrawElementsList(drawElements)) + { + for(DrawElementsList::iterator itr = drawElements.begin(); + itr != drawElements.end(); + ++itr) + { + (*itr)->releaseGLObjects(state); + } + } -#define SETARRAYUNITPOINTER_IFPERVERTEXBINDING(vertexData, unit, setVertexPointer, disableVertexPointer) \ - if( vertexData.array.valid() && vertexData.binding==BIND_PER_VERTEX) \ - { \ - new_vbo = vertexData.array.valid() ? vertexData.array->getVertexBufferObject() : 0; \ - if (new_vbo) \ - { \ - if (new_vbo!=prev_vbo) new_vbo->bindBuffer(contextID); \ - prev_vbo = new_vbo; \ - setVertexPointer(unit, vertexData.array->getDataSize(),vertexData.array->getDataType(),0,new_vbo->getOffset(vertexData.array->getVertexBufferObjectIndex())); \ - } \ - else \ - { \ - extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0); \ - prev_vbo = 0; \ - setVertexPointer(unit, vertexData.array->getDataSize(),vertexData.array->getDataType(),0,vertexData.array->getDataPointer()); \ - } \ - } \ - else \ - disableVertexPointer(); - +} void Geometry::drawImplementation(RenderInfo& renderInfo) const { diff --git a/src/osg/PrimitiveSet.cpp b/src/osg/PrimitiveSet.cpp index b4f669899..3ab5f00a2 100644 --- a/src/osg/PrimitiveSet.cpp +++ b/src/osg/PrimitiveSet.cpp @@ -121,35 +121,6 @@ DrawElementsUByte::~DrawElementsUByte() releaseGLObjects(); } -void DrawElementsUByte::resizeGLObjectBuffers(unsigned int maxSize) -{ - _vboList.resize(maxSize); -} - -void DrawElementsUByte::releaseGLObjects(State* state) const -{ - if (state) - { - unsigned int contextID = state->getContextID(); - if (_vboList[contextID]._objectID != 0) - { - BufferObject::deleteBufferObject(contextID,_vboList[contextID]._objectID); - _vboList[contextID]._objectID = 0; - } - } - else - { - for(unsigned int i=0;i<_vboList.size();++i) - { - if (_vboList[i]._objectID != 0) - { - BufferObject::deleteBufferObject(i,_vboList[i]._objectID); - _vboList[i]._objectID = 0; - } - } - } -} - void DrawElementsUByte::draw(State& state, bool useVertexBufferObjects) const { if (useVertexBufferObjects) @@ -158,7 +129,7 @@ void DrawElementsUByte::draw(State& state, bool useVertexBufferObjects) const state.bindElementBufferObject(ebo); if (ebo) { - glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, ebo->getOffset(getElementBufferObjectIndex())); + glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, getElementBufferObjectOffset()); } else { @@ -197,35 +168,6 @@ DrawElementsUShort::~DrawElementsUShort() releaseGLObjects(); } -void DrawElementsUShort::resizeGLObjectBuffers(unsigned int maxSize) -{ - _vboList.resize(maxSize); -} - -void DrawElementsUShort::releaseGLObjects(State* state) const -{ - if (state) - { - unsigned int contextID = state->getContextID(); - if (_vboList[contextID]._objectID != 0) - { - BufferObject::deleteBufferObject(contextID,_vboList[contextID]._objectID); - _vboList[contextID]._objectID = 0; - } - } - else - { - for(unsigned int i=0;i<_vboList.size();++i) - { - if (_vboList[i]._objectID != 0) - { - BufferObject::deleteBufferObject(i,_vboList[i]._objectID); - _vboList[i]._objectID = 0; - } - } - } -} - void DrawElementsUShort::draw(State& state, bool useVertexBufferObjects) const { if (useVertexBufferObjects) @@ -234,7 +176,7 @@ void DrawElementsUShort::draw(State& state, bool useVertexBufferObjects) const state.bindElementBufferObject(ebo); if (ebo) { - glDrawElements(_mode, size(), GL_UNSIGNED_SHORT, ebo->getOffset(getElementBufferObjectIndex())); + glDrawElements(_mode, size(), GL_UNSIGNED_SHORT, getElementBufferObjectOffset()); } else { @@ -273,35 +215,6 @@ DrawElementsUInt::~DrawElementsUInt() releaseGLObjects(); } -void DrawElementsUInt::resizeGLObjectBuffers(unsigned int maxSize) -{ - _vboList.resize(maxSize); -} - -void DrawElementsUInt::releaseGLObjects(State* state) const -{ - if (state) - { - unsigned int contextID = state->getContextID(); - if (_vboList[contextID]._objectID != 0) - { - BufferObject::deleteBufferObject(contextID,_vboList[contextID]._objectID); - _vboList[contextID]._objectID = 0; - } - } - else - { - for(unsigned int i=0;i<_vboList.size();++i) - { - if (_vboList[i]._objectID != 0) - { - BufferObject::deleteBufferObject(i,_vboList[i]._objectID); - _vboList[i]._objectID = 0; - } - } - } -} - void DrawElementsUInt::draw(State& state, bool useVertexBufferObjects) const { if (useVertexBufferObjects) @@ -310,7 +223,7 @@ void DrawElementsUInt::draw(State& state, bool useVertexBufferObjects) const state.bindElementBufferObject(ebo); if (ebo) { - glDrawElements(_mode, size(), GL_UNSIGNED_INT, ebo->getOffset(getElementBufferObjectIndex())); + glDrawElements(_mode, size(), GL_UNSIGNED_INT, getElementBufferObjectOffset()); } else { diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index 803adab6e..4c44fd77b 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -907,8 +907,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima const PixelBufferObject* pbo = image->getPixelBufferObject(); if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale) { - pbo->compileBuffer(contextID, state); - pbo->bindBuffer(contextID); + state.bindPixelBufferObject(pbo); dataMinusOffset = data; dataPlusOffset = reinterpret_cast(pbo->offset()); #ifdef DO_TIMING @@ -1043,8 +1042,9 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima if (pbo) { - pbo->unbindBuffer(contextID); + state.unbindPixelBufferObject(); } + #ifdef DO_TIMING static double s_total_time = 0.0; double delta_time = osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick()); @@ -1159,8 +1159,7 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image* const PixelBufferObject* pbo = image->getPixelBufferObject(); if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale) { - pbo->compileBuffer(contextID, state); - pbo->bindBuffer(contextID); + state.bindPixelBufferObject(pbo); dataMinusOffset = data; dataPlusOffset = reinterpret_cast(pbo->offset()); #ifdef DO_TIMING @@ -1277,7 +1276,7 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image* if (pbo) { - pbo->unbindBuffer(contextID); + state.unbindPixelBufferObject(); } #ifdef DO_TIMING osg::notify(osg::NOTICE)<<"glTexSubImage2D "<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<getPixelBufferObject(); if (pbo && pbo->isPBOSupported(contextID)) { - pbo->compileBuffer(contextID, state); - pbo->bindBuffer(contextID); + state.bindPixelBufferObject(pbo); dataMinusOffset = image->data(); dataPlusOffset = reinterpret_cast(pbo->offset()); } @@ -305,7 +304,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st if (pbo) { - pbo->unbindBuffer(contextID); + state.unbindPixelBufferObject(); } inwidth = image->s(); @@ -352,8 +351,7 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& const PixelBufferObject* pbo = image->getPixelBufferObject(); if (pbo && pbo->isPBOSupported(contextID)) { - pbo->compileBuffer(contextID, state); - pbo->bindBuffer(contextID); + state.bindPixelBufferObject(pbo); dataMinusOffset = image->data(); dataPlusOffset = reinterpret_cast(pbo->offset()); // -dataMinusOffset+dataPlusOffset @@ -378,7 +376,7 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& if (pbo) { - pbo->unbindBuffer(contextID); + state.unbindPixelBufferObject(); } #ifdef DO_TIMING diff --git a/src/osgWrappers/osg/Array.cpp b/src/osgWrappers/osg/Array.cpp index 67f23e694..9227c9384 100644 --- a/src/osgWrappers/osg/Array.cpp +++ b/src/osgWrappers/osg/Array.cpp @@ -169,15 +169,15 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Array) __C5_osg_VertexBufferObject_P1__getVertexBufferObject, "Get the const VertexBufferObject. ", "If no VBO is assigned returns NULL "); - I_Method1(void, setVertexBufferObjectIndex, IN, unsigned int, index, + I_Method1(void, setVertexBufferObjectOffset, IN, const GLvoid *, offset, Properties::NON_VIRTUAL, - __void__setVertexBufferObjectIndex__unsigned_int, - "Set the index into the VertexBufferObject, if used. ", + __void__setVertexBufferObjectOffset__C5_GLvoid_P1, + "Set the offset into the VertexBufferObject, if used. ", ""); - I_Method0(unsigned int, getVertexBufferObjectIndex, + I_Method0(const GLvoid *, getVertexBufferObjectOffset, Properties::NON_VIRTUAL, - __unsigned_int__getVertexBufferObjectIndex, - "Get the index into the VertexBufferObject, if used. ", + __C5_GLvoid_P1__getVertexBufferObjectOffset, + "Get the offset into the VertexBufferObject, if used. ", ""); I_SimpleProperty(const GLvoid *, DataPointer, __C5_GLvoid_P1__getDataPointer, @@ -200,9 +200,9 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Array) I_SimpleProperty(osg::VertexBufferObject *, VertexBufferObject, __osg_VertexBufferObject_P1__getVertexBufferObject, __void__setVertexBufferObject__osg_VertexBufferObject_P1); - I_SimpleProperty(unsigned int, VertexBufferObjectIndex, - __unsigned_int__getVertexBufferObjectIndex, - __void__setVertexBufferObjectIndex__unsigned_int); + I_SimpleProperty(const GLvoid *, VertexBufferObjectOffset, + __C5_GLvoid_P1__getVertexBufferObjectOffset, + __void__setVertexBufferObjectOffset__C5_GLvoid_P1); END_REFLECTOR BEGIN_VALUE_REFLECTOR(osg::ArrayVisitor) diff --git a/src/osgWrappers/osg/BufferObject.cpp b/src/osgWrappers/osg/BufferObject.cpp index 7c744591d..48042fde4 100644 --- a/src/osgWrappers/osg/BufferObject.cpp +++ b/src/osgWrappers/osg/BufferObject.cpp @@ -85,26 +85,21 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::BufferObject) __bool__isDirty__unsigned_int, "", ""); - I_Method1(bool, needsCompile, IN, unsigned int, contextID, + I_Method1(void, compileBuffer, IN, osg::State &, state, Properties::PURE_VIRTUAL, - __bool__needsCompile__unsigned_int, + __void__compileBuffer__State_R1, "", ""); - I_Method2(void, compileBuffer, IN, unsigned int, contextID, IN, osg::State &, state, - Properties::NON_VIRTUAL, - __void__compileBuffer__unsigned_int__State_R1, - "", - ""); - I_Method1(void, compileBufferImplementation, IN, osg::State &, state, - Properties::PURE_VIRTUAL, - __void__compileBufferImplementation__State_R1, - "", - ""); - I_Method1(void, releaseBuffer, IN, osg::State *, state, - Properties::NON_VIRTUAL, - __void__releaseBuffer__State_P1, - "", + I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, + Properties::VIRTUAL, + __void__resizeGLObjectBuffers__unsigned_int, + "Resize any per context GLObject buffers to specified size. ", ""); + I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0, + Properties::VIRTUAL, + __void__releaseGLObjects__State_P1, + "If State is non-zero, this function releases OpenGL objects for the specified graphics context. ", + "Otherwise, releases OpenGL objexts for all graphics contexts. "); I_StaticMethod2(void, deleteBufferObject, IN, unsigned int, contextID, IN, GLuint, globj, __void__deleteBufferObject__unsigned_int__GLuint_S, "Use deleteVertexBufferObject instead of glDeleteBuffers to allow OpenGL buffer objects to be cached until they can be deleted by the OpenGL context in which they were created, specified by contextID. ", @@ -279,6 +274,11 @@ BEGIN_OBJECT_REFLECTOR(osg::ElementBufferObject) __unsigned_int__addDrawElements__osg_DrawElements_P1, "", ""); + I_Method1(void, removeDrawElements, IN, osg::DrawElements *, PrimitiveSet, + Properties::NON_VIRTUAL, + __void__removeDrawElements__osg_DrawElements_P1, + "", + ""); I_Method2(void, setDrawElements, IN, unsigned int, i, IN, osg::DrawElements *, PrimitiveSet, Properties::NON_VIRTUAL, __void__setDrawElements__unsigned_int__DrawElements_P1, @@ -299,15 +299,15 @@ BEGIN_OBJECT_REFLECTOR(osg::ElementBufferObject) __C5_GLvoid_P1__getOffset__unsigned_int, "", ""); - I_Method1(bool, needsCompile, IN, unsigned int, contextID, + I_Method1(void, compileBuffer, IN, osg::State &, state, Properties::VIRTUAL, - __bool__needsCompile__unsigned_int, + __void__compileBuffer__State_R1, "", ""); - I_Method1(void, compileBufferImplementation, IN, osg::State &, state, + I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, Properties::VIRTUAL, - __void__compileBufferImplementation__State_R1, - "", + __void__resizeGLObjectBuffers__unsigned_int, + "Resize any per context GLObject buffers to specified size. ", ""); I_IndexedProperty(osg::DrawElements *, DrawElements, __DrawElements_P1__getDrawElements__unsigned_int, @@ -373,15 +373,15 @@ BEGIN_OBJECT_REFLECTOR(osg::PixelBufferObject) __unsigned_int__offset, "", ""); - I_Method1(bool, needsCompile, IN, unsigned int, contextID, + I_Method1(void, compileBuffer, IN, osg::State &, state, Properties::VIRTUAL, - __bool__needsCompile__unsigned_int, + __void__compileBuffer__State_R1, "", ""); - I_Method1(void, compileBufferImplementation, IN, osg::State &, state, + I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, Properties::VIRTUAL, - __void__compileBufferImplementation__State_R1, - "", + __void__resizeGLObjectBuffers__unsigned_int, + "Resize any per context GLObject buffers to specified size. ", ""); I_SimpleProperty(osg::Image *, Image, __Image_P1__getImage, @@ -431,6 +431,11 @@ BEGIN_OBJECT_REFLECTOR(osg::VertexBufferObject) __unsigned_int__addArray__osg_Array_P1, "", ""); + I_Method1(void, removeArray, IN, osg::Array *, array, + Properties::NON_VIRTUAL, + __void__removeArray__osg_Array_P1, + "", + ""); I_Method2(void, setArray, IN, unsigned int, i, IN, osg::Array *, array, Properties::NON_VIRTUAL, __void__setArray__unsigned_int__Array_P1, @@ -451,15 +456,15 @@ BEGIN_OBJECT_REFLECTOR(osg::VertexBufferObject) __C5_GLvoid_P1__getOffset__unsigned_int, "", ""); - I_Method1(bool, needsCompile, IN, unsigned int, contextID, + I_Method1(void, compileBuffer, IN, osg::State &, state, Properties::VIRTUAL, - __bool__needsCompile__unsigned_int, + __void__compileBuffer__State_R1, "", ""); - I_Method1(void, compileBufferImplementation, IN, osg::State &, state, + I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, Properties::VIRTUAL, - __void__compileBufferImplementation__State_R1, - "", + __void__resizeGLObjectBuffers__unsigned_int, + "Resize any per context GLObject buffers to specified size. ", ""); I_IndexedProperty(osg::Array *, Array, __Array_P1__getArray__unsigned_int, diff --git a/src/osgWrappers/osg/Geometry.cpp b/src/osgWrappers/osg/Geometry.cpp index b5eaa807e..045ad5231 100644 --- a/src/osgWrappers/osg/Geometry.cpp +++ b/src/osgWrappers/osg/Geometry.cpp @@ -18,6 +18,7 @@ #include #include #include +#include // Must undefine IN and OUT macros defined in Windows headers #ifdef IN @@ -562,6 +563,16 @@ BEGIN_OBJECT_REFLECTOR(osg::Geometry) __void__dirtyDisplayList, "Force a recompile on next draw() of any OpenGL display list associated with this geoset. ", ""); + I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, + Properties::VIRTUAL, + __void__resizeGLObjectBuffers__unsigned_int, + "Resize any per context GLObject buffers to specified size. ", + ""); + I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0, + Properties::VIRTUAL, + __void__releaseGLObjects__State_P1, + "If State is non-zero, this function releases OpenGL objects for the specified graphics context. ", + "Otherwise, releases OpenGL objexts for all graphics contexts. "); I_Method1(bool, getArrayList, IN, osg::Geometry::ArrayList &, arrayList, Properties::NON_VIRTUAL, __bool__getArrayList__ArrayList_R1, @@ -901,7 +912,6 @@ BEGIN_VALUE_REFLECTOR(osg::Geometry::ArrayData) I_PublicMemberProperty(osg::ref_ptr< osg::IndexArray >, indices); I_PublicMemberProperty(osg::Geometry::AttributeBinding, binding); I_PublicMemberProperty(GLboolean, normalize); - I_PublicMemberProperty(unsigned long, offset); END_REFLECTOR BEGIN_VALUE_REFLECTOR(osg::Geometry::Vec3ArrayData) @@ -929,7 +939,6 @@ BEGIN_VALUE_REFLECTOR(osg::Geometry::Vec3ArrayData) I_PublicMemberProperty(osg::ref_ptr< osg::IndexArray >, indices); I_PublicMemberProperty(osg::Geometry::AttributeBinding, binding); I_PublicMemberProperty(GLboolean, normalize); - I_PublicMemberProperty(unsigned long, offset); END_REFLECTOR BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osg::PrimitiveSet >) diff --git a/src/osgWrappers/osg/PrimitiveSet.cpp b/src/osgWrappers/osg/PrimitiveSet.cpp index b26ee881b..8b5143924 100644 --- a/src/osgWrappers/osg/PrimitiveSet.cpp +++ b/src/osgWrappers/osg/PrimitiveSet.cpp @@ -271,25 +271,35 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::DrawElements) __C5_osg_ElementBufferObject_P1__getElementBufferObject, "Get the const ElementBufferObject. ", "If no EBO is assigned returns NULL "); - I_Method1(void, setElementBufferObjectIndex, IN, unsigned int, index, + I_Method1(void, setElementBufferObjectOffset, IN, const GLvoid *, offset, Properties::NON_VIRTUAL, - __void__setElementBufferObjectIndex__unsigned_int, - "Set the index into the ElementBufferObject, if used. ", + __void__setElementBufferObjectOffset__C5_GLvoid_P1, + "Set the offset into the ElementBufferObject, if used. ", ""); - I_Method0(unsigned int, getElementBufferObjectIndex, + I_Method0(const GLvoid *, getElementBufferObjectOffset, Properties::NON_VIRTUAL, - __unsigned_int__getElementBufferObjectIndex, - "Get the index into the ElementBufferObject, if used. ", + __C5_GLvoid_P1__getElementBufferObjectOffset, + "Get the offset into the ElementBufferOffset, if used. ", ""); + I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, + Properties::VIRTUAL, + __void__resizeGLObjectBuffers__unsigned_int, + "Resize any per context GLObject buffers to specified size. ", + ""); + I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0, + Properties::VIRTUAL, + __void__releaseGLObjects__State_P1, + "If State is non-zero, this function releases OpenGL objects for the specified graphics context. ", + "Otherwise, releases OpenGL objexts for all graphics contexts. "); I_SimpleProperty(osg::DrawElements *, DrawElements, __DrawElements_P1__getDrawElements, 0); I_SimpleProperty(osg::ElementBufferObject *, ElementBufferObject, __osg_ElementBufferObject_P1__getElementBufferObject, __void__setElementBufferObject__osg_ElementBufferObject_P1); - I_SimpleProperty(unsigned int, ElementBufferObjectIndex, - __unsigned_int__getElementBufferObjectIndex, - __void__setElementBufferObjectIndex__unsigned_int); + I_SimpleProperty(const GLvoid *, ElementBufferObjectOffset, + __C5_GLvoid_P1__getElementBufferObjectOffset, + __void__setElementBufferObjectOffset__C5_GLvoid_P1); END_REFLECTOR TYPE_NAME_ALIAS(osg::VectorGLubyte, osg::DrawElementsUByte::vector_type) @@ -384,16 +394,6 @@ BEGIN_OBJECT_REFLECTOR(osg::DrawElementsUByte) __void__offsetIndices__int, "", ""); - I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, - Properties::VIRTUAL, - __void__resizeGLObjectBuffers__unsigned_int, - "Resize any per context GLObject buffers to specified size. ", - ""); - I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0, - Properties::VIRTUAL, - __void__releaseGLObjects__State_P1, - "If State is non-zero, this function releases OpenGL objects for the specified graphics context. ", - "Otherwise, releases OpenGL objexts for all graphics contexts. "); I_Method0(void, computeRange, Properties::VIRTUAL, __void__computeRange, @@ -499,16 +499,6 @@ BEGIN_OBJECT_REFLECTOR(osg::DrawElementsUInt) __void__offsetIndices__int, "", ""); - I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, - Properties::VIRTUAL, - __void__resizeGLObjectBuffers__unsigned_int, - "Resize any per context GLObject buffers to specified size. ", - ""); - I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0, - Properties::VIRTUAL, - __void__releaseGLObjects__State_P1, - "If State is non-zero, this function releases OpenGL objects for the specified graphics context. ", - "Otherwise, releases OpenGL objexts for all graphics contexts. "); I_Method0(void, computeRange, Properties::VIRTUAL, __void__computeRange, @@ -614,16 +604,6 @@ BEGIN_OBJECT_REFLECTOR(osg::DrawElementsUShort) __void__offsetIndices__int, "", ""); - I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, - Properties::VIRTUAL, - __void__resizeGLObjectBuffers__unsigned_int, - "Resize any per context GLObject buffers to specified size. ", - ""); - I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, state, 0, - Properties::VIRTUAL, - __void__releaseGLObjects__State_P1, - "If State is non-zero, this function releases OpenGL objects for the specified graphics context. ", - "Otherwise, releases OpenGL objexts for all graphics contexts. "); I_Method0(void, computeRange, Properties::VIRTUAL, __void__computeRange,