diff --git a/examples/osgparametric/osgparametric.cpp b/examples/osgparametric/osgparametric.cpp index 2fcd58911..b10a56422 100644 --- a/examples/osgparametric/osgparametric.cpp +++ b/examples/osgparametric/osgparametric.cpp @@ -106,7 +106,7 @@ class UniformVarying : public osg::Uniform::Callback } }; -osg::Node* createModel(const std::string& shader, const std::string& textureFileName, const std::string& terrainFileName, bool dynamic, bool vbo) +osg::Node* createModel(const std::string& shader, const std::string& textureFileName, const std::string& terrainFileName, bool dynamic, bool useVBO) { osg::Geode* geode = new osg::Geode; @@ -238,10 +238,10 @@ osg::Node* createModel(const std::string& shader, const std::string& textureFile geom->setVertexArray(vertices); - osg::VertexBufferObject* vbObject = new osg::VertexBufferObject; - vertices->setVertexBufferObject(vbObject); + osg::VertexBufferObject* vbo = useVBO ? new osg::VertexBufferObject : 0; + if (vbo) vertices->setVertexBufferObject(vbo); - osg::ElementBufferObject* ebo = new osg::ElementBufferObject; + osg::ElementBufferObject* ebo = useVBO ? new osg::ElementBufferObject : 0; for(iy=0; iyaddPrimitiveSet(elements); - if (ebo) elements->setElementBufferObject(ebo); + if (ebo) elements->setElementBufferObject(ebo); } geom->setUseVertexBufferObjects(vbo); diff --git a/examples/osgscreencapture/osgscreencapture.cpp b/examples/osgscreencapture/osgscreencapture.cpp index ddb41032a..f4d3a1b8e 100644 --- a/examples/osgscreencapture/osgscreencapture.cpp +++ b/examples/osgscreencapture/osgscreencapture.cpp @@ -137,7 +137,7 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback void read() { - osg::BufferObject::Extensions* ext = osg::BufferObject::getExtensions(_gc->getState()->getContextID(),true); + osg::GLBufferObject::Extensions* ext = osg::GLBufferObject::getExtensions(_gc->getState()->getContextID(),true); if (ext->isPBOSupported() && !_pboBuffer.empty()) { @@ -158,9 +158,9 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback void readPixels(); - void singlePBO(osg::BufferObject::Extensions* ext); + void singlePBO(osg::GLBufferObject::Extensions* ext); - void multiPBO(osg::BufferObject::Extensions* ext); + void multiPBO(osg::GLBufferObject::Extensions* ext); typedef std::vector< osg::ref_ptr > ImageBuffer; typedef std::vector< GLuint > PBOBuffer; @@ -325,7 +325,7 @@ void WindowCaptureCallback::ContextData::readPixels() _currentPboIndex = nextPboIndex; } -void WindowCaptureCallback::ContextData::singlePBO(osg::BufferObject::Extensions* ext) +void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensions* ext) { // std::cout<<"singelPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<(obj)!=NULL; } virtual const char* libraryName() const { return "osg"; } @@ -113,61 +109,22 @@ class OSG_EXPORT Array : public Object /** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/ virtual void trim() {} - /** Dirty the primitive, which increments the modified count, to force buffer objects to update. */ - inline void dirty() { ++_modifiedCount; if (_vbo.valid()) _vbo->dirty(); } - - /** Set the modified count value.*/ - inline void setModifiedCount(unsigned int value) { _modifiedCount=value; } - - /** Get modified count value.*/ - inline unsigned int getModifiedCount() const { return _modifiedCount; } - /** Set the VertexBufferObject.*/ - inline void setVertexBufferObject(osg::VertexBufferObject* vbo) - { - if (_vbo == vbo) return; - - if (_vbo.valid()) - { - _vbo->removeArray(this); - } - - _vbo = vbo; - - if (_vbo.valid()) - { - _vbo->addArray(this); - } - } - + inline void setVertexBufferObject(osg::VertexBufferObject* vbo) { setBufferObject(vbo); } + /** Get the VertexBufferObject. If no VBO is assigned returns NULL*/ - inline osg::VertexBufferObject* getVertexBufferObject() { return _vbo.get(); } + inline osg::VertexBufferObject* getVertexBufferObject() { return dynamic_cast(_bufferObject.get()); } /** Get the const VertexBufferObject. If no VBO is assigned returns NULL*/ - inline const osg::VertexBufferObject* getVertexBufferObject() const { return _vbo.get(); } - - /** Set the offset into the VertexBufferObject, if used.*/ - void setVertexBufferObjectOffset(const GLvoid* offset ) const { _vboOffset = offset; } - - /** Get the offset into the VertexBufferObject, if used.*/ - const GLvoid* getVertexBufferObjectOffset() const { return _vboOffset; } + inline const osg::VertexBufferObject* getVertexBufferObject() const { return dynamic_cast(_bufferObject.get()); } protected: - - virtual ~Array() - { - if (_vbo.valid()) - { - _vbo->removeArray(this); - } - } + + virtual ~Array() {} Type _arrayType; GLint _dataSize; GLenum _dataType; - unsigned int _modifiedCount; - osg::ref_ptr _vbo; - mutable const GLvoid* _vboOffset; }; template diff --git a/include/osg/BufferObject b/include/osg/BufferObject index 8bcf492da..9a7aa9211 100644 --- a/include/osg/BufferObject +++ b/include/osg/BufferObject @@ -99,72 +99,75 @@ namespace osg { class State; +class BufferData; +class BufferObject; -class OSG_EXPORT BufferObject : public Object +class OSG_EXPORT GLBufferObject : public Referenced { public: - BufferObject(); + GLBufferObject(unsigned int contextID, BufferObject* bufferObject=0); - /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ - BufferObject(const BufferObject& bo,const CopyOp& copyop=CopyOp::SHALLOW_COPY); - - virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } - virtual const char* libraryName() const { return "osg"; } - virtual const char* className() const { return "BufferObject"; } - - /** Set what type of usage the buffer object will have. Options are: - * GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, - * GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, - * GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY. - */ - void setUsage(GLenum usage) { _usage = usage; } - - /** Get the type of usage the buffer object has been set up for.*/ - GLenum getUsage() const { return _usage; } + void setBufferObject(BufferObject* bufferObject); + BufferObject* getBufferObject() { return _bufferObject; } struct BufferEntry { - BufferEntry(): dataSize(0),offset(0) {} - BufferEntry(const BufferEntry& be): modifiedCount(be.modifiedCount),dataSize(be.dataSize),offset(be.offset) {} - - BufferEntry& operator = (const BufferEntry& be) { modifiedCount=be.modifiedCount; dataSize=be.dataSize; offset=be.offset; return *this; } + BufferEntry(): modifiedCount(0),dataSize(0),offset(0),dataSource(0) {} - mutable buffered_value modifiedCount; - mutable unsigned int dataSize; - mutable unsigned int offset; + BufferEntry(const BufferEntry& rhs): + modifiedCount(rhs.modifiedCount), + dataSize(rhs.dataSize), + offset(rhs.offset), + dataSource(rhs.dataSource) {} + + BufferEntry& operator = (const BufferEntry& rhs) + { + if (&rhs==this) return *this; + modifiedCount = rhs.modifiedCount; + dataSize = rhs.dataSize; + offset = rhs.offset; + dataSource = rhs.dataSource; + return *this; + } + + unsigned int modifiedCount; + GLsizeiptrARB dataSize; + GLsizeiptrARB offset; + BufferData* dataSource; }; - inline bool isBufferObjectSupported(unsigned int contextID) const { return getExtensions(contextID,true)->isBufferObjectSupported(); } - inline bool isPBOSupported(unsigned int contextID) const { return getExtensions(contextID,true)->isPBOSupported(); } + inline unsigned int getContextID() const { return _contextID; } - inline GLuint& buffer(unsigned int contextID) const { return _bufferObjectList[contextID]; } - - inline void bindBuffer(unsigned int contextID) const + inline GLuint& getGLObjectID() { return _glObjectID; } + inline GLuint getGLObjectID() const { return _glObjectID; } + inline GLsizeiptrARB getOffset(unsigned int i) const { return _bufferEntries[i].offset; } + + inline void bindBuffer() const { - Extensions* extensions = getExtensions(contextID,true); - extensions->glBindBuffer(_target,_bufferObjectList[contextID]); + _extensions->glBindBuffer(_target,_glObjectID); } - virtual void unbindBuffer(unsigned int contextID) const + inline void unbindBuffer() const { - Extensions* extensions = getExtensions(contextID,true); - extensions->glBindBuffer(_target,0); + _extensions->glBindBuffer(_target,0); } - inline void dirty() { _compiledList.setAllElementsTo(0); } + inline bool isDirty() const { return _dirty; } - bool isDirty(unsigned int contextID) const { return _compiledList[contextID]==0; } + void dirty() { _dirty = true; } - virtual void compileBuffer(State& state) const = 0; - - /** Resize any per context GLObject buffers to specified size. */ - virtual void resizeGLObjectBuffers(unsigned int maxSize); + void clear(); - /** If State is non-zero, this function releases OpenGL objects for - * the specified graphics context. Otherwise, releases OpenGL objects - * for all graphics contexts. */ - void releaseGLObjects(State* state=0) const; + void compileBuffer(); + + void deleteGLObject(); + + void assign(BufferObject* bufferObject); + + bool isPBOSupported() const { return _extensions->isPBOSupported(); } + + static GLBufferObject* createGLBufferObject(unsigned int contextID, const BufferObject* bufferObject); /** Use deleteVertexBufferObject instead of glDeleteBuffers to allow @@ -256,19 +259,148 @@ class OSG_EXPORT BufferObject : public Object protected: - virtual ~BufferObject(); - - typedef osg::buffered_value GLObjectList; - typedef osg::buffered_value CompiledList; + virtual ~GLBufferObject(); - mutable GLObjectList _bufferObjectList; - mutable CompiledList _compiledList; + unsigned int _contextID; + GLuint _glObjectID; GLenum _target; GLenum _usage; + + bool _dirty; + mutable unsigned int _totalSize; + + typedef std::vector BufferEntries; + BufferEntries _bufferEntries; + + BufferObject* _bufferObject; + + public: + Extensions* _extensions; + }; +class OSG_EXPORT BufferObject : public Object +{ + public: + + BufferObject(); + + /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ + BufferObject(const BufferObject& bo,const CopyOp& copyop=CopyOp::SHALLOW_COPY); + + virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } + virtual const char* libraryName() const { return "osg"; } + virtual const char* className() const { return "BufferObject"; } + + void setTarget(GLenum target) { _target = target; } + GLenum getTarget() const { return _target; } + + /** Set what type of usage the buffer object will have. Options are: + * GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, + * GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, + * GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY. + */ + void setUsage(GLenum usage) { _usage = usage; } + + /** Get the type of usage the buffer object has been set up for.*/ + GLenum getUsage() const { return _usage; } + + void dirty(); + + /** 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 objects + * for all graphics contexts. */ + void releaseGLObjects(State* state=0) const; + + unsigned int addBufferData(BufferData* bd); + void removeBufferData(unsigned int index); + void removeBufferData(BufferData* bd); + + void setBufferData(unsigned int index, BufferData* bd); + BufferData* getBufferData(unsigned int index) { return _bufferDataList[index]; } + const BufferData* getBufferData(unsigned int index) const { return _bufferDataList[index]; } + + unsigned int getNumBufferData() const { return _bufferDataList.size(); } + + GLBufferObject* getGLBufferObject(unsigned int contextID) const { return _glBufferObjects[contextID].get(); } + + GLBufferObject* getOrCreateGLBufferObject(unsigned int contextID) const + { + if (!_glBufferObjects[contextID]) _glBufferObjects[contextID] = GLBufferObject::createGLBufferObject(contextID, this); + return _glBufferObjects[contextID].get(); + } + + protected: + + ~BufferObject(); + + typedef std::vector< BufferData* > BufferDataList; + typedef osg::buffered_object< osg::ref_ptr > GLBufferObjects; + + GLenum _target; + GLenum _usage; + BufferDataList _bufferDataList; + + mutable GLBufferObjects _glBufferObjects; +}; + +class BufferData : public Object +{ + public: + + BufferData(): + Object(true), + _modifiedCount(0), + _bufferIndex(0) {} + + /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ + BufferData(const BufferData& bd,const CopyOp& copyop=CopyOp::SHALLOW_COPY): + osg::Object(bd,copyop), + _modifiedCount(0), + _bufferIndex(0) {} + + virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } + virtual const char* libraryName() const { return "osg"; } + virtual const char* className() const { return "BufferData"; } + + virtual const GLvoid* getDataPointer() const = 0; + virtual unsigned int getTotalDataSize() const = 0; + + void setBufferObject(BufferObject* bufferObject); + BufferObject* getBufferObject() { return _bufferObject.get(); } + const BufferObject* getBufferObject() const { return _bufferObject.get(); } + + void setBufferIndex(unsigned int index) { _bufferIndex = index; } + unsigned int getBufferIndex() const { return _bufferIndex; } + + GLBufferObject* getGLBufferObject(unsigned int contextID) const { return _bufferObject.valid() ? _bufferObject->getGLBufferObject(contextID) : 0; } + GLBufferObject* getOrCreateGLBufferObject(unsigned int contextID) const { return _bufferObject.valid() ? _bufferObject->getOrCreateGLBufferObject(contextID) : 0; } + + /** Dirty the primitive, which increments the modified count, to force buffer objects to update. */ + inline void dirty() { ++_modifiedCount; if (_bufferObject.valid()) _bufferObject->dirty(); } + + /** Set the modified count value.*/ + inline void setModifiedCount(unsigned int value) { _modifiedCount=value; } + + /** Get modified count value.*/ + inline unsigned int getModifiedCount() const { return _modifiedCount; } + + protected: + + virtual ~BufferData(); + + unsigned int _modifiedCount; + + unsigned int _bufferIndex; + osg::ref_ptr _bufferObject; +}; + + class Array; class OSG_EXPORT VertexBufferObject : public BufferObject { @@ -280,29 +412,16 @@ class OSG_EXPORT VertexBufferObject : public BufferObject VertexBufferObject(const VertexBufferObject& vbo,const CopyOp& copyop=CopyOp::SHALLOW_COPY); META_Object(osg,VertexBufferObject); - - typedef std::pair< BufferEntry, Array* > BufferEntryArrayPair; - 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; } - const Array* getArray(unsigned int i) const { return _bufferEntryArrayPairs[i].second; } - - const GLvoid* getOffset(unsigned int i) const { return (const GLvoid*)(((char *)0)+(_bufferEntryArrayPairs[i].first.offset)); } - - virtual void compileBuffer(State& state) const; - - /** Resize any per context GLObject buffers to specified size. */ - virtual void resizeGLObjectBuffers(unsigned int maxSize); + Array* getArray(unsigned int i); + const Array* getArray(unsigned int i) const; protected: - virtual ~VertexBufferObject(); - - BufferEntryArrayPairs _bufferEntryArrayPairs; }; class DrawElements; @@ -317,28 +436,16 @@ class OSG_EXPORT ElementBufferObject : public BufferObject META_Object(osg,ElementBufferObject); - typedef std::pair< BufferEntry, DrawElements* > BufferEntryDrawElementsPair; - typedef std::vector< BufferEntryDrawElementsPair > 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; } - const DrawElements* getDrawElements(unsigned int i) const { return _bufferEntryDrawElementsPairs[i].second; } - - const GLvoid* getOffset(unsigned int i) const { return (const GLvoid*)(((char *)0)+(_bufferEntryDrawElementsPairs[i].first.offset)); } - - virtual void compileBuffer(State& state) const; - - /** Resize any per context GLObject buffers to specified size. */ - virtual void resizeGLObjectBuffers(unsigned int maxSize); + DrawElements* getDrawElements(unsigned int i); + const DrawElements* getDrawElements(unsigned int i) const; protected: virtual ~ElementBufferObject(); - - BufferEntryDrawElementsPairs _bufferEntryDrawElementsPairs; }; class Image; @@ -352,26 +459,17 @@ class OSG_EXPORT PixelBufferObject : public BufferObject PixelBufferObject(const PixelBufferObject& pbo,const CopyOp& copyop=CopyOp::SHALLOW_COPY); META_Object(osg,PixelBufferObject); - - typedef std::pair< BufferEntry, Image* > BufferEntryImagePair; void setImage(osg::Image* image); - Image* getImage() { return _bufferEntryImagePair.second; } - const Image* getImage() const { return _bufferEntryImagePair.second; } - - unsigned int offset() const { return _bufferEntryImagePair.first.offset; } - - virtual void compileBuffer(State& state) const; + Image* getImage(); + const Image* getImage() const; - /** Resize any per context GLObject buffers to specified size. */ - virtual void resizeGLObjectBuffers(unsigned int maxSize); + bool isPBOSupported(unsigned int contextID) const { return _glBufferObjects[contextID]->isPBOSupported(); } protected: virtual ~PixelBufferObject(); - - BufferEntryImagePair _bufferEntryImagePair; }; /** @@ -389,10 +487,10 @@ class OSG_EXPORT PixelDataBufferObject : public BufferObject META_Object(osg, PixelDataBufferObject); //! Set new size of the buffer object. This will reallocate the memory on the next compile - inline void setDataSize(unsigned int size) { _bufferData.dataSize = size; dirty(); } + inline void setDataSize(unsigned int size) { _dataSize = size; dirty(); } //! Get data size of the used buffer - inline unsigned int getDataSize() { return _bufferData.dataSize; } + inline unsigned int getDataSize() const { return _dataSize; } //! Compile the buffer (reallocate the memory if buffer is dirty) virtual void compileBuffer(State& state) const; @@ -427,7 +525,7 @@ class OSG_EXPORT PixelDataBufferObject : public BufferObject virtual ~PixelDataBufferObject(); - BufferEntry _bufferData; + unsigned int _dataSize; typedef osg::buffered_value ModeList; diff --git a/include/osg/Image b/include/osg/Image index 07b81a297..f5fa39dc7 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -61,7 +61,7 @@ namespace osg { class NodeVisitor; /** Image class for encapsulating the storage texture image data. */ -class OSG_EXPORT Image : public Object +class OSG_EXPORT Image : public BufferData { public : @@ -77,6 +77,9 @@ class OSG_EXPORT Image : public Object virtual const char* libraryName() const { return "osg"; } virtual const char* className() const { return "Image"; } + virtual const GLvoid* getDataPointer() const { return data(); } + virtual unsigned int getTotalDataSize() const { return getTotalSizeInBytesIncludingMipmaps(); } + /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */ virtual int compare(const Image& rhs) const; @@ -252,16 +255,6 @@ class OSG_EXPORT Image : public Object * the host machine. */ void ensureValidSizeForTexturing(GLint maxTextureSize); - - /** Dirty the image, which increments the modified count, to force osg::Texture to reload the image. */ - inline void dirty() { ++_modifiedCount; if (_bufferObject.valid()) _bufferObject->dirty(); } - - /** Set the modified count value. Used by osg::Texture when using texture subloading. */ - inline void setModifiedCount(unsigned int value) { _modifiedCount=value; } - - /** Get modified count value. Used by osg::Texture when using texture subloading. */ - inline unsigned int getModifiedCount() const { return _modifiedCount; } - static bool isPackedType(GLenum type); static GLenum computePixelFormat(GLenum pixelFormat); @@ -316,15 +309,15 @@ class OSG_EXPORT Image : public Object virtual bool isImageTranslucent() const; /** Set the optional PixelBufferObject used to map the image memory efficiently to graphics memory. */ - void setPixelBufferObject(PixelBufferObject* buffer) { _bufferObject = buffer; if (_bufferObject.valid()) _bufferObject->setImage(this); } + void setPixelBufferObject(PixelBufferObject* buffer) { setBufferObject(buffer); } - /** Get the PixelBufferObject.*/ - PixelBufferObject* getPixelBufferObject() { return _bufferObject.get(); } + /** Get the PixelBufferObject.*/ + PixelBufferObject* getPixelBufferObject() { return dynamic_cast(_bufferObject.get()); } - /** Get the const PixelBufferObject.*/ - const PixelBufferObject* getPixelBufferObject() const { return _bufferObject.get(); } + /** Get the const PixelBufferObject.*/ + const PixelBufferObject* getPixelBufferObject() const { return dynamic_cast(_bufferObject.get()); } - virtual void update(NodeVisitor* /*nv*/) {} + virtual void update(NodeVisitor* /*nv*/) {} /** method for sending pointer events to images that are acting as front ends to interactive surfaces such as a vnc or browser window. Return true if handled. */ virtual bool sendPointerEvent(int /*x*/, int /*y*/, int /*buttonMask*/) { return false; } @@ -361,8 +354,6 @@ class OSG_EXPORT Image : public Object void setData(unsigned char* data,AllocationMode allocationMode); - unsigned int _modifiedCount; - MipmapDataType _mipmapData; ref_ptr _bufferObject; diff --git a/include/osg/PrimitiveSet b/include/osg/PrimitiveSet index 7f3f3c315..a7d2f0d37 100644 --- a/include/osg/PrimitiveSet +++ b/include/osg/PrimitiveSet @@ -147,7 +147,7 @@ public: class DrawElements; -class OSG_EXPORT PrimitiveSet : public Object +class OSG_EXPORT PrimitiveSet : public BufferData { public: @@ -179,15 +179,13 @@ class OSG_EXPORT PrimitiveSet : public Object _primitiveType(primType), _numInstances(numInstances), _mode(mode), - _modifiedCount(0), _rangeModifiedCount(0) {} PrimitiveSet(const PrimitiveSet& prim,const CopyOp& copyop=CopyOp::SHALLOW_COPY): - Object(prim,copyop), + BufferData(prim,copyop), _primitiveType(prim._primitiveType), _numInstances(prim._numInstances), _mode(prim._mode), - _modifiedCount(0), _rangeModifiedCount(0) {} virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast(obj)!=NULL; } @@ -219,23 +217,6 @@ class OSG_EXPORT PrimitiveSet : public Object virtual unsigned int getNumPrimitives() const; - /** Dirty the primitive, which increments the modified count, to force buffer objects to update. */ - virtual void dirty() { ++_modifiedCount; } - - /** Set the modified count value.*/ - inline void setModifiedCount(unsigned int value) { _modifiedCount=value; } - - /** Get modified count value.*/ - inline unsigned int getModifiedCount() const { return _modifiedCount; } - - /** 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 objects - * for all graphics contexts. */ - virtual void releaseGLObjects(State* /*state*/=0) const {} - virtual void computeRange() const {} protected: @@ -245,31 +226,7 @@ class OSG_EXPORT PrimitiveSet : public Object Type _primitiveType; int _numInstances; GLenum _mode; - unsigned int _modifiedCount; mutable unsigned int _rangeModifiedCount; - - struct ObjectIDModifiedCountPair - { - ObjectIDModifiedCountPair(): - _objectID(0), - _modifiedCount(0) {} - - ObjectIDModifiedCountPair(const ObjectIDModifiedCountPair& obj): - _objectID(obj._objectID), - _modifiedCount(obj._modifiedCount) {} - - ObjectIDModifiedCountPair& operator = (const ObjectIDModifiedCountPair& obj) - { - _objectID = obj._objectID; - _modifiedCount = obj._modifiedCount; - return *this; - } - - GLuint _objectID; - unsigned int _modifiedCount; - }; - - typedef osg::buffered_object GLObjectList; }; class OSG_EXPORT DrawArrays : public PrimitiveSet @@ -392,83 +349,32 @@ class DrawElements : public PrimitiveSet public: DrawElements(Type primType=PrimitiveType, GLenum mode=0, int numInstances=0): - PrimitiveSet(primType,mode, numInstances), - _eboOffset(0) {} + PrimitiveSet(primType,mode, numInstances) {} DrawElements(const DrawElements& copy,const CopyOp& copyop=CopyOp::SHALLOW_COPY): - PrimitiveSet(copy,copyop), - _eboOffset(0) {} + PrimitiveSet(copy,copyop) {} virtual DrawElements* getDrawElements() { return this; } virtual const DrawElements* getDrawElements() const { return this; } - virtual void dirty() { ++_modifiedCount; if (_ebo.valid()) _ebo->dirty(); } - /** Set the ElementBufferObject.*/ - inline void setElementBufferObject(osg::ElementBufferObject* ebo) - { - if (_ebo == ebo) return; - - if (_ebo.valid()) - { - _ebo->removeDrawElements(this); - } - - _ebo = ebo; + inline void setElementBufferObject(osg::ElementBufferObject* ebo) { setBufferObject(ebo); } - if (_ebo.valid()) - { - _ebo->addDrawElements(this); - } - } - /** Get the ElementBufferObject. If no EBO is assigned returns NULL*/ - inline osg::ElementBufferObject* getElementBufferObject() { return _ebo.get(); } + inline osg::ElementBufferObject* getElementBufferObject() { return dynamic_cast(_bufferObject.get()); } /** Get the const ElementBufferObject. If no EBO is assigned returns NULL*/ - inline const osg::ElementBufferObject* getElementBufferObject() const { return _ebo.get(); } + inline const osg::ElementBufferObject* getElementBufferObject() const { return dynamic_cast(_bufferObject.get()); } - /** Set the offset into the ElementBufferObject, if used.*/ - inline void setElementBufferObjectOffset(const GLvoid* offset) const { _eboOffset = offset; } - - /** 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 objects - * for all graphics contexts. */ - virtual void releaseGLObjects(State* state=0) const - { - if (_ebo.valid()) _ebo->releaseGLObjects(state); - } - - virtual void reserveElements(unsigned int numIndices) = 0; virtual void setElement(unsigned int, unsigned int) = 0; virtual unsigned int getElement(unsigned int) = 0; virtual void addElement(unsigned int) = 0; protected: - - virtual ~DrawElements() - { - if (_ebo.valid()) - { - _ebo->removeDrawElements(this); - } - } - - osg::ref_ptr _ebo; - mutable const GLvoid* _eboOffset; + virtual ~DrawElements() {} }; class OSG_EXPORT DrawElementsUByte : public DrawElements, public VectorGLubyte diff --git a/include/osg/State b/include/osg/State index 0438c5403..e3457f512 100644 --- a/include/osg/State +++ b/include/osg/State @@ -405,13 +405,13 @@ class OSG_EXPORT State : public Referenced, public Observer void dirtyAllVertexArrays(); - void setCurrentVertexBufferObject(osg::VertexBufferObject* vbo) { _currentVBO = vbo; } - const VertexBufferObject* getCurrentVertexBufferObject() { return _currentVBO; } - inline void bindVertexBufferObject(const osg::VertexBufferObject* vbo) + void setCurrentVertexBufferObject(osg::GLBufferObject* vbo) { _currentVBO = vbo; } + const GLBufferObject* getCurrentVertexBufferObject() { return _currentVBO; } + inline void bindVertexBufferObject(osg::GLBufferObject* vbo) { if (vbo == _currentVBO) return; - if (vbo->isDirty(_contextID)) vbo->compileBuffer(*this); - else _glBindBuffer(GL_ARRAY_BUFFER_ARB,vbo->buffer(_contextID)); + if (vbo->isDirty()) vbo->compileBuffer(); + else _glBindBuffer(GL_ARRAY_BUFFER_ARB,vbo->getGLObjectID()); _currentVBO = vbo; } @@ -422,14 +422,14 @@ class OSG_EXPORT State : public Referenced, public Observer _currentVBO = 0; } - void setCurrentElementBufferObject(osg::ElementBufferObject* ebo) { _currentEBO = ebo; } - const ElementBufferObject* getCurrentElementBufferObject() { return _currentEBO; } + void setCurrentElementBufferObject(osg::GLBufferObject* ebo) { _currentEBO = ebo; } + const GLBufferObject* getCurrentElementBufferObject() { return _currentEBO; } - inline void bindElementBufferObject(const osg::ElementBufferObject* ebo) + inline void bindElementBufferObject(osg::GLBufferObject* ebo) { if (ebo == _currentEBO) return; - if (ebo->isDirty(_contextID)) ebo->compileBuffer(*this); - else _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,ebo->buffer(_contextID)); + if (ebo->isDirty()) ebo->compileBuffer(); + else _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,ebo->getGLObjectID()); _currentEBO = ebo; } @@ -440,15 +440,15 @@ class OSG_EXPORT State : public Referenced, public Observer _currentEBO = 0; } - void setCurrentPixelBufferObject(osg::PixelBufferObject* pbo) { _currentPBO = pbo; } - const PixelBufferObject* getCurrentPixelBufferObject() { return _currentPBO; } + void setCurrentPixelBufferObject(osg::GLBufferObject* pbo) { _currentPBO = pbo; } + const GLBufferObject* getCurrentPixelBufferObject() { return _currentPBO; } - inline void bindPixelBufferObject(const osg::PixelBufferObject* pbo) + inline void bindPixelBufferObject(osg::GLBufferObject* pbo) { if (pbo == _currentPBO) return; - if (pbo->isDirty(_contextID)) pbo->compileBuffer(*this); - else _glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,pbo->buffer(_contextID)); + if (pbo->isDirty()) pbo->compileBuffer(); + else _glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,pbo->getGLObjectID()); _currentPBO = pbo; } @@ -485,11 +485,11 @@ class OSG_EXPORT State : public Referenced, public Observer { if (array) { - const VertexBufferObject* vbo = array->getVertexBufferObject(); + GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID); if (vbo) { bindVertexBufferObject(vbo); - setVertexPointer(array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset()); + setVertexPointer(array->getDataSize(),array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); } else { @@ -542,11 +542,11 @@ class OSG_EXPORT State : public Referenced, public Observer { if (array) { - const VertexBufferObject* vbo = array->getVertexBufferObject(); + GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID); if (vbo) { bindVertexBufferObject(vbo); - setNormalPointer(array->getDataType(),0,array->getVertexBufferObjectOffset()); + setNormalPointer(array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); } else { @@ -598,11 +598,11 @@ class OSG_EXPORT State : public Referenced, public Observer { if (array) { - const VertexBufferObject* vbo = array->getVertexBufferObject(); + GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID); if (vbo) { bindVertexBufferObject(vbo); - setColorPointer(array->getDataSize(),array->getDataType(),0,array->getVertexBufferObjectOffset()); + setColorPointer(array->getDataSize(),array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); } else { @@ -659,15 +659,11 @@ class OSG_EXPORT State : public Referenced, public Observer { if (array) { - const VertexBufferObject* vbo = array->getVertexBufferObject(); + GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID); 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 + setSecondaryColorPointer(array->getDataSize(),array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); } else { @@ -745,15 +741,11 @@ class OSG_EXPORT State : public Referenced, public Observer { if (array) { - const VertexBufferObject* vbo = array->getVertexBufferObject(); + GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID); if (vbo) { bindVertexBufferObject(vbo); -#if 0 - setFogCoordPointer(array->getDataType(),0,vbo->getOffset(array->getVertexBufferObjectIndex())); -#else - setFogCoordPointer(array->getDataType(),0,array->getVertexBufferObjectOffset()); -#endif + setFogCoordPointer(array->getDataType(),0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); } else { @@ -794,15 +786,11 @@ class OSG_EXPORT State : public Referenced, public Observer { if (array) { - const VertexBufferObject* vbo = array->getVertexBufferObject(); + GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID); 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 + setTexCoordPointer(unit, array->getDataSize(),array->getDataType(),0, (const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); } else { @@ -916,15 +904,11 @@ class OSG_EXPORT State : public Referenced, public Observer { if (array) { - const VertexBufferObject* vbo = array->getVertexBufferObject(); + GLBufferObject* vbo = array->getOrCreateGLBufferObject(_contextID); 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 + setVertexAttribPointer(unit, array->getDataSize(),array->getDataType(),normalized,0,(const GLvoid *)(vbo->getOffset(array->getBufferIndex()))); } else { @@ -1279,9 +1263,9 @@ class OSG_EXPORT State : public Referenced, public Observer unsigned int _currentActiveTextureUnit; unsigned int _currentClientActiveTextureUnit; - const VertexBufferObject* _currentVBO; - const ElementBufferObject* _currentEBO; - const PixelBufferObject* _currentPBO; + GLBufferObject* _currentVBO; + GLBufferObject* _currentEBO; + GLBufferObject* _currentPBO; inline ModeMap& getOrCreateTextureModeMap(unsigned int unit) diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index d71036034..c4753d23c 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -37,7 +37,185 @@ typedef osg::buffered_object DeletedBufferObjectCache; static OpenThreads::Mutex s_mutex_deletedBufferObjectCache; static DeletedBufferObjectCache s_deletedBufferObjectCache; -void BufferObject::deleteBufferObject(unsigned int contextID,GLuint globj) +////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// GLBufferObject +// +GLBufferObject::GLBufferObject(unsigned int contextID, BufferObject* bufferObject): + _contextID(contextID), + _glObjectID(0), + _target(0), + _usage(0), + _dirty(true), + _totalSize(0), + _bufferObject(0), + _extensions(0) +{ + assign(bufferObject); + _extensions = GLBufferObject::getExtensions(contextID, true); + _extensions->glGenBuffers(1, &_glObjectID); +} + +GLBufferObject::~GLBufferObject() +{ + if (_glObjectID!=0) GLBufferObject::deleteBufferObject(_contextID, _glObjectID); + +} + +void GLBufferObject::assign(BufferObject* bufferObject) +{ + _bufferObject = bufferObject; + + if (_bufferObject) + { + _target = bufferObject->getTarget(); + _usage = bufferObject->getUsage(); + + _totalSize = 0; + + _dirty = true; + + _bufferEntries.clear(); + } + else + { + _target = 0; + _usage = 0; + + _totalSize = 0; + + // clear all previous entries; + _bufferEntries.clear(); + } +} + +void GLBufferObject::clear() +{ + _bufferEntries.clear(); + _dirty = true; +} + +void GLBufferObject::compileBuffer() +{ + _dirty = false; + + _bufferEntries.reserve(_bufferObject->getNumBufferData()); + + _totalSize = 0; + + bool compileAll = false; + bool offsetChanged = false; + + GLsizeiptrARB newTotalSize = 0; + unsigned int i=0; + for(; i<_bufferObject->getNumBufferData(); ++i) + { + BufferData* bd = _bufferObject->getBufferData(i); + if (i<_bufferEntries.size()) + { + BufferEntry& entry = _bufferEntries[i]; + if (offsetChanged || + entry.dataSource != bd || + entry.dataSize != bd->getTotalDataSize()) + { + GLsizeiptrARB previousEndOfBufferDataMarker = GLsizeiptrARB(entry.offset) + entry.dataSize; + + // osg::notify(osg::NOTICE)<<"GLBufferObject::compileBuffer(..) updating BufferEntry"<getTotalDataSize(); + entry.dataSource = bd; + + newTotalSize += entry.dataSize; + if (previousEndOfBufferDataMarker==newTotalSize) + { + offsetChanged = true; + } + } + } + else + { + BufferEntry entry; + entry.offset = newTotalSize; + entry.modifiedCount = 0xffffff; + entry.dataSize = bd->getTotalDataSize(); + entry.dataSource = bd; +#if 0 + osg::notify(osg::NOTICE)<<"entry"<glBindBuffer(_target, _glObjectID); + + if (newTotalSize != _totalSize) + { + _totalSize = newTotalSize; + _extensions->glBufferData(_target, _totalSize, NULL, _usage); + } + + char* vboMemory = 0; + +#if 0 + vboMemory = extensions->glMapBuffer(_target, GL_WRITE_ONLY_ARB); +#endif + + for(BufferEntries::iterator itr = _bufferEntries.begin(); + itr != _bufferEntries.end(); + ++itr) + { + BufferEntry& entry = *itr; + if (compileAll || entry.modifiedCount != entry.dataSource->getModifiedCount()) + { + // osg::notify(osg::NOTICE)<<"GLBufferObject::compileBuffer(..) downloading BufferEntry "<<&entry<getModifiedCount(); + + if (vboMemory) + memcpy(vboMemory + (GLsizeiptrARB)entry.offset, entry.dataSource->getDataPointer(), entry.dataSize); + else + _extensions->glBufferSubData(_target, (GLintptrARB)entry.offset, (GLsizeiptrARB)entry.dataSize, entry.dataSource->getDataPointer()); + + } + } + + // Unmap the texture image buffer + if (vboMemory) _extensions->glUnmapBuffer(_target); +} + +GLBufferObject* GLBufferObject::createGLBufferObject(unsigned int contextID, const BufferObject* bufferObject) +{ + return new GLBufferObject(contextID, const_cast(bufferObject)); +} + +void GLBufferObject::deleteGLObject() +{ + if (_glObjectID!=0) + { + _extensions->glDeleteBuffers(1, &_glObjectID); + _glObjectID = 0; + + _totalSize = 0; + _bufferEntries.clear(); + } +} + + +void GLBufferObject::deleteBufferObject(unsigned int contextID,GLuint globj) { if (globj!=0) { @@ -48,7 +226,7 @@ void BufferObject::deleteBufferObject(unsigned int contextID,GLuint globj) } } -void BufferObject::flushDeletedBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime) +void GLBufferObject::flushDeletedBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime) { // if no time available don't try to flush objects. if (availableTime<=0.0) return; @@ -84,85 +262,38 @@ void BufferObject::flushDeletedBufferObjects(unsigned int contextID,double /*cur availableTime -= elapsedTime; } -void BufferObject::discardDeletedBufferObjects(unsigned int contextID) +void GLBufferObject::discardDeletedBufferObjects(unsigned int contextID) { OpenThreads::ScopedLock lock(s_mutex_deletedBufferObjectCache); BufferObjectMap& dll = s_deletedBufferObjectCache[contextID]; dll.clear(); } - -BufferObject::BufferObject(): - _target(0), - _usage(0), - _totalSize(0) -{ -} - -BufferObject::BufferObject(const BufferObject& bo,const CopyOp& copyop): - Object(bo,copyop) -{ -} - -BufferObject::~BufferObject() -{ - releaseGLObjects(0); -} - -void BufferObject::resizeGLObjectBuffers(unsigned int maxSize) -{ - _bufferObjectList.resize(maxSize); -} - -void BufferObject::releaseGLObjects(State* state) const -{ - if (state) - { - unsigned int contextID = state->getContextID(); - if (_bufferObjectList[contextID]) - { - deleteBufferObject(contextID,_bufferObjectList[contextID]); - _bufferObjectList[contextID] = 0; - } - } - else - { - for(unsigned int contextID=0;contextID<_bufferObjectList.size();++contextID) - { - if (_bufferObjectList[contextID]) - { - deleteBufferObject(contextID,_bufferObjectList[contextID]); - _bufferObjectList[contextID] = 0; - } - } - } -} - ////////////////////////////////////////////////////////////////////////////// // // Extension support // -typedef buffered_value< ref_ptr > BufferedExtensions; +typedef buffered_value< ref_ptr > BufferedExtensions; static BufferedExtensions s_extensions; -BufferObject::Extensions* BufferObject::getExtensions(unsigned int contextID,bool createIfNotInitalized) +GLBufferObject::Extensions* GLBufferObject::getExtensions(unsigned int contextID,bool createIfNotInitalized) { - if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new BufferObject::Extensions(contextID); + if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new GLBufferObject::Extensions(contextID); return s_extensions[contextID].get(); } -void BufferObject::setExtensions(unsigned int contextID,Extensions* extensions) +void GLBufferObject::setExtensions(unsigned int contextID,Extensions* extensions) { s_extensions[contextID] = extensions; } -BufferObject::Extensions::Extensions(unsigned int contextID) +GLBufferObject::Extensions::Extensions(unsigned int contextID) { setupGLExtensions(contextID); } -BufferObject::Extensions::Extensions(const Extensions& rhs): +GLBufferObject::Extensions::Extensions(const Extensions& rhs): Referenced() { _glGenBuffers = rhs._glGenBuffers; @@ -179,7 +310,7 @@ BufferObject::Extensions::Extensions(const Extensions& rhs): } -void BufferObject::Extensions::lowestCommonDenominator(const Extensions& rhs) +void GLBufferObject::Extensions::lowestCommonDenominator(const Extensions& rhs) { if (!rhs._glGenBuffers) _glGenBuffers = rhs._glGenBuffers; if (!rhs._glBindBuffer) _glBindBuffer = rhs._glBindBuffer; @@ -194,7 +325,7 @@ void BufferObject::Extensions::lowestCommonDenominator(const Extensions& rhs) if (!rhs._glGetBufferParameteriv) _glGetBufferPointerv = rhs._glGetBufferPointerv; } -void BufferObject::Extensions::setupGLExtensions(unsigned int contextID) +void GLBufferObject::Extensions::setupGLExtensions(unsigned int contextID) { setGLExtensionFuncPtr(_glGenBuffers, "glGenBuffers","glGenBuffersARB"); setGLExtensionFuncPtr(_glBindBuffer, "glBindBuffer","glBindBufferARB"); @@ -210,37 +341,37 @@ void BufferObject::Extensions::setupGLExtensions(unsigned int contextID) _isPBOSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_pixel_buffer_object"); } -void BufferObject::Extensions::glGenBuffers(GLsizei n, GLuint *buffers) const +void GLBufferObject::Extensions::glGenBuffers(GLsizei n, GLuint *buffers) const { if (_glGenBuffers) _glGenBuffers(n, buffers); else notify(WARN)<<"Error: glGenBuffers not supported by OpenGL driver"<=_bufferDataList.size()) _bufferDataList.resize(index+1); + _bufferDataList[index] = bd; +} + +void BufferObject::dirty() +{ + for(unsigned int i=0; i<_glBufferObjects.size(); ++i) + { + if (_glBufferObjects[i].valid()) _glBufferObjects[i]->dirty(); + } +} + +void BufferObject::resizeGLObjectBuffers(unsigned int maxSize) +{ + _glBufferObjects.resize(maxSize); +} + +void BufferObject::releaseGLObjects(State* state) const +{ + if (state) + { + _glBufferObjects[state->getContextID()] = 0; + } + else + { + _glBufferObjects.clear(); + } +} + +unsigned int BufferObject::addBufferData(BufferData* bd) +{ + if (!bd) return 0; + + // check to see if bd exists in BufferObject already, is so return without doing anything + for(BufferDataList::iterator itr = _bufferDataList.begin(); + itr != _bufferDataList.end(); + ++itr) + { + if (*itr == bd) return bd->getBufferIndex(); + } + + // bd->setBufferIndex(_bufferDataList.size()); + + _bufferDataList.push_back(bd); + + // osg::notify(osg::NOTICE)<<"BufferObject "<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<first.modifiedCount.resize(maxSize); - } -} +#endif ////////////////////////////////////////////////////////////////////////////////// // @@ -548,36 +788,31 @@ ElementBufferObject::~ElementBufferObject() unsigned int ElementBufferObject::addDrawElements(osg::DrawElements* drawElements) { - unsigned int i = _bufferEntryDrawElementsPairs.size(); - _bufferEntryDrawElementsPairs.resize(i+1); - _bufferEntryDrawElementsPairs[i].second = drawElements; - _bufferEntryDrawElementsPairs[i].first.modifiedCount.setAllElementsTo(0xffffffff); - _bufferEntryDrawElementsPairs[i].first.dataSize = 0; - - return i; + return addBufferData(drawElements); } 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); + removeBufferData(drawElements); } void ElementBufferObject::setDrawElements(unsigned int i, DrawElements* drawElements) { - if (i+1>=_bufferEntryDrawElementsPairs.size()) _bufferEntryDrawElementsPairs.resize(i+1); - - _bufferEntryDrawElementsPairs[i].second = drawElements; - _bufferEntryDrawElementsPairs[i].first.modifiedCount.setAllElementsTo(0xffffffff); - _bufferEntryDrawElementsPairs[i].first.dataSize = 0; + setBufferData(i,drawElements); } +DrawElements* ElementBufferObject::getDrawElements(unsigned int i) +{ + return dynamic_cast(getBufferData(i)); +} + +const DrawElements* ElementBufferObject::getDrawElements(unsigned int i) const +{ + return dynamic_cast(getBufferData(i)); +} + + +#if 0 void ElementBufferObject::compileBuffer(State& state) const { unsigned int contextID = state.getContextID(); @@ -681,18 +916,7 @@ void ElementBufferObject::compileBuffer(State& state) const // osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<first.modifiedCount.resize(maxSize); - } -} +#endif ////////////////////////////////////////////////////////////////////////////////// // @@ -703,13 +927,14 @@ PixelBufferObject::PixelBufferObject(osg::Image* image): { _target = GL_PIXEL_UNPACK_BUFFER_ARB; _usage = GL_STREAM_DRAW_ARB; - _bufferEntryImagePair.second = image; + + osg::notify(osg::NOTICE)<<"Constructing PixelBufferObject for image="<(getBufferData(0)); +} + +const Image* PixelBufferObject::getImage() const +{ + return dynamic_cast(getBufferData(0)); +} + +#if 0 void PixelBufferObject::compileBuffer(State& state) const { unsigned int contextID = state.getContextID(); @@ -781,14 +1014,7 @@ void PixelBufferObject::compileBuffer(State& state) const // osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<isDirty()) return; - GLuint& pbo = buffer(contextID); - if (pbo == 0) - { - extensions->glGenBuffers(1, &pbo); - } - - extensions->glBindBuffer(_target, pbo); - extensions->glBufferData(_target, _bufferData.dataSize, NULL, _usage); - extensions->glBindBuffer(_target, 0); - - _compiledList[contextID] = 1; + bo->_extensions->glBindBuffer(_target, bo->getGLObjectID()); + bo->_extensions->glBufferData(_target, _dataSize, NULL, _usage); + bo->_extensions->glBindBuffer(_target, 0); } //-------------------------------------------------------------------------------- void PixelDataBufferObject::bindBufferInReadMode(State& state) { unsigned int contextID = state.getContextID(); - if (isDirty(contextID)) compileBuffer(state); - Extensions* extensions = getExtensions(contextID,true); + GLBufferObject* bo = getOrCreateGLBufferObject(contextID); + if (!bo) return; + + if (bo->isDirty()) compileBuffer(state); + + bo->_extensions->glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, bo->getGLObjectID()); - extensions->glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, buffer(contextID)); _mode[contextID] = READ; } @@ -851,18 +1071,21 @@ void PixelDataBufferObject::bindBufferInReadMode(State& state) void PixelDataBufferObject::bindBufferInWriteMode(State& state) { unsigned int contextID = state.getContextID(); - if (isDirty(contextID)) compileBuffer(state); - Extensions* extensions = getExtensions(contextID,true); + GLBufferObject* bo = getOrCreateGLBufferObject(contextID); + if (!bo) return; + + if (bo->isDirty()) compileBuffer(state); + + bo->_extensions->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, bo->getGLObjectID()); - extensions->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer(contextID)); _mode[contextID] = WRITE; } //-------------------------------------------------------------------------------- void PixelDataBufferObject::unbindBuffer(unsigned int contextID) const { - Extensions* extensions = getExtensions(contextID,true); + GLBufferObject::Extensions* extensions = GLBufferObject::getExtensions(contextID,true); switch(_mode[contextID]) { @@ -888,3 +1111,5 @@ void PixelDataBufferObject::resizeGLObjectBuffers(unsigned int maxSize) _mode.resize(maxSize); } + +#endif \ No newline at end of file diff --git a/src/osg/GLObjects.cpp b/src/osg/GLObjects.cpp index f4c79c915..16e47821e 100644 --- a/src/osg/GLObjects.cpp +++ b/src/osg/GLObjects.cpp @@ -23,7 +23,7 @@ void osg::flushDeletedGLObjects(unsigned int contextID, double currentTime, double& availableTime) { - osg::BufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime); + osg::GLBufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime); osg::Drawable::flushDeletedDisplayLists(contextID,availableTime); osg::FragmentProgram::flushDeletedFragmentProgramObjects(contextID,currentTime,availableTime); osg::FrameBufferObject::flushDeletedFrameBufferObjects(contextID,currentTime,availableTime); @@ -39,7 +39,7 @@ void osg::flushAllDeletedGLObjects(unsigned int contextID) { double currentTime = DBL_MAX; double availableTime = DBL_MAX; - osg::BufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime); + osg::GLBufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime); osg::Drawable::flushAllDeletedDisplayLists(contextID); osg::FragmentProgram::flushDeletedFragmentProgramObjects(contextID,currentTime,availableTime); osg::FrameBufferObject::flushDeletedFrameBufferObjects(contextID,currentTime,availableTime); @@ -53,7 +53,7 @@ void osg::flushAllDeletedGLObjects(unsigned int contextID) void osg::discardAllDeletedGLObjects(unsigned int contextID) { - osg::BufferObject::discardDeletedBufferObjects(contextID); + osg::GLBufferObject::discardDeletedBufferObjects(contextID); osg::Drawable::discardAllDeletedDisplayLists(contextID); osg::FragmentProgram::discardDeletedFragmentProgramObjects(contextID); osg::FrameBufferObject::discardDeletedFrameBufferObjects(contextID); diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index d668a5112..05f552f1d 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -1374,6 +1374,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const // if (usingVertexBufferObjects) { + // osg::notify(osg::NOTICE)<<"Geometry::drawImplementation() Using VertexBufferObjects"<=1) state.glDrawElementsInstanced(_mode, size(), GL_UNSIGNED_BYTE, getElementBufferObjectOffset(), _numInstances); - else glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, getElementBufferObjectOffset()); + if (_numInstances>=1) state.glDrawElementsInstanced(_mode, size(), GL_UNSIGNED_BYTE, (const GLvoid *)(ebo->getOffset(getBufferIndex())), _numInstances); + else glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, (const GLvoid *)(ebo->getOffset(getBufferIndex()))); } else { @@ -176,12 +176,12 @@ void DrawElementsUShort::draw(State& state, bool useVertexBufferObjects) const { if (useVertexBufferObjects) { - const ElementBufferObject* ebo = getElementBufferObject(); + GLBufferObject* ebo = getOrCreateGLBufferObject(state.getContextID()); state.bindElementBufferObject(ebo); if (ebo) { - if (_numInstances>=1) state.glDrawElementsInstanced(_mode, size(), GL_UNSIGNED_SHORT, getElementBufferObjectOffset(), _numInstances); - else glDrawElements(_mode, size(), GL_UNSIGNED_SHORT, getElementBufferObjectOffset()); + if (_numInstances>=1) state.glDrawElementsInstanced(_mode, size(), GL_UNSIGNED_SHORT, (const GLvoid *)(ebo->getOffset(getBufferIndex())), _numInstances); + else glDrawElements(_mode, size(), GL_UNSIGNED_SHORT, (const GLvoid *)(ebo->getOffset(getBufferIndex()))); } else { @@ -226,12 +226,12 @@ void DrawElementsUInt::draw(State& state, bool useVertexBufferObjects) const { if (useVertexBufferObjects) { - const ElementBufferObject* ebo = getElementBufferObject(); + GLBufferObject* ebo = getOrCreateGLBufferObject(state.getContextID()); state.bindElementBufferObject(ebo); if (ebo) { - if (_numInstances>=1) state.glDrawElementsInstanced(_mode, size(), GL_UNSIGNED_INT, getElementBufferObjectOffset(), _numInstances); - else glDrawElements(_mode, size(), GL_UNSIGNED_INT, getElementBufferObjectOffset()); + if (_numInstances>=1) state.glDrawElementsInstanced(_mode, size(), GL_UNSIGNED_INT, (const GLvoid *)(ebo->getOffset(getBufferIndex())), _numInstances); + else glDrawElements(_mode, size(), GL_UNSIGNED_INT, (const GLvoid *)(ebo->getOffset(getBufferIndex()))); } else { diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index cc2ddc7fa..8863059ba 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -46,7 +46,7 @@ #define GL_STORAGE_SHARED_APPLE 0x85BF #endif -//#define DO_TIMING +// #define DO_TIMING namespace osg { @@ -1777,15 +1777,12 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima bool useHardwareMipMapGeneration = mipmappingRequired && (!image->isMipmap() && isHardwareMipmapGenerationEnabled(state)); bool useGluBuildMipMaps = mipmappingRequired && (!useHardwareMipMapGeneration && !image->isMipmap()); - unsigned char* dataMinusOffset = 0; - unsigned char* dataPlusOffset = 0; - - const PixelBufferObject* pbo = image->getPixelBufferObject(); - if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale && !useGluBuildMipMaps) + const unsigned char* dataPtr = image->data(); + GLBufferObject* pbo = image->getOrCreateGLBufferObject(contextID); + if (pbo && !needImageRescale && !useGluBuildMipMaps) { state.bindPixelBufferObject(pbo); - dataMinusOffset = data; - dataPlusOffset = reinterpret_cast(pbo->offset()); + dataPtr = reinterpret_cast(pbo->getOffset(image->getBufferIndex())); #ifdef DO_TIMING osg::notify(osg::NOTICE)<<"after PBO "<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<getPixelFormat(), (GLenum)image->getDataType(), - data -dataMinusOffset+dataPlusOffset); + dataPtr); } else if (extensions->isCompressedTexImage2DSupported()) @@ -1821,7 +1818,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima extensions->glCompressedTexImage2D(target, 0, _internalFormat, inwidth, inheight,0, size, - data-dataMinusOffset+dataPlusOffset); + dataPtr); } mipmapAfterTexImage(state, mipmapResult); @@ -1853,7 +1850,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima width, height, _borderWidth, (GLenum)image->getPixelFormat(), (GLenum)image->getDataType(), - image->getMipmapData(k)-dataMinusOffset+dataPlusOffset); + dataPtr + image->getMipmapOffset(k)); width >>= 1; height >>= 1; @@ -1874,7 +1871,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima extensions->glCompressedTexImage2D(target, k, _internalFormat, width, height, _borderWidth, - size, image->getMipmapData(k)-dataMinusOffset+dataPlusOffset); + size, dataPtr + image->getMipmapOffset(k)); width >>= 1; height >>= 1; @@ -2027,12 +2024,12 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image* unsigned char* dataMinusOffset = 0; unsigned char* dataPlusOffset = 0; - const PixelBufferObject* pbo = image->getPixelBufferObject(); - if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale && !useGluBuildMipMaps) + const unsigned char* dataPtr = image->data(); + GLBufferObject* pbo = image->getOrCreateGLBufferObject(contextID); + if (pbo && !needImageRescale && !useGluBuildMipMaps) { state.bindPixelBufferObject(pbo); - dataMinusOffset = data; - dataPlusOffset = reinterpret_cast(pbo->offset()); + dataPtr = reinterpret_cast(pbo->getOffset(image->getBufferIndex())); #ifdef DO_TIMING osg::notify(osg::NOTICE)<<"after PBO "<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<getPixelBufferObject(); - if (pbo && pbo->isPBOSupported(contextID)) + const unsigned char* dataPtr = image->data(); + GLBufferObject* pbo = image->getOrCreateGLBufferObject(contextID); + if (pbo) { state.bindPixelBufferObject(pbo); - dataMinusOffset = image->data(); - dataPlusOffset = reinterpret_cast(pbo->offset()); - } - else - { - pbo = 0; + dataPtr = reinterpret_cast(pbo->getOffset(image->getBufferIndex())); } if(isCompressedInternalFormat(_internalFormat) && extensions->isCompressedTexImage2DSupported()) @@ -310,7 +303,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st extensions->glCompressedTexImage2D(target, 0, _internalFormat, image->s(), image->t(), 0, image->getImageSizeInBytes(), - image->data() - dataMinusOffset + dataPlusOffset); + dataPtr); } else { @@ -318,7 +311,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st image->s(), image->t(), 0, (GLenum)image->getPixelFormat(), (GLenum)image->getDataType(), - image->data() - dataMinusOffset + dataPlusOffset ); + dataPtr ); } @@ -365,26 +358,21 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& #ifdef DO_TIMING osg::Timer_t start_tick = osg::Timer::instance()->tick(); - osg::notify(osg::NOTICE)<<"glTexSubImage2D pixelFormat = "<getPixelFormat()<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<getBufferObject()<<", "<getPixelBufferObject()<<" pbo="<s(), image->t(), (GLenum)image->getPixelFormat(), (GLenum)image->getDataType(), - image->data() - dataMinusOffset + dataPlusOffset); + dataPtr); } else { @@ -404,7 +392,7 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& image->s(), image->t(), (GLenum)image->getPixelFormat(), (GLenum)image->getDataType(), - image->data() - dataMinusOffset + dataPlusOffset ); + dataPtr); } if (pbo) @@ -415,7 +403,6 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& #ifdef DO_TIMING osg::notify(osg::NOTICE)<<"glTexSubImage2D "<delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<writeInt(size()); - out->writeCharArray((const char*)&front(), size() * CHARSIZE); + if (size()!=0) out->writeCharArray((const char*)&front(), size() * CHARSIZE); } void DrawElementsUByte::read(DataInputStream* in){ @@ -53,7 +53,7 @@ void DrawElementsUByte::read(DataInputStream* in){ // Read array length and its elements. int size = in->readInt(); resize(size); - in->readCharArray((char*)&front(), size * CHARSIZE); + if (size!=0) in->readCharArray((char*)&front(), size * CHARSIZE); } else{ diff --git a/src/osgPlugins/ive/DrawElementsUInt.cpp b/src/osgPlugins/ive/DrawElementsUInt.cpp index 936b8bbdb..d6962eee6 100644 --- a/src/osgPlugins/ive/DrawElementsUInt.cpp +++ b/src/osgPlugins/ive/DrawElementsUInt.cpp @@ -34,7 +34,7 @@ void DrawElementsUInt::write(DataOutputStream* out){ // Write array length and its elements. out->writeInt(size()); - out->writeCharArray((const char*)&front(), size() * INTSIZE); + if (size()!=0) out->writeCharArray((const char*)&front(), size() * INTSIZE); } void DrawElementsUInt::read(DataInputStream* in) @@ -55,7 +55,7 @@ void DrawElementsUInt::read(DataInputStream* in) // Read array length and its elements. int size = in->readInt(); resize(size); - in->readCharArray((char*)&front(), size * INTSIZE); + if (size!=0) in->readCharArray((char*)&front(), size * INTSIZE); if (in->_byteswap) { diff --git a/src/osgPlugins/ive/DrawElementsUShort.cpp b/src/osgPlugins/ive/DrawElementsUShort.cpp index c8b60c387..9efc359bf 100644 --- a/src/osgPlugins/ive/DrawElementsUShort.cpp +++ b/src/osgPlugins/ive/DrawElementsUShort.cpp @@ -34,7 +34,7 @@ void DrawElementsUShort::write(DataOutputStream* out){ // Write array length and its elements. out->writeInt(size()); - out->writeCharArray((const char*)&front(), size() * SHORTSIZE); + if (size()!=0) out->writeCharArray((const char*)&front(), size() * SHORTSIZE); } void DrawElementsUShort::read(DataInputStream* in){ diff --git a/src/osgViewer/ScreenCaptureHandler.cpp b/src/osgViewer/ScreenCaptureHandler.cpp index ae68f83d4..b0e53e0cd 100644 --- a/src/osgViewer/ScreenCaptureHandler.cpp +++ b/src/osgViewer/ScreenCaptureHandler.cpp @@ -73,8 +73,8 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback void read(); void readPixels(); - void singlePBO(osg::BufferObject::Extensions* ext); - void multiPBO(osg::BufferObject::Extensions* ext); + void singlePBO(osg::GLBufferObject::Extensions* ext); + void multiPBO(osg::GLBufferObject::Extensions* ext); typedef std::vector< osg::ref_ptr > ImageBuffer; typedef std::vector< GLuint > PBOBuffer; @@ -220,7 +220,7 @@ void WindowCaptureCallback::ContextData::updateTimings(osg::Timer_t tick_start, void WindowCaptureCallback::ContextData::read() { - osg::BufferObject::Extensions* ext = osg::BufferObject::getExtensions(_gc->getState()->getContextID(),true); + osg::GLBufferObject::Extensions* ext = osg::GLBufferObject::getExtensions(_gc->getState()->getContextID(),true); if (ext->isPBOSupported() && !_pboBuffer.empty()) { @@ -277,7 +277,7 @@ void WindowCaptureCallback::ContextData::readPixels() _currentPboIndex = nextPboIndex; } -void WindowCaptureCallback::ContextData::singlePBO(osg::BufferObject::Extensions* ext) +void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensions* ext) { unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size(); @@ -352,7 +352,7 @@ void WindowCaptureCallback::ContextData::singlePBO(osg::BufferObject::Extensions _currentImageIndex = nextImageIndex; } -void WindowCaptureCallback::ContextData::multiPBO(osg::BufferObject::Extensions* ext) +void WindowCaptureCallback::ContextData::multiPBO(osg::GLBufferObject::Extensions* ext) { unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size(); unsigned int nextPboIndex = (_currentPboIndex+1)%_pboBuffer.size(); diff --git a/src/osgWrappers/genwrapper.conf b/src/osgWrappers/genwrapper.conf index 530c6d3ca..1bd901d90 100644 --- a/src/osgWrappers/genwrapper.conf +++ b/src/osgWrappers/genwrapper.conf @@ -445,7 +445,7 @@ suppress reflector "osg::StencilTwoSided::Extensions" suppress reflector "osg::Texture3D::Extensions" suppress reflector "osg::GL2Extensions" suppress reflector "osg::Drawable::Extensions" -suppress reflector "osg::BufferObject::Extensions" +suppress reflector "osg::GLBufferObject::Extensions" suppress reflector "osg::FBOExtensions" suppress reflector "osg::Drawable::Extensions" suppress reflector "osg::BlendColor::Extensions" diff --git a/src/osgWrappers/osg/Array.cpp b/src/osgWrappers/osg/Array.cpp index 85702b30c..5017a61e2 100644 --- a/src/osgWrappers/osg/Array.cpp +++ b/src/osgWrappers/osg/Array.cpp @@ -64,7 +64,7 @@ END_REFLECTOR BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Array) I_DeclaringFile("osg/Array"); - I_BaseType(osg::Object); + I_BaseType(osg::BufferData); I_ConstructorWithDefaults3(IN, osg::Array::Type, arrayType, osg::Array::ArrayType, IN, GLint, dataSize, 0, IN, GLenum, dataType, 0, ____Array__Type__GLint__GLenum, "", @@ -148,21 +148,6 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Array) __void__trim, "Frees unused space on this vector - i.e. ", "the difference between size() and max_size() of the underlying vector. "); - I_Method0(void, dirty, - Properties::NON_VIRTUAL, - __void__dirty, - "Dirty the primitive, which increments the modified count, to force buffer objects to update. ", - ""); - I_Method1(void, setModifiedCount, IN, unsigned int, value, - Properties::NON_VIRTUAL, - __void__setModifiedCount__unsigned_int, - "Set the modified count value. ", - ""); - I_Method0(unsigned int, getModifiedCount, - Properties::NON_VIRTUAL, - __unsigned_int__getModifiedCount, - "Get modified count value. ", - ""); I_Method1(void, setVertexBufferObject, IN, osg::VertexBufferObject *, vbo, Properties::NON_VIRTUAL, __void__setVertexBufferObject__osg_VertexBufferObject_P1, @@ -178,16 +163,6 @@ 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, setVertexBufferObjectOffset, IN, const GLvoid *, offset, - Properties::NON_VIRTUAL, - __void__setVertexBufferObjectOffset__C5_GLvoid_P1, - "Set the offset into the VertexBufferObject, if used. ", - ""); - I_Method0(const GLvoid *, getVertexBufferObjectOffset, - Properties::NON_VIRTUAL, - __C5_GLvoid_P1__getVertexBufferObjectOffset, - "Get the offset into the VertexBufferObject, if used. ", - ""); I_SimpleProperty(const GLvoid *, DataPointer, __C5_GLvoid_P1__getDataPointer, 0); @@ -197,9 +172,6 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Array) I_SimpleProperty(GLenum, DataType, __GLenum__getDataType, 0); - I_SimpleProperty(unsigned int, ModifiedCount, - __unsigned_int__getModifiedCount, - __void__setModifiedCount__unsigned_int); I_SimpleProperty(unsigned int, TotalDataSize, __unsigned_int__getTotalDataSize, 0); @@ -209,9 +181,6 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Array) I_SimpleProperty(osg::VertexBufferObject *, VertexBufferObject, __osg_VertexBufferObject_P1__getVertexBufferObject, __void__setVertexBufferObject__osg_VertexBufferObject_P1); - 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 bc6effbaa..88315c714 100644 --- a/src/osgWrappers/osg/BufferObject.cpp +++ b/src/osgWrappers/osg/BufferObject.cpp @@ -26,6 +26,108 @@ #undef OUT #endif +BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::BufferData) + I_DeclaringFile("osg/BufferObject"); + I_BaseType(osg::Object); + I_Constructor0(____BufferData, + "", + ""); + I_ConstructorWithDefaults2(IN, const osg::BufferData &, bd, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY, + ____BufferData__C5_BufferData_R1__C5_CopyOp_R1, + "Copy constructor using CopyOp to manage deep vs shallow copy. ", + ""); + I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj, + Properties::VIRTUAL, + __bool__isSameKindAs__C5_Object_P1, + "", + ""); + I_Method0(const char *, libraryName, + Properties::VIRTUAL, + __C5_char_P1__libraryName, + "return the name of the object's library. ", + "Must be defined by derived classes. The OpenSceneGraph convention is that the namespace of a library is the same as the library name. "); + I_Method0(const char *, className, + Properties::VIRTUAL, + __C5_char_P1__className, + "return the name of the object's class type. ", + "Must be defined by derived classes. "); + I_Method0(const GLvoid *, getDataPointer, + Properties::PURE_VIRTUAL, + __C5_GLvoid_P1__getDataPointer, + "", + ""); + I_Method0(unsigned int, getTotalDataSize, + Properties::PURE_VIRTUAL, + __unsigned_int__getTotalDataSize, + "", + ""); + I_Method1(void, setBufferObject, IN, osg::BufferObject *, bufferObject, + Properties::NON_VIRTUAL, + __void__setBufferObject__BufferObject_P1, + "", + ""); + I_Method0(osg::BufferObject *, getBufferObject, + Properties::NON_VIRTUAL, + __BufferObject_P1__getBufferObject, + "", + ""); + I_Method0(const osg::BufferObject *, getBufferObject, + Properties::NON_VIRTUAL, + __C5_BufferObject_P1__getBufferObject, + "", + ""); + I_Method1(void, setBufferIndex, IN, unsigned int, index, + Properties::NON_VIRTUAL, + __void__setBufferIndex__unsigned_int, + "", + ""); + I_Method0(unsigned int, getBufferIndex, + Properties::NON_VIRTUAL, + __unsigned_int__getBufferIndex, + "", + ""); + I_Method1(osg::GLBufferObject *, getGLBufferObject, IN, unsigned int, contextID, + Properties::NON_VIRTUAL, + __GLBufferObject_P1__getGLBufferObject__unsigned_int, + "", + ""); + I_Method1(osg::GLBufferObject *, getOrCreateGLBufferObject, IN, unsigned int, contextID, + Properties::NON_VIRTUAL, + __GLBufferObject_P1__getOrCreateGLBufferObject__unsigned_int, + "", + ""); + I_Method0(void, dirty, + Properties::NON_VIRTUAL, + __void__dirty, + "Dirty the primitive, which increments the modified count, to force buffer objects to update. ", + ""); + I_Method1(void, setModifiedCount, IN, unsigned int, value, + Properties::NON_VIRTUAL, + __void__setModifiedCount__unsigned_int, + "Set the modified count value. ", + ""); + I_Method0(unsigned int, getModifiedCount, + Properties::NON_VIRTUAL, + __unsigned_int__getModifiedCount, + "Get modified count value. ", + ""); + I_SimpleProperty(unsigned int, BufferIndex, + __unsigned_int__getBufferIndex, + __void__setBufferIndex__unsigned_int); + I_SimpleProperty(osg::BufferObject *, BufferObject, + __BufferObject_P1__getBufferObject, + __void__setBufferObject__BufferObject_P1); + I_SimpleProperty(const GLvoid *, DataPointer, + __C5_GLvoid_P1__getDataPointer, + 0); + I_SimpleProperty(unsigned int, ModifiedCount, + __unsigned_int__getModifiedCount, + __void__setModifiedCount__unsigned_int); + I_SimpleProperty(unsigned int, TotalDataSize, + __unsigned_int__getTotalDataSize, + 0); +END_REFLECTOR + BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::BufferObject) I_DeclaringFile("osg/BufferObject"); I_BaseType(osg::Object); @@ -51,6 +153,16 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::BufferObject) __C5_char_P1__className, "return the name of the object's class type. ", "Must be defined by derived classes. "); + I_Method1(void, setTarget, IN, GLenum, target, + Properties::NON_VIRTUAL, + __void__setTarget__GLenum, + "", + ""); + I_Method0(GLenum, getTarget, + Properties::NON_VIRTUAL, + __GLenum__getTarget, + "", + ""); I_Method1(void, setUsage, IN, GLenum, usage, Properties::NON_VIRTUAL, __void__setUsage__GLenum, @@ -61,46 +173,11 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::BufferObject) __GLenum__getUsage, "Get the type of usage the buffer object has been set up for. ", ""); - I_Method1(bool, isBufferObjectSupported, IN, unsigned int, contextID, - Properties::NON_VIRTUAL, - __bool__isBufferObjectSupported__unsigned_int, - "", - ""); - I_Method1(bool, isPBOSupported, IN, unsigned int, contextID, - Properties::NON_VIRTUAL, - __bool__isPBOSupported__unsigned_int, - "", - ""); - I_Method1(GLuint &, buffer, IN, unsigned int, contextID, - Properties::NON_VIRTUAL, - __GLuint_R1__buffer__unsigned_int, - "", - ""); - I_Method1(void, bindBuffer, IN, unsigned int, contextID, - Properties::NON_VIRTUAL, - __void__bindBuffer__unsigned_int, - "", - ""); - I_Method1(void, unbindBuffer, IN, unsigned int, contextID, - Properties::VIRTUAL, - __void__unbindBuffer__unsigned_int, - "", - ""); I_Method0(void, dirty, Properties::NON_VIRTUAL, __void__dirty, "", ""); - I_Method1(bool, isDirty, IN, unsigned int, contextID, - Properties::NON_VIRTUAL, - __bool__isDirty__unsigned_int, - "", - ""); - I_Method1(void, compileBuffer, IN, osg::State &, state, - Properties::PURE_VIRTUAL, - __void__compileBuffer__State_R1, - "", - ""); I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, Properties::VIRTUAL, __void__resizeGLObjectBuffers__unsigned_int, @@ -111,50 +188,66 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::BufferObject) __void__releaseGLObjects__State_P1, "If State is non-zero, this function releases OpenGL objects for the specified graphics context. ", "Otherwise, releases OpenGL objects 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. ", - ""); - I_StaticMethod3(void, flushDeletedBufferObjects, IN, unsigned int, contextID, IN, double, x, IN, double &, availableTime, - __void__flushDeletedBufferObjects__unsigned_int__double__double_R1_S, - "flush all the cached display list which need to be deleted in the OpenGL context related to contextID. ", - ""); - I_StaticMethod1(void, discardDeletedBufferObjects, IN, unsigned int, contextID, - __void__discardDeletedBufferObjects__unsigned_int_S, - "dicard all the cached display list which need to be deleted in the OpenGL context related to contextID. ", - "Note, unlike flush no OpenGL calls are made, instead the handles are all removed. this call is useful for when an OpenGL context has been destroyed. "); - I_StaticMethod2(osg::BufferObject::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized, - __Extensions_P1__getExtensions__unsigned_int__bool_S, - "Function to call to get the extension of a specified context. ", - "If the Extension object for that context has not yet been created and the 'createIfNotInitalized' flag been set to false then returns NULL. If 'createIfNotInitalized' is true then the Extensions object is automatically created. However, in this case the extension object is only created with the graphics context associated with ContextID.. "); - I_StaticMethod2(void, setExtensions, IN, unsigned int, contextID, IN, osg::BufferObject::Extensions *, extensions, - __void__setExtensions__unsigned_int__Extensions_P1_S, - "setExtensions allows users to override the extensions across graphics contexts. ", - "typically used when you have different extensions supported across graphics pipes but need to ensure that they all use the same low common denominator extensions. "); + I_Method1(unsigned int, addBufferData, IN, osg::BufferData *, bd, + Properties::NON_VIRTUAL, + __unsigned_int__addBufferData__BufferData_P1, + "", + ""); + I_Method1(void, removeBufferData, IN, unsigned int, index, + Properties::NON_VIRTUAL, + __void__removeBufferData__unsigned_int, + "", + ""); + I_Method1(void, removeBufferData, IN, osg::BufferData *, bd, + Properties::NON_VIRTUAL, + __void__removeBufferData__BufferData_P1, + "", + ""); + I_Method2(void, setBufferData, IN, unsigned int, index, IN, osg::BufferData *, bd, + Properties::NON_VIRTUAL, + __void__setBufferData__unsigned_int__BufferData_P1, + "", + ""); + I_Method1(osg::BufferData *, getBufferData, IN, unsigned int, index, + Properties::NON_VIRTUAL, + __BufferData_P1__getBufferData__unsigned_int, + "", + ""); + I_Method1(const osg::BufferData *, getBufferData, IN, unsigned int, index, + Properties::NON_VIRTUAL, + __C5_BufferData_P1__getBufferData__unsigned_int, + "", + ""); + I_Method0(unsigned int, getNumBufferData, + Properties::NON_VIRTUAL, + __unsigned_int__getNumBufferData, + "", + ""); + I_Method1(osg::GLBufferObject *, getGLBufferObject, IN, unsigned int, contextID, + Properties::NON_VIRTUAL, + __GLBufferObject_P1__getGLBufferObject__unsigned_int, + "", + ""); + I_Method1(osg::GLBufferObject *, getOrCreateGLBufferObject, IN, unsigned int, contextID, + Properties::NON_VIRTUAL, + __GLBufferObject_P1__getOrCreateGLBufferObject__unsigned_int, + "", + ""); + I_ArrayProperty(osg::BufferData *, BufferData, + __BufferData_P1__getBufferData__unsigned_int, + __void__setBufferData__unsigned_int__BufferData_P1, + __unsigned_int__getNumBufferData, + __unsigned_int__addBufferData__BufferData_P1, + 0, + __void__removeBufferData__unsigned_int); + I_SimpleProperty(GLenum, Target, + __GLenum__getTarget, + __void__setTarget__GLenum); I_SimpleProperty(GLenum, Usage, __GLenum__getUsage, __void__setUsage__GLenum); END_REFLECTOR -BEGIN_VALUE_REFLECTOR(osg::BufferObject::BufferEntry) - I_DeclaringFile("osg/BufferObject"); - I_Constructor0(____BufferEntry, - "", - ""); - I_Constructor1(IN, const osg::BufferObject::BufferEntry &, be, - Properties::NON_EXPLICIT, - ____BufferEntry__C5_BufferEntry_R1, - "", - ""); - I_PublicMemberProperty(osg::buffered_value< unsigned int >, modifiedCount); - I_PublicMemberProperty(unsigned int, dataSize); - I_PublicMemberProperty(unsigned int, offset); -END_REFLECTOR - -TYPE_NAME_ALIAS(std::pair< osg::BufferObject::BufferEntry COMMA osg::DrawElements * >, osg::ElementBufferObject::BufferEntryDrawElementsPair) - -TYPE_NAME_ALIAS(std::vector< osg::ElementBufferObject::BufferEntryDrawElementsPair >, osg::ElementBufferObject::BufferEntryDrawElementsPairs) - BEGIN_OBJECT_REFLECTOR(osg::ElementBufferObject) I_DeclaringFile("osg/BufferObject"); I_BaseType(osg::BufferObject); @@ -215,28 +308,145 @@ BEGIN_OBJECT_REFLECTOR(osg::ElementBufferObject) __C5_DrawElements_P1__getDrawElements__unsigned_int, "", ""); - I_Method1(const GLvoid *, getOffset, IN, unsigned int, i, - Properties::NON_VIRTUAL, - __C5_GLvoid_P1__getOffset__unsigned_int, - "", - ""); - I_Method1(void, compileBuffer, IN, osg::State &, state, - Properties::VIRTUAL, - __void__compileBuffer__State_R1, - "", - ""); - I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, - Properties::VIRTUAL, - __void__resizeGLObjectBuffers__unsigned_int, - "Resize any per context GLObject buffers to specified size. ", - ""); I_IndexedProperty(osg::DrawElements *, DrawElements, __DrawElements_P1__getDrawElements__unsigned_int, __void__setDrawElements__unsigned_int__DrawElements_P1, 0); END_REFLECTOR -TYPE_NAME_ALIAS(std::pair< osg::BufferObject::BufferEntry COMMA osg::Image * >, osg::PixelBufferObject::BufferEntryImagePair) +BEGIN_OBJECT_REFLECTOR(osg::GLBufferObject) + I_DeclaringFile("osg/BufferObject"); + I_BaseType(osg::Referenced); + I_ConstructorWithDefaults2(IN, unsigned int, contextID, , IN, osg::BufferObject *, bufferObject, 0, + ____GLBufferObject__unsigned_int__BufferObject_P1, + "", + ""); + I_Method1(void, setBufferObject, IN, osg::BufferObject *, bufferObject, + Properties::NON_VIRTUAL, + __void__setBufferObject__BufferObject_P1, + "", + ""); + I_Method0(osg::BufferObject *, getBufferObject, + Properties::NON_VIRTUAL, + __BufferObject_P1__getBufferObject, + "", + ""); + I_Method0(unsigned int, getContextID, + Properties::NON_VIRTUAL, + __unsigned_int__getContextID, + "", + ""); + I_Method0(GLuint &, getGLObjectID, + Properties::NON_VIRTUAL, + __GLuint_R1__getGLObjectID, + "", + ""); + I_Method0(GLuint, getGLObjectID, + Properties::NON_VIRTUAL, + __GLuint__getGLObjectID, + "", + ""); + I_Method1(GLsizeiptrARB, getOffset, IN, unsigned int, i, + Properties::NON_VIRTUAL, + __GLsizeiptrARB__getOffset__unsigned_int, + "", + ""); + I_Method0(void, bindBuffer, + Properties::NON_VIRTUAL, + __void__bindBuffer, + "", + ""); + I_Method0(void, unbindBuffer, + Properties::NON_VIRTUAL, + __void__unbindBuffer, + "", + ""); + I_Method0(bool, isDirty, + Properties::NON_VIRTUAL, + __bool__isDirty, + "", + ""); + I_Method0(void, dirty, + Properties::NON_VIRTUAL, + __void__dirty, + "", + ""); + I_Method0(void, clear, + Properties::NON_VIRTUAL, + __void__clear, + "", + ""); + I_Method0(void, compileBuffer, + Properties::NON_VIRTUAL, + __void__compileBuffer, + "", + ""); + I_Method0(void, deleteGLObject, + Properties::NON_VIRTUAL, + __void__deleteGLObject, + "", + ""); + I_Method1(void, assign, IN, osg::BufferObject *, bufferObject, + Properties::NON_VIRTUAL, + __void__assign__BufferObject_P1, + "", + ""); + I_Method0(bool, isPBOSupported, + Properties::NON_VIRTUAL, + __bool__isPBOSupported, + "", + ""); + I_StaticMethod2(osg::GLBufferObject *, createGLBufferObject, IN, unsigned int, contextID, IN, const osg::BufferObject *, bufferObject, + __GLBufferObject_P1__createGLBufferObject__unsigned_int__C5_BufferObject_P1_S, + "", + ""); + 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. ", + ""); + I_StaticMethod3(void, flushDeletedBufferObjects, IN, unsigned int, contextID, IN, double, x, IN, double &, availableTime, + __void__flushDeletedBufferObjects__unsigned_int__double__double_R1_S, + "flush all the cached display list which need to be deleted in the OpenGL context related to contextID. ", + ""); + I_StaticMethod1(void, discardDeletedBufferObjects, IN, unsigned int, contextID, + __void__discardDeletedBufferObjects__unsigned_int_S, + "dicard all the cached display list which need to be deleted in the OpenGL context related to contextID. ", + "Note, unlike flush no OpenGL calls are made, instead the handles are all removed. this call is useful for when an OpenGL context has been destroyed. "); + I_StaticMethod2(osg::GLBufferObject::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized, + __Extensions_P1__getExtensions__unsigned_int__bool_S, + "Function to call to get the extension of a specified context. ", + "If the Extension object for that context has not yet been created and the 'createIfNotInitalized' flag been set to false then returns NULL. If 'createIfNotInitalized' is true then the Extensions object is automatically created. However, in this case the extension object is only created with the graphics context associated with ContextID.. "); + I_StaticMethod2(void, setExtensions, IN, unsigned int, contextID, IN, osg::GLBufferObject::Extensions *, extensions, + __void__setExtensions__unsigned_int__Extensions_P1_S, + "setExtensions allows users to override the extensions across graphics contexts. ", + "typically used when you have different extensions supported across graphics pipes but need to ensure that they all use the same low common denominator extensions. "); + I_SimpleProperty(osg::BufferObject *, BufferObject, + __BufferObject_P1__getBufferObject, + __void__setBufferObject__BufferObject_P1); + I_SimpleProperty(unsigned int, ContextID, + __unsigned_int__getContextID, + 0); + I_SimpleProperty(GLuint, GLObjectID, + __GLuint__getGLObjectID, + 0); + I_PublicMemberProperty(osg::GLBufferObject::Extensions *, _extensions); +END_REFLECTOR + +BEGIN_VALUE_REFLECTOR(osg::GLBufferObject::BufferEntry) + I_DeclaringFile("osg/BufferObject"); + I_Constructor0(____BufferEntry, + "", + ""); + I_Constructor1(IN, const osg::GLBufferObject::BufferEntry &, rhs, + Properties::NON_EXPLICIT, + ____BufferEntry__C5_BufferEntry_R1, + "", + ""); + I_PublicMemberProperty(unsigned int, modifiedCount); + I_PublicMemberProperty(GLsizeiptrARB, dataSize); + I_PublicMemberProperty(GLsizeiptrARB, offset); + I_PublicMemberProperty(osg::BufferData *, dataSource); +END_REFLECTOR BEGIN_OBJECT_REFLECTOR(osg::PixelBufferObject) I_DeclaringFile("osg/BufferObject"); @@ -290,21 +500,11 @@ BEGIN_OBJECT_REFLECTOR(osg::PixelBufferObject) __C5_Image_P1__getImage, "", ""); - I_Method0(unsigned int, offset, + I_Method1(bool, isPBOSupported, IN, unsigned int, contextID, Properties::NON_VIRTUAL, - __unsigned_int__offset, + __bool__isPBOSupported__unsigned_int, "", ""); - I_Method1(void, compileBuffer, IN, osg::State &, state, - Properties::VIRTUAL, - __void__compileBuffer__State_R1, - "", - ""); - I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, - Properties::VIRTUAL, - __void__resizeGLObjectBuffers__unsigned_int, - "Resize any per context GLObject buffers to specified size. ", - ""); I_SimpleProperty(osg::Image *, Image, __Image_P1__getImage, __void__setImage__osg_Image_P1); @@ -397,10 +597,6 @@ BEGIN_OBJECT_REFLECTOR(osg::PixelDataBufferObject) __void__setDataSize__unsigned_int); END_REFLECTOR -TYPE_NAME_ALIAS(std::pair< osg::BufferObject::BufferEntry COMMA osg::Array * >, osg::VertexBufferObject::BufferEntryArrayPair) - -TYPE_NAME_ALIAS(std::vector< osg::VertexBufferObject::BufferEntryArrayPair >, osg::VertexBufferObject::BufferEntryArrayPairs) - BEGIN_OBJECT_REFLECTOR(osg::VertexBufferObject) I_DeclaringFile("osg/BufferObject"); I_BaseType(osg::BufferObject); @@ -461,34 +657,9 @@ BEGIN_OBJECT_REFLECTOR(osg::VertexBufferObject) __C5_Array_P1__getArray__unsigned_int, "", ""); - I_Method1(const GLvoid *, getOffset, IN, unsigned int, i, - Properties::NON_VIRTUAL, - __C5_GLvoid_P1__getOffset__unsigned_int, - "", - ""); - I_Method1(void, compileBuffer, IN, osg::State &, state, - Properties::VIRTUAL, - __void__compileBuffer__State_R1, - "", - ""); - I_Method1(void, resizeGLObjectBuffers, IN, unsigned int, maxSize, - Properties::VIRTUAL, - __void__resizeGLObjectBuffers__unsigned_int, - "Resize any per context GLObject buffers to specified size. ", - ""); I_IndexedProperty(osg::Array *, Array, __Array_P1__getArray__unsigned_int, __void__setArray__unsigned_int__Array_P1, 0); END_REFLECTOR -STD_PAIR_REFLECTOR(std::pair< osg::BufferObject::BufferEntry COMMA osg::Array * >) - -STD_PAIR_REFLECTOR(std::pair< osg::BufferObject::BufferEntry COMMA osg::DrawElements * >) - -STD_PAIR_REFLECTOR(std::pair< osg::BufferObject::BufferEntry COMMA osg::Image * >) - -STD_VECTOR_REFLECTOR(std::vector< osg::ElementBufferObject::BufferEntryDrawElementsPair >) - -STD_VECTOR_REFLECTOR(std::vector< osg::VertexBufferObject::BufferEntryArrayPair >) - diff --git a/src/osgWrappers/osg/Image.cpp b/src/osgWrappers/osg/Image.cpp index 99051335e..26e01309a 100644 --- a/src/osgWrappers/osg/Image.cpp +++ b/src/osgWrappers/osg/Image.cpp @@ -52,7 +52,7 @@ TYPE_NAME_ALIAS(std::vector< unsigned int >, osg::Image::MipmapDataType) BEGIN_OBJECT_REFLECTOR(osg::Image) I_DeclaringFile("osg/Image"); - I_BaseType(osg::Object); + I_BaseType(osg::BufferData); I_Constructor0(____Image, "", ""); @@ -85,6 +85,16 @@ BEGIN_OBJECT_REFLECTOR(osg::Image) __C5_char_P1__className, "return the name of the object's class type. ", "Must be defined by derived classes. "); + I_Method0(const GLvoid *, getDataPointer, + Properties::VIRTUAL, + __C5_GLvoid_P1__getDataPointer, + "", + ""); + I_Method0(unsigned int, getTotalDataSize, + Properties::VIRTUAL, + __unsigned_int__getTotalDataSize, + "", + ""); I_Method1(int, compare, IN, const osg::Image &, rhs, Properties::VIRTUAL, __int__compare__C5_Image_R1, @@ -310,21 +320,6 @@ BEGIN_OBJECT_REFLECTOR(osg::Image) __void__ensureValidSizeForTexturing__GLint, "Ensure image dimensions are a power of two. ", "Mipmapped textures require the image dimensions to be power of two and are within the maxiumum texture size for the host machine. "); - I_Method0(void, dirty, - Properties::NON_VIRTUAL, - __void__dirty, - "Dirty the image, which increments the modified count, to force osg::Texture to reload the image. ", - ""); - I_Method1(void, setModifiedCount, IN, unsigned int, value, - Properties::NON_VIRTUAL, - __void__setModifiedCount__unsigned_int, - "Set the modified count value. ", - "Used by osg::Texture when using texture subloading. "); - I_Method0(unsigned int, getModifiedCount, - Properties::NON_VIRTUAL, - __unsigned_int__getModifiedCount, - "Get modified count value. ", - "Used by osg::Texture when using texture subloading. "); I_Method0(bool, isMipmap, Properties::NON_VIRTUAL, __bool__isMipmap, @@ -447,6 +442,9 @@ BEGIN_OBJECT_REFLECTOR(osg::Image) I_SimpleProperty(osg::Image::AllocationMode, AllocationMode, __AllocationMode__getAllocationMode, __void__setAllocationMode__AllocationMode); + I_SimpleProperty(const GLvoid *, DataPointer, + __C5_GLvoid_P1__getDataPointer, + 0); I_SimpleProperty(GLenum, DataType, __GLenum__getDataType, __void__setDataType__GLenum); @@ -465,9 +463,6 @@ BEGIN_OBJECT_REFLECTOR(osg::Image) I_SimpleProperty(const osg::Image::MipmapDataType &, MipmapLevels, __C5_MipmapDataType_R1__getMipmapLevels, __void__setMipmapLevels__C5_MipmapDataType_R1); - I_SimpleProperty(unsigned int, ModifiedCount, - __unsigned_int__getModifiedCount, - __void__setModifiedCount__unsigned_int); I_SimpleProperty(osg::Image::Origin, Origin, __Origin__getOrigin, __void__setOrigin__Origin); @@ -489,6 +484,9 @@ BEGIN_OBJECT_REFLECTOR(osg::Image) I_SimpleProperty(unsigned int, RowSizeInBytes, __unsigned_int__getRowSizeInBytes, 0); + I_SimpleProperty(unsigned int, TotalDataSize, + __unsigned_int__getTotalDataSize, + 0); I_SimpleProperty(unsigned int, TotalSizeInBytes, __unsigned_int__getTotalSizeInBytes, 0); diff --git a/src/osgWrappers/osg/PrimitiveSet.cpp b/src/osgWrappers/osg/PrimitiveSet.cpp index b99285283..07b3df6fe 100644 --- a/src/osgWrappers/osg/PrimitiveSet.cpp +++ b/src/osgWrappers/osg/PrimitiveSet.cpp @@ -157,11 +157,6 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::DrawElements) __C5_DrawElements_P1__getDrawElements, "", ""); - I_Method0(void, dirty, - Properties::VIRTUAL, - __void__dirty, - "Dirty the primitive, which increments the modified count, to force buffer objects to update. ", - ""); I_Method1(void, setElementBufferObject, IN, osg::ElementBufferObject *, ebo, Properties::NON_VIRTUAL, __void__setElementBufferObject__osg_ElementBufferObject_P1, @@ -177,26 +172,6 @@ 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, setElementBufferObjectOffset, IN, const GLvoid *, offset, - Properties::NON_VIRTUAL, - __void__setElementBufferObjectOffset__C5_GLvoid_P1, - "Set the offset into the ElementBufferObject, if used. ", - ""); - I_Method0(const GLvoid *, getElementBufferObjectOffset, - Properties::NON_VIRTUAL, - __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 objects for all graphics contexts. "); I_Method1(void, reserveElements, IN, unsigned int, numIndices, Properties::PURE_VIRTUAL, __void__reserveElements__unsigned_int, @@ -223,9 +198,6 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::DrawElements) I_SimpleProperty(osg::ElementBufferObject *, ElementBufferObject, __osg_ElementBufferObject_P1__getElementBufferObject, __void__setElementBufferObject__osg_ElementBufferObject_P1); - 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) @@ -429,7 +401,7 @@ END_REFLECTOR BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::PrimitiveSet) I_DeclaringFile("osg/PrimitiveSet"); - I_BaseType(osg::Object); + I_BaseType(osg::BufferData); I_ConstructorWithDefaults3(IN, osg::PrimitiveSet::Type, primType, osg::PrimitiveSet::PrimitiveType, IN, GLenum, mode, 0, IN, int, numInstances, 0, ____PrimitiveSet__Type__GLenum__int, "", @@ -538,31 +510,6 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::PrimitiveSet) __unsigned_int__getNumPrimitives, "", ""); - I_Method0(void, dirty, - Properties::VIRTUAL, - __void__dirty, - "Dirty the primitive, which increments the modified count, to force buffer objects to update. ", - ""); - I_Method1(void, setModifiedCount, IN, unsigned int, value, - Properties::NON_VIRTUAL, - __void__setModifiedCount__unsigned_int, - "Set the modified count value. ", - ""); - I_Method0(unsigned int, getModifiedCount, - Properties::NON_VIRTUAL, - __unsigned_int__getModifiedCount, - "Get modified count value. ", - ""); - I_Method1(void, resizeGLObjectBuffers, IN, unsigned, int, - Properties::VIRTUAL, - __void__resizeGLObjectBuffers__unsigned, - "Resize any per context GLObject buffers to specified size. ", - ""); - I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, x, 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 objects for all graphics contexts. "); I_Method0(void, computeRange, Properties::VIRTUAL, __void__computeRange, @@ -577,9 +524,6 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::PrimitiveSet) I_SimpleProperty(GLenum, Mode, __GLenum__getMode, __void__setMode__GLenum); - I_SimpleProperty(unsigned int, ModifiedCount, - __unsigned_int__getModifiedCount, - __void__setModifiedCount__unsigned_int); I_SimpleProperty(int, NumInstances, 0, __void__setNumInstances__int); diff --git a/src/osgWrappers/osg/State.cpp b/src/osgWrappers/osg/State.cpp index f6d2a703b..d5a05e259 100644 --- a/src/osgWrappers/osg/State.cpp +++ b/src/osgWrappers/osg/State.cpp @@ -331,19 +331,19 @@ BEGIN_OBJECT_REFLECTOR(osg::State) __void__dirtyAllVertexArrays, "dirty the vertex, normal, color, tex coords, secondary color, fog coord and index arrays. ", ""); - I_Method1(void, setCurrentVertexBufferObject, IN, osg::VertexBufferObject *, vbo, + I_Method1(void, setCurrentVertexBufferObject, IN, osg::GLBufferObject *, vbo, Properties::NON_VIRTUAL, - __void__setCurrentVertexBufferObject__osg_VertexBufferObject_P1, + __void__setCurrentVertexBufferObject__osg_GLBufferObject_P1, "", ""); - I_Method0(const osg::VertexBufferObject *, getCurrentVertexBufferObject, + I_Method0(const osg::GLBufferObject *, getCurrentVertexBufferObject, Properties::NON_VIRTUAL, - __C5_VertexBufferObject_P1__getCurrentVertexBufferObject, + __C5_GLBufferObject_P1__getCurrentVertexBufferObject, "", ""); - I_Method1(void, bindVertexBufferObject, IN, const osg::VertexBufferObject *, vbo, + I_Method1(void, bindVertexBufferObject, IN, osg::GLBufferObject *, vbo, Properties::NON_VIRTUAL, - __void__bindVertexBufferObject__C5_osg_VertexBufferObject_P1, + __void__bindVertexBufferObject__osg_GLBufferObject_P1, "", ""); I_Method0(void, unbindVertexBufferObject, @@ -351,19 +351,19 @@ BEGIN_OBJECT_REFLECTOR(osg::State) __void__unbindVertexBufferObject, "", ""); - I_Method1(void, setCurrentElementBufferObject, IN, osg::ElementBufferObject *, ebo, + I_Method1(void, setCurrentElementBufferObject, IN, osg::GLBufferObject *, ebo, Properties::NON_VIRTUAL, - __void__setCurrentElementBufferObject__osg_ElementBufferObject_P1, + __void__setCurrentElementBufferObject__osg_GLBufferObject_P1, "", ""); - I_Method0(const osg::ElementBufferObject *, getCurrentElementBufferObject, + I_Method0(const osg::GLBufferObject *, getCurrentElementBufferObject, Properties::NON_VIRTUAL, - __C5_ElementBufferObject_P1__getCurrentElementBufferObject, + __C5_GLBufferObject_P1__getCurrentElementBufferObject, "", ""); - I_Method1(void, bindElementBufferObject, IN, const osg::ElementBufferObject *, ebo, + I_Method1(void, bindElementBufferObject, IN, osg::GLBufferObject *, ebo, Properties::NON_VIRTUAL, - __void__bindElementBufferObject__C5_osg_ElementBufferObject_P1, + __void__bindElementBufferObject__osg_GLBufferObject_P1, "", ""); I_Method0(void, unbindElementBufferObject, @@ -371,19 +371,19 @@ BEGIN_OBJECT_REFLECTOR(osg::State) __void__unbindElementBufferObject, "", ""); - I_Method1(void, setCurrentPixelBufferObject, IN, osg::PixelBufferObject *, pbo, + I_Method1(void, setCurrentPixelBufferObject, IN, osg::GLBufferObject *, pbo, Properties::NON_VIRTUAL, - __void__setCurrentPixelBufferObject__osg_PixelBufferObject_P1, + __void__setCurrentPixelBufferObject__osg_GLBufferObject_P1, "", ""); - I_Method0(const osg::PixelBufferObject *, getCurrentPixelBufferObject, + I_Method0(const osg::GLBufferObject *, getCurrentPixelBufferObject, Properties::NON_VIRTUAL, - __C5_PixelBufferObject_P1__getCurrentPixelBufferObject, + __C5_GLBufferObject_P1__getCurrentPixelBufferObject, "", ""); - I_Method1(void, bindPixelBufferObject, IN, const osg::PixelBufferObject *, pbo, + I_Method1(void, bindPixelBufferObject, IN, osg::GLBufferObject *, pbo, Properties::NON_VIRTUAL, - __void__bindPixelBufferObject__C5_osg_PixelBufferObject_P1, + __void__bindPixelBufferObject__osg_GLBufferObject_P1, "", ""); I_Method0(void, unbindPixelBufferObject, @@ -830,15 +830,15 @@ BEGIN_OBJECT_REFLECTOR(osg::State) I_SimpleProperty(unsigned int, ContextID, __unsigned_int__getContextID, __void__setContextID__unsigned_int); - I_SimpleProperty(osg::ElementBufferObject *, CurrentElementBufferObject, + I_SimpleProperty(osg::GLBufferObject *, CurrentElementBufferObject, 0, - __void__setCurrentElementBufferObject__osg_ElementBufferObject_P1); - I_SimpleProperty(osg::PixelBufferObject *, CurrentPixelBufferObject, + __void__setCurrentElementBufferObject__osg_GLBufferObject_P1); + I_SimpleProperty(osg::GLBufferObject *, CurrentPixelBufferObject, 0, - __void__setCurrentPixelBufferObject__osg_PixelBufferObject_P1); - I_SimpleProperty(osg::VertexBufferObject *, CurrentVertexBufferObject, + __void__setCurrentPixelBufferObject__osg_GLBufferObject_P1); + I_SimpleProperty(osg::GLBufferObject *, CurrentVertexBufferObject, 0, - __void__setCurrentVertexBufferObject__osg_VertexBufferObject_P1); + __void__setCurrentVertexBufferObject__osg_GLBufferObject_P1); I_SimpleProperty(const osg::Viewport *, CurrentViewport, __C5_Viewport_P1__getCurrentViewport, 0);