Index: /OpenSceneGraph/trunk/include/osg/DisplaySettings
===================================================================
--- /OpenSceneGraph/trunk/include/osg/DisplaySettings (revision 10588)
+++ /OpenSceneGraph/trunk/include/osg/DisplaySettings (revision 10601)
@@ -204,9 +204,6 @@
         unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
 
-        void setMaxVBOPoolSize(unsigned int size) { _maxVBOPoolSize = size; }
-        unsigned int getMaxVBOPoolSize() const { return _maxVBOPoolSize; }
-
-        void setMaxFBOPoolSize(unsigned int size) { _maxFBOPoolSize = size; }
-        unsigned int getMaxFBOPoolSize() const { return _maxFBOPoolSize; }
+        void setMaxBufferObjectPoolSize(unsigned int size) { _maxBufferObjectPoolSize = size; }
+        unsigned int getMaxBufferObjectPoolSize() const { return _maxBufferObjectPoolSize; }
 
     protected:
@@ -252,6 +249,5 @@
 
         unsigned int                    _maxTexturePoolSize;
-        unsigned int                    _maxVBOPoolSize;
-        unsigned int                    _maxFBOPoolSize;
+        unsigned int                    _maxBufferObjectPoolSize;
 };
 
Index: /OpenSceneGraph/trunk/include/osg/Texture
===================================================================
--- /OpenSceneGraph/trunk/include/osg/Texture (revision 10597)
+++ /OpenSceneGraph/trunk/include/osg/Texture (revision 10601)
@@ -1001,5 +1001,5 @@
         typedef std::list< ref_ptr<TextureObject> > TextureObjectList;
 
-        class TextureObjectSet : public Referenced
+        class OSG_EXPORT TextureObjectSet : public Referenced
         {
         public:
Index: /OpenSceneGraph/trunk/include/osg/BufferObject
===================================================================
--- /OpenSceneGraph/trunk/include/osg/BufferObject (revision 10600)
+++ /OpenSceneGraph/trunk/include/osg/BufferObject (revision 10601)
@@ -18,4 +18,8 @@
 #include <osg/Object>
 #include <osg/buffered_value>
+#include <osg/FrameStamp>
+
+#include <list>
+#include <map>
 
 #ifndef GL_ARB_vertex_buffer_object
@@ -103,4 +107,62 @@
 class BufferObject;
 
+class BufferObjectProfile
+{
+    public:
+        BufferObjectProfile():
+            _target(0),
+            _usage(0),
+            _size(0) {}
+
+        BufferObjectProfile(GLenum target, GLenum usage, unsigned int size):
+            _target(target),
+            _usage(usage),
+            _size(size) {}
+
+        BufferObjectProfile(const BufferObjectProfile& bpo):
+            _target(bpo._target),
+            _usage(bpo._usage),
+            _size(bpo._size) {}
+
+        bool operator < (const BufferObjectProfile& rhs) const
+        {
+            if (_target < rhs._target) return true;
+            else if (_target > rhs._target) return false;
+            if (_usage < rhs._usage) return true;
+            else if (_usage > rhs._usage) return false;
+            return _size < rhs._size;
+        }
+
+        bool operator == (const BufferObjectProfile& rhs) const
+        {
+            return (_target == rhs._target) &&
+                   (_usage == rhs._usage) &&
+                   (_size == rhs._size);
+        }
+
+        void setProfile(GLenum target, GLenum usage, unsigned int size)
+        {
+            _target = target;
+            _usage = usage;
+            _size = size;
+        }
+
+        BufferObjectProfile& operator = (const BufferObjectProfile& rhs)
+        {
+            _target = rhs._target;
+            _usage = rhs._usage;
+            _size = rhs._size;
+            return *this;
+        }
+
+        GLenum _target;
+        GLenum _usage;
+        GLenum _size;
+};
+
+// forward declare
+class GLBufferObjectSet;
+class GLBufferObjectManager;
+
 class OSG_EXPORT GLBufferObject : public Referenced
 {
@@ -108,4 +170,7 @@
 
         GLBufferObject(unsigned int contextID, BufferObject* bufferObject=0);
+
+        void setProfile(const BufferObjectProfile& profile) { _profile = profile; }
+        const BufferObjectProfile& getProfile() const { return _profile; }
 
         void setBufferObject(BufferObject* bufferObject);
@@ -144,12 +209,9 @@
         inline GLsizeiptrARB getOffset(unsigned int i) const { return _bufferEntries[i].offset; }
 
-        inline void bindBuffer() const
+        void bindBuffer();
+
+        inline void unbindBuffer()
         { 
-            _extensions->glBindBuffer(_target,_glObjectID);
-        }
-
-        inline void unbindBuffer() const
-        { 
-            _extensions->glBindBuffer(_target,0);
+            _extensions->glBindBuffer(_profile._target,0);
         }
 
@@ -177,13 +239,8 @@
         static void deleteBufferObject(unsigned int contextID,GLuint globj);
 
-        /** flush all the cached display list which need to be deleted
-          * in the OpenGL context related to contextID.*/
-        static void flushDeletedBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime);
-
-        /** 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. */
-        static void discardDeletedBufferObjects(unsigned int contextID);
+        static void flushAllDeletedBufferObjects(unsigned int contextID);
+        static void discardAllDeletedBufferObjects(unsigned int contextID);
+        static void flushDeletedBufferObjects(unsigned int contextID,double currentTime, double& availbleTime);
+        static void releaseGLBufferObject(unsigned int contextID, GLBufferObject* to);
 
         /** Extensions class which encapsulates the querying of extensions and
@@ -265,10 +322,8 @@
         GLuint                  _glObjectID;
 
-        GLenum                  _target;
-        GLenum                  _usage;
+        BufferObjectProfile     _profile;
+        unsigned int            _allocatedSize;
 
         bool                    _dirty;
-
-        mutable unsigned int    _totalSize;
 
         typedef std::vector<BufferEntry> BufferEntries;
@@ -278,7 +333,139 @@
 
     public:
+
+        GLBufferObjectSet*      _set;
+        GLBufferObject*         _previous;
+        GLBufferObject*         _next;
+        unsigned int            _frameLastUsed;
+
+    public:
         Extensions*             _extensions;
 
 };
+
+typedef std::list< ref_ptr<GLBufferObject> > GLBufferObjectList;
+
+class OSG_EXPORT GLBufferObjectSet : public Referenced
+{
+    public:
+        GLBufferObjectSet(GLBufferObjectManager* parent, const BufferObjectProfile& profile);
+
+        void handlePendingOrphandedGLBufferObjects();
+        void flushAllDeletedGLBufferObjects();
+        void discardAllDeletedGLBufferObjects();
+        void flushDeletedGLBufferObjects(double currentTime, double& availableTime);
+
+        GLBufferObject* takeFromOrphans(BufferObject* bufferObject);
+        GLBufferObject* takeOrGenerate(BufferObject* bufferObject);
+
+        void moveToBack(GLBufferObject* to);
+        void addToBack(GLBufferObject* to);
+        void orphan(GLBufferObject* to);
+        void remove(GLBufferObject* to);
+
+        unsigned int size() const { return _profile._size * _numOfGLBufferObjects; }
+
+        bool makeSpace(unsigned int& size);
+
+        bool checkConsistency() const;
+
+        GLBufferObjectManager* getParent() { return _parent; }
+
+
+    protected:
+
+        virtual ~GLBufferObjectSet();
+
+        OpenThreads::Mutex  _mutex;
+
+        GLBufferObjectManager*  _parent;
+        unsigned int            _contextID;
+        BufferObjectProfile     _profile;
+        unsigned int            _numOfGLBufferObjects;
+        GLBufferObjectList      _orphanedGLBufferObjects;
+        GLBufferObjectList      _pendingOrphanedGLBufferObjects;
+
+        GLBufferObject*         _head;
+        GLBufferObject*         _tail;
+};
+
+class OSG_EXPORT GLBufferObjectManager : public osg::Referenced
+{
+    public:
+        GLBufferObjectManager(unsigned int contextID);
+
+        unsigned int getContextID() const { return _contextID; }
+
+
+        void setNumberActiveGLBufferObjects(unsigned int size) { _numActiveGLBufferObjects = size; }
+        unsigned int& getNumberActiveGLBufferObjects() { return _numActiveGLBufferObjects; }
+        unsigned int getNumberActiveGLBufferObjects() const { return _numActiveGLBufferObjects; }
+
+        void setNumberOrphanedGLBufferObjects(unsigned int size) { _numOrphanedGLBufferObjects = size; }
+        unsigned int& getNumberOrphanedGLBufferObjects() { return _numOrphanedGLBufferObjects; }
+        unsigned int getNumberOrphanedGLBufferObjects() const { return _numOrphanedGLBufferObjects; }
+
+        void setCurrGLBufferObjectPoolSize(unsigned int size) { _currGLBufferObjectPoolSize = size; }
+        unsigned int& getCurrGLBufferObjectPoolSize() { return _currGLBufferObjectPoolSize; }
+        unsigned int getCurrGLBufferObjectPoolSize() const { return _currGLBufferObjectPoolSize; }
+
+        void setMaxGLBufferObjectPoolSize(unsigned int size);
+        unsigned int getMaxGLBufferObjectPoolSize() const { return _maxGLBufferObjectPoolSize; }
+
+        bool hasSpace(unsigned int size) const { return (_currGLBufferObjectPoolSize+size)<=_maxGLBufferObjectPoolSize; }
+        bool makeSpace(unsigned int size);
+
+        GLBufferObject* generateGLBufferObject(const osg::BufferObject* bufferObject);
+
+        void handlePendingOrphandedGLBufferObjects();
+        void flushAllDeletedGLBufferObjects();
+        void discardAllDeletedGLBufferObjects();
+        void flushDeletedGLBufferObjects(double currentTime, double& availableTime);
+        void releaseGLBufferObject(GLBufferObject* to);
+
+        GLBufferObjectSet* getGLBufferObjectSet(const BufferObjectProfile& profile);
+
+        void newFrame(osg::FrameStamp* fs);
+        void resetStats();
+        void reportStats();
+
+        unsigned int& getFrameNumber() { return _frameNumber; }
+        unsigned int& getNumberFrames() { return _numFrames; }
+
+        unsigned int& getNumberDeleted() { return _numDeleted; }
+        double& getDeleteTime() { return _deleteTime; }
+
+        unsigned int& getNumberGenerated() { return _numGenerated; }
+        double& getGenerateTime() { return _generateTime; }
+
+        unsigned int& getNumberApplied() { return _numApplied; }
+        double& getApplyTime() { return _applyTime; }
+
+        static osg::ref_ptr<GLBufferObjectManager>& getGLBufferObjectManager(unsigned int contextID);
+
+    protected:
+
+        typedef std::map< BufferObjectProfile, osg::ref_ptr<GLBufferObjectSet> > GLBufferObjectSetMap;
+        unsigned int            _contextID;
+        unsigned int            _numActiveGLBufferObjects;
+        unsigned int            _numOrphanedGLBufferObjects;
+        unsigned int            _currGLBufferObjectPoolSize;
+        unsigned int            _maxGLBufferObjectPoolSize;
+        GLBufferObjectSetMap    _glBufferObjectSetMap;
+
+        unsigned int            _frameNumber;
+
+        unsigned int            _numFrames;
+        unsigned int            _numDeleted;
+        double                  _deleteTime;
+
+        unsigned int            _numGenerated;
+        double                  _generateTime;
+
+        unsigned int            _numApplied;
+        double                  _applyTime;
+
+};
+
 
 class OSG_EXPORT BufferObject : public Object
@@ -295,6 +482,6 @@
         virtual const char* className() const { return "BufferObject"; }
 
-        void setTarget(GLenum target) { _target = target; }
-        GLenum getTarget() const { return _target; }
+        void setTarget(GLenum target) { _profile._target = target; }
+        GLenum getTarget() const { return _profile._target; }
 
         /** Set what type of usage the buffer object will have. Options are:
@@ -303,8 +490,11 @@
           *          GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.
           */
-        void setUsage(GLenum usage) { _usage = usage; }
+        void setUsage(GLenum usage) { _profile._usage = usage; }
 
         /** Get the type of usage the buffer object has been set up for.*/
-        GLenum getUsage() const { return _usage; }
+        GLenum getUsage() const { return _profile._usage; }
+
+        BufferObjectProfile& getProfile() { return _profile; }
+        const BufferObjectProfile& getProfile() const { return _profile; }
 
         void dirty();
@@ -327,4 +517,6 @@
 
         unsigned int getNumBufferData() const { return _bufferDataList.size(); }
+
+        void setGLBufferObject(unsigned int contextID, GLBufferObject* glbo) { _glBufferObjects[contextID] = glbo; }
 
         GLBufferObject* getGLBufferObject(unsigned int contextID) const { return _glBufferObjects[contextID].get(); }
@@ -336,4 +528,6 @@
         }
 
+        unsigned int computeRequiredBufferSize() const;
+
     protected:
 
@@ -343,6 +537,6 @@
         typedef osg::buffered_object< osg::ref_ptr<GLBufferObject> > GLBufferObjects;
 
-        GLenum                  _target;
-        GLenum                  _usage;
+        BufferObjectProfile     _profile;
+
         BufferDataList          _bufferDataList;
 
@@ -488,8 +682,8 @@
 
         //! Set new size of the buffer object. This will reallocate the memory on the next compile
-        inline void setDataSize(unsigned int size) { _dataSize = size; dirty(); }
+        inline void setDataSize(unsigned int size) { _profile._size = size; dirty(); }
 
         //! Get data size of the used buffer 
-        inline unsigned int getDataSize() const { return _dataSize; }
+        inline unsigned int getDataSize() const { return _profile._size; }
 
         //! Compile the buffer (reallocate the memory if buffer is dirty)
@@ -526,6 +720,4 @@
         virtual ~PixelDataBufferObject();
 
-        unsigned int _dataSize;
-
         typedef osg::buffered_value<unsigned int> ModeList;
         
Index: /OpenSceneGraph/trunk/include/osg/State
===================================================================
--- /OpenSceneGraph/trunk/include/osg/State (revision 10600)
+++ /OpenSceneGraph/trunk/include/osg/State (revision 10601)
@@ -412,5 +412,5 @@
             if (vbo == _currentVBO) return;
             if (vbo->isDirty()) vbo->compileBuffer();
-            else _glBindBuffer(GL_ARRAY_BUFFER_ARB,vbo->getGLObjectID());
+            else vbo->bindBuffer();
             _currentVBO = vbo;
         }
@@ -430,5 +430,5 @@
             if (ebo == _currentEBO) return;
             if (ebo->isDirty()) ebo->compileBuffer();
-            else _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,ebo->getGLObjectID());
+            else ebo->bindBuffer();
             _currentEBO = ebo;
         }
@@ -449,5 +449,5 @@
 
             if (pbo->isDirty()) pbo->compileBuffer();
-            else _glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,pbo->getGLObjectID());
+            else pbo->bindBuffer();
 
             _currentPBO = pbo;
@@ -1041,10 +1041,6 @@
         unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
 
-        void setMaxVBOPoolSize(unsigned int size);
-        unsigned int getMaxVBOPoolSize() const { return _maxVBOPoolSize; }
-
-        void setMaxFBOPoolSize(unsigned int size);
-        unsigned int getMaxFBOPoolSize() const { return _maxFBOPoolSize; }
-
+        void setMaxBufferObjectPoolSize(unsigned int size);
+        unsigned int getMaxBufferObjectPoolSize() const { return _maxBufferObjectPoolSize; }
 
 
@@ -1234,6 +1230,5 @@
 
         unsigned int                                                    _maxTexturePoolSize;
-        unsigned int                                                    _maxVBOPoolSize;
-        unsigned int                                                    _maxFBOPoolSize;
+        unsigned int                                                    _maxBufferObjectPoolSize;
 
 
Index: /OpenSceneGraph/trunk/src/osgUtil/SceneView.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgUtil/SceneView.cpp (revision 10595)
+++ /OpenSceneGraph/trunk/src/osgUtil/SceneView.cpp (revision 10601)
@@ -1026,4 +1026,7 @@
     tom->newFrame(state->getFrameStamp());
 
+    osg::GLBufferObjectManager::GLBufferObjectManager* bom = osg::GLBufferObjectManager::getGLBufferObjectManager(state->getContextID());
+    bom->newFrame(state->getFrameStamp());
+
     if (!_initCalled) init();
 
@@ -1567,4 +1570,5 @@
 #ifdef REPORT_TEXTURE_MANAGER_STATS
     tom->reportStats();
+    bom->reportStats();
 #endif
 
Index: /OpenSceneGraph/trunk/src/osg/Texture.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osg/Texture.cpp (revision 10600)
+++ /OpenSceneGraph/trunk/src/osg/Texture.cpp (revision 10601)
@@ -176,5 +176,5 @@
 bool Texture::TextureObjectSet::checkConsistency() const
 {
-    return true;
+//    return true;
 
     // osg::notify(osg::NOTICE)<<"TextureObjectSet::checkConsistency()"<<std::endl;
@@ -266,5 +266,5 @@
         GLuint id = (*itr)->id();
 
-        // osg::notify(osg::NOTICE)<<"Deleting textureobject id="<<id<<std::endl;
+        osg::notify(osg::NOTICE)<<"Deleting textureobject id="<<id<<std::endl;
 
         glDeleteTextures( 1L, &id);
@@ -328,5 +328,5 @@
         GLuint id = (*itr)->id();
 
-        // osg::notify(osg::NOTICE)<<"Deleting textureobject id="<<id<<std::endl;
+        osg::notify(osg::NOTICE)<<"Deleting textureobject id="<<id<<std::endl;
 
         glDeleteTextures( 1L, &id);
Index: /OpenSceneGraph/trunk/src/osg/BufferObject.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osg/BufferObject.cpp (revision 10600)
+++ /OpenSceneGraph/trunk/src/osg/BufferObject.cpp (revision 10601)
@@ -38,4 +38,6 @@
 static DeletedBufferObjectCache s_deletedBufferObjectCache;
 
+unsigned int s_minimumNumberOfGLBufferObjectsToRetainInCache = 1000;
+
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 //
@@ -45,9 +47,11 @@
     _contextID(contextID),
     _glObjectID(0),
-    _target(0),
-    _usage(0),
+    _profile(0,0,0),
+    _allocatedSize(0),
     _dirty(true),
-    _totalSize(0),
     _bufferObject(0),
+    _set(0),
+    _previous(0),
+    _next(0),
     _extensions(0)
 {
@@ -59,6 +63,15 @@
 GLBufferObject::~GLBufferObject()
 {
-    if (_glObjectID!=0) GLBufferObject::deleteBufferObject(_contextID, _glObjectID);
-
+}
+
+void GLBufferObject::bindBuffer()
+{
+    _extensions->glBindBuffer(_profile._target,_glObjectID);
+    if (_set) _set->moveToBack(this);
+}
+
+void GLBufferObject::setBufferObject(BufferObject* bufferObject)
+{
+    assign(bufferObject);
 }
 
@@ -69,8 +82,5 @@
     if (_bufferObject)
     {
-        _target = bufferObject->getTarget();
-        _usage = bufferObject->getUsage();
-
-        _totalSize = 0;
+        _profile = bufferObject->getProfile();
 
         _dirty = true;
@@ -80,8 +90,5 @@
     else
     {
-        _target = 0;
-        _usage = 0;
-
-        _totalSize = 0;
+        _profile.setProfile(0,0,0);
 
         // clear all previous entries;
@@ -101,6 +108,4 @@
 
     _bufferEntries.reserve(_bufferObject->getNumBufferData());
-
-    _totalSize = 0;
 
     bool compileAll = false;
@@ -156,4 +161,5 @@
     }
 
+
     if (i<_bufferEntries.size())
     {
@@ -162,10 +168,29 @@
     }
 
-    _extensions->glBindBuffer(_target, _glObjectID);
-
-    if (newTotalSize != _totalSize)
-    {
-        _totalSize = newTotalSize;
-        _extensions->glBufferData(_target, _totalSize, NULL, _usage);
+    _extensions->glBindBuffer(_profile._target, _glObjectID);
+
+    if (newTotalSize > _profile._size)
+    {
+        osg::notify(osg::NOTICE)<<"newTotalSize="<<newTotalSize<<", _profile._size="<<_profile._size<<std::endl;
+
+        _profile._size = newTotalSize;
+        if (_set)
+        {
+            // remove self from original set
+            _set->remove(this);
+
+            // get the new set for the new profile
+            _set = _set->getParent()->getGLBufferObjectSet(_profile);
+
+            // register self with new set.
+            _set->addToBack(this);
+        }
+
+    }
+
+    if (_allocatedSize != _profile._size)
+    {
+        _allocatedSize = _profile._size;
+        _extensions->glBufferData(_profile._target, _profile._size, NULL, _profile._usage);
     }
 
@@ -189,5 +214,5 @@
                 memcpy(vboMemory + (GLsizeiptrARB)entry.offset, entry.dataSource->getDataPointer(), entry.dataSize);
             else
-                _extensions->glBufferSubData(_target, (GLintptrARB)entry.offset, (GLsizeiptrARB)entry.dataSize, entry.dataSource->getDataPointer());
+                _extensions->glBufferSubData(_profile._target, (GLintptrARB)entry.offset, (GLsizeiptrARB)entry.dataSize, entry.dataSource->getDataPointer());
 
         }
@@ -195,10 +220,7 @@
 
     // 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*>(bufferObject));
+    if (vboMemory) _extensions->glUnmapBuffer(_profile._target);
+
+
 }
 
@@ -210,20 +232,14 @@
         _glObjectID = 0;
 
-        _totalSize = 0;
+        _allocatedSize = 0;
         _bufferEntries.clear();
     }
 }
 
-
 void GLBufferObject::deleteBufferObject(unsigned int contextID,GLuint globj)
 {
-    if (globj!=0)
-    {
-        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedBufferObjectCache);
-
-        // insert the globj into the cache for the appropriate context.
-        s_deletedBufferObjectCache[contextID].insert(BufferObjectMap::value_type(0,globj));
-    }
-}
+    osg::notify(osg::NOTICE)<<"GLBufferObject::deleteBufferObject("<<std::endl;
+}
+#if 0
 
 void GLBufferObject::flushDeletedBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime)
@@ -269,5 +285,5 @@
     dll.clear();
 }
-
+#endif
 //////////////////////////////////////////////////////////////////////////////
 //
@@ -420,13 +436,637 @@
 }
 
-#if 1
-
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 //
+// GLBufferObjectSet
+//
+GLBufferObjectSet::GLBufferObjectSet(GLBufferObjectManager* parent, const BufferObjectProfile& profile):
+    _parent(parent),
+    _contextID(parent->getContextID()),
+    _profile(profile),
+    _numOfGLBufferObjects(0),
+    _head(0),
+    _tail(0)
+{
+    osg::notify(osg::NOTICE)<<"GLBufferObjectSet::GLBufferObjectSet _profile._size="<<_profile._size<<std::endl;
+}
+
+GLBufferObjectSet::~GLBufferObjectSet()
+{
+#if 0
+    osg::notify(osg::NOTICE)<<"GLBufferObjectSet::~GLBufferObjectSet(), _numOfGLBufferObjects="<<_numOfGLBufferObjects<<std::endl;
+    osg::notify(osg::NOTICE)<<"     _orphanedGLBufferObjects = "<<_orphanedGLBufferObjects.size()<<std::endl;
+    osg::notify(osg::NOTICE)<<"     _head = "<<_head<<std::endl;
+    osg::notify(osg::NOTICE)<<"     _tail = "<<_tail<<std::endl;
+#endif
+}
+
+bool GLBufferObjectSet::checkConsistency() const
+{
+    return true;
+
+    // osg::notify(osg::NOTICE)<<"GLBufferObjectSet::checkConsistency()"<<std::endl;
+    // check consistency of linked list.
+    unsigned int numInList = 0;
+    GLBufferObject* to = _head;
+    while(to!=0)
+    {
+        ++numInList;
+
+        if (to->_next)
+        {
+            if ((to->_next)->_previous != to)
+            {
+                osg::notify(osg::NOTICE)<<"Error (to->_next)->_previous != to "<<std::endl;
+                throw "Error (to->_next)->_previous != to ";
+            }
+        }
+        else
+        {
+            if (_tail != to)
+            {
+                osg::notify(osg::NOTICE)<<"Error _trail != to"<<std::endl;
+                throw "Error _trail != to";
+            }
+        }
+
+        to = to->_next;
+    }
+
+    unsigned int totalNumber = numInList + _orphanedGLBufferObjects.size();
+    if (totalNumber != _numOfGLBufferObjects)
+    {
+        osg::notify(osg::NOTICE)<<"Error numInList + _orphanedGLBufferObjects.size() != _numOfGLBufferObjects"<<std::endl;
+        osg::notify(osg::NOTICE)<<"    numInList = "<<numInList<<std::endl;
+        osg::notify(osg::NOTICE)<<"    _orphanedGLBufferObjects.size() = "<<_orphanedGLBufferObjects.size()<<std::endl;
+        osg::notify(osg::NOTICE)<<"    _pendingOrphanedGLBufferObjects.size() = "<<_pendingOrphanedGLBufferObjects.size()<<std::endl;
+        osg::notify(osg::NOTICE)<<"    _numOfGLBufferObjects = "<<_numOfGLBufferObjects<<std::endl;
+        throw "Error numInList + _orphanedGLBufferObjects.size() != _numOfGLBufferObjects";
+    }
+
+    return true;
+}
+
+void GLBufferObjectSet::handlePendingOrphandedGLBufferObjects()
+{
+//    osg::notify(osg::NOTICE)<<"handlePendingOrphandedGLBufferObjects()"<<_pendingOrphanedGLBufferObjects.size()<<std::endl;
+
+    if (_pendingOrphanedGLBufferObjects.empty()) return;
+
+    unsigned int numOrphaned = _pendingOrphanedGLBufferObjects.size();
+
+    for(GLBufferObjectList::iterator itr = _pendingOrphanedGLBufferObjects.begin();
+        itr != _pendingOrphanedGLBufferObjects.end();
+        ++itr)
+    {
+        GLBufferObject* to = itr->get();
+
+        _orphanedGLBufferObjects.push_back(to);
+
+        remove(to);
+
+#if 0
+        osg::notify(osg::NOTICE)<<"  HPOTO  after  _head = "<<_head<<std::endl;
+        osg::notify(osg::NOTICE)<<"  HPOTO  after _tail = "<<_tail<<std::endl;
+        osg::notify(osg::NOTICE)<<"  HPOTO  after to->_previous = "<<to->_previous<<std::endl;
+        osg::notify(osg::NOTICE)<<"  HPOTO  after to->_next = "<<to->_next<<std::endl;
+#endif
+
+    }
+
+
+    // update the GLBufferObjectManager's running total of active + orphaned GLBufferObjects
+    _parent->getNumberOrphanedGLBufferObjects() += numOrphaned;
+    _parent->getNumberActiveGLBufferObjects() -= numOrphaned;
+
+    _pendingOrphanedGLBufferObjects.clear();
+
+    checkConsistency();
+}
+
+void GLBufferObjectSet::flushAllDeletedGLBufferObjects()
+{
+    for(GLBufferObjectList::iterator itr = _orphanedGLBufferObjects.begin();
+        itr != _orphanedGLBufferObjects.end();
+        ++itr)
+    {
+
+        (*itr)->deleteGLObject();
+
+        osg::notify(osg::NOTICE)<<"Deleting textureobject id="<<(*itr)->getGLObjectID()<<std::endl;
+    }
+
+    unsigned int numDeleted = _orphanedGLBufferObjects.size();
+    _numOfGLBufferObjects -= numDeleted;
+
+    // update the GLBufferObjectManager's running total of current pool size
+    _parent->getCurrGLBufferObjectPoolSize() -= numDeleted*_profile._size;
+    _parent->getNumberOrphanedGLBufferObjects() -= numDeleted;
+    _parent->getNumberDeleted() += numDeleted;
+
+    _orphanedGLBufferObjects.clear();
+}
+
+void GLBufferObjectSet::discardAllDeletedGLBufferObjects()
+{
+    unsigned int numDiscarded = _orphanedGLBufferObjects.size();
+
+    _numOfGLBufferObjects -= numDiscarded;
+
+    // update the GLBufferObjectManager's running total of current pool size
+    _parent->setCurrGLBufferObjectPoolSize( _parent->getCurrGLBufferObjectPoolSize() - numDiscarded*_profile._size );
+
+    // update the number of active and orphaned TextureOjects
+    _parent->getNumberOrphanedGLBufferObjects() -= 1;
+    _parent->getNumberActiveGLBufferObjects() += 1;
+    _parent->getNumberDeleted() += 1;
+
+
+    // just clear the list as there is nothing else we can do with them when discarding them
+    _orphanedGLBufferObjects.clear();
+}
+
+void GLBufferObjectSet::flushDeletedGLBufferObjects(double currentTime, double& availableTime)
+{
+    // if nothing to delete return
+    if (_orphanedGLBufferObjects.empty()) return;
+
+    // if no time available don't try to flush objects.
+    if (availableTime<=0.0) return;
+
+    // if we don't have too many orphaned texture objects then don't bother deleting them, as we can potentially reuse them later.
+    if (_parent->getNumberOrphanedGLBufferObjects()<=s_minimumNumberOfGLBufferObjectsToRetainInCache) return;
+
+    unsigned int numDeleted = 0;
+    unsigned int maxNumObjectsToDelete = _parent->getNumberOrphanedGLBufferObjects()-s_minimumNumberOfGLBufferObjectsToRetainInCache;
+    if (maxNumObjectsToDelete>4) maxNumObjectsToDelete = 4;
+
+    ElapsedTime timer;
+
+    GLBufferObjectList::iterator itr = _orphanedGLBufferObjects.begin();
+    for(;
+        itr != _orphanedGLBufferObjects.end() && timer.elapsedTime()<availableTime && numDeleted<maxNumObjectsToDelete;
+        ++itr)
+    {
+
+        osg::notify(osg::NOTICE)<<"Deleting textureobject id="<<itr->get()<<std::endl;
+
+         (*itr)->deleteGLObject();
+
+        ++numDeleted;
+    }
+
+    // osg::notify(osg::NOTICE)<<"Size before = "<<_orphanedGLBufferObjects.size();
+    _orphanedGLBufferObjects.erase(_orphanedGLBufferObjects.begin(), itr);
+    //osg::notify(osg::NOTICE)<<", after = "<<_orphanedGLBufferObjects.size()<<" numDeleted = "<<numDeleted<<std::endl;
+
+    // update the number of TO's in this GLBufferObjectSet
+    _numOfGLBufferObjects -= numDeleted;
+
+    _parent->setCurrGLBufferObjectPoolSize( _parent->getCurrGLBufferObjectPoolSize() - numDeleted*_profile._size );
+
+    // update the number of active and orphaned TextureOjects
+    _parent->getNumberOrphanedGLBufferObjects() -= numDeleted;
+    _parent->getNumberActiveGLBufferObjects() += numDeleted;
+    _parent->getNumberDeleted() += numDeleted;
+
+    availableTime -= timer.elapsedTime();
+}
+
+bool GLBufferObjectSet::makeSpace(unsigned int& size)
+{
+    if (!_orphanedGLBufferObjects.empty())
+    {
+        unsigned int sizeAvailable = _orphanedGLBufferObjects.size() * _profile._size;
+        if (size>sizeAvailable) size -= sizeAvailable;
+        else size = 0;
+
+        flushAllDeletedGLBufferObjects();
+    }
+
+    return size==0;
+}
+
+GLBufferObject* GLBufferObjectSet::takeFromOrphans(BufferObject* bufferObject)
+{
+    // take front of orphaned list.
+    ref_ptr<GLBufferObject> glbo = _orphanedGLBufferObjects.front();
+
+    // remove from orphan list.
+    _orphanedGLBufferObjects.pop_front();
+
+    // assign to new texture
+    glbo->assign(bufferObject);
+    glbo->setProfile(_profile);
+
+    // update the number of active and orphaned TextureOjects
+    _parent->getNumberOrphanedGLBufferObjects() -= 1;
+    _parent->getNumberActiveGLBufferObjects() += 1;
+
+    // place at back of active list
+    addToBack(glbo.get());
+
+    // osg::notify(osg::NOTICE)<<"Reusing orhpahned GLBufferObject, _numOfGLBufferObjects="<<_numOfGLBufferObjects<<std::endl;
+
+    return glbo.release();
+}
+
+
+GLBufferObject* GLBufferObjectSet::takeOrGenerate(BufferObject* bufferObject)
+{
+    // see if we can recyle GLBufferObject from the orphane list
+    if (!_pendingOrphanedGLBufferObjects.empty())
+    {
+        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
+        handlePendingOrphandedGLBufferObjects();
+        return takeFromOrphans(bufferObject);
+    }
+    else if (!_orphanedGLBufferObjects.empty())
+    {
+        return takeFromOrphans(bufferObject);
+    }
+
+    unsigned int minFrameNumber = _parent->getFrameNumber();
+
+    // see if we can reuse GLBufferObject by taking the least recently used active GLBufferObject
+    if ((_parent->getMaxGLBufferObjectPoolSize()!=0) &&
+        (!_parent->hasSpace(_profile._size)) &&
+        (_numOfGLBufferObjects>1) &&
+        (_head != 0) &&
+        (_head->_frameLastUsed<minFrameNumber))
+    {
+
+        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
+
+        ref_ptr<GLBufferObject> glbo = _head;
+
+        ref_ptr<BufferObject> original_BufferObject = glbo->getBufferObject();
+
+        if (original_BufferObject.valid())
+        {
+            original_BufferObject->setGLBufferObject(_contextID,0);
+            // osg::notify(osg::NOTICE)<<"GLBufferObjectSet="<<this<<": Reusing an active GLBufferObject "<<glbo.get()<<" _numOfGLBufferObjects="<<_numOfGLBufferObjects<<" size="<<_profile._size<<std::endl;
+        }
+        else
+        {
+            // osg::notify(osg::NOTICE)<<"Reusing a recently orphaned active GLBufferObject "<<glbo.get()<<std::endl;
+        }
+
+        moveToBack(glbo.get());
+
+        // assign to new texture
+        glbo->setBufferObject(bufferObject);
+        glbo->setProfile(_profile);
+
+        return glbo.release();
+    }
+
+    //
+    GLBufferObject* glbo = new GLBufferObject(_contextID, const_cast<BufferObject*>(bufferObject));
+    glbo->setProfile(_profile);
+    glbo->_set = this;
+    ++_numOfGLBufferObjects;
+
+    // update the current texture pool size
+    _parent->getCurrGLBufferObjectPoolSize() += _profile._size;
+    _parent->getNumberActiveGLBufferObjects() += 1;
+
+    addToBack(glbo);
+
+    // osg::notify(osg::NOTICE)<<"Created new GLBufferObject, _numOfGLBufferObjects "<<_numOfGLBufferObjects<<std::endl;
+
+    return glbo;
+}
+
+void GLBufferObjectSet::moveToBack(GLBufferObject* to)
+{
+#if 0
+    osg::notify(osg::NOTICE)<<"GLBufferObjectSet::moveToBack("<<to<<")"<<std::endl;
+    osg::notify(osg::NOTICE)<<"    before _head = "<<_head<<std::endl;
+    osg::notify(osg::NOTICE)<<"    before _tail = "<<_tail<<std::endl;
+    osg::notify(osg::NOTICE)<<"    before to->_previous = "<<to->_previous<<std::endl;
+    osg::notify(osg::NOTICE)<<"    before to->_next = "<<to->_next<<std::endl;
+#endif
+
+    to->_frameLastUsed = _parent->getFrameNumber();
+
+    // nothing to do if we are already tail
+    if (to==_tail) return;
+
+    // if no tail exists then assign 'to' as tail and head
+    if (_tail==0)
+    {
+        osg::notify(osg::NOTICE)<<"Error ***************** Should not get here !!!!!!!!!"<<std::endl;
+        _head = to;
+        _tail = to;
+        return;
+    }
+
+    if (to->_next==0)
+    {
+        osg::notify(osg::NOTICE)<<"Error ***************** Should not get here either !!!!!!!!!"<<std::endl;
+        return;
+    }
+
+
+    if (to->_previous)
+    {
+        (to->_previous)->_next = to->_next;
+    }
+    else
+    {
+        // 'to' is the head, so moving it to the back will mean we need a new head
+        if (to->_next)
+        {
+            _head = to->_next;
+        }
+    }
+
+    (to->_next)->_previous = to->_previous;
+
+    _tail->_next = to;
+
+    to->_previous = _tail;
+    to->_next = 0;
+
+    _tail = to;
+
+#if 0
+    osg::notify(osg::NOTICE)<<"  m2B   after  _head = "<<_head<<std::endl;
+    osg::notify(osg::NOTICE)<<"  m2B   after _tail = "<<_tail<<std::endl;
+    osg::notify(osg::NOTICE)<<"  m2B   after to->_previous = "<<to->_previous<<std::endl;
+    osg::notify(osg::NOTICE)<<"  m2B   after to->_next = "<<to->_next<<std::endl;
+#endif
+    checkConsistency();
+}
+
+void GLBufferObjectSet::addToBack(GLBufferObject* to)
+{
+#if 0
+    osg::notify(osg::NOTICE)<<"GLBufferObjectSet::addToBack("<<to<<")"<<std::endl;
+    osg::notify(osg::NOTICE)<<"    before _head = "<<_head<<std::endl;
+    osg::notify(osg::NOTICE)<<"    before _tail = "<<_tail<<std::endl;
+    osg::notify(osg::NOTICE)<<"    before to->_previous = "<<to->_previous<<std::endl;
+    osg::notify(osg::NOTICE)<<"    before to->_next = "<<to->_next<<std::endl;
+#endif
+
+    if (to->_previous !=0 || to->_next !=0)
+    {
+        moveToBack(to);
+    }
+    else
+    {
+        to->_frameLastUsed = _parent->getFrameNumber();
+
+        if (_tail) _tail->_next = to;
+        to->_previous = _tail;
+
+        if (!_head) _head = to;
+        _tail = to;
+    }
+#if 0
+    osg::notify(osg::NOTICE)<<"  a2B  after  _head = "<<_head<<std::endl;
+    osg::notify(osg::NOTICE)<<"  a2B   after _tail = "<<_tail<<std::endl;
+    osg::notify(osg::NOTICE)<<"  a2B   after to->_previous = "<<to->_previous<<std::endl;
+    osg::notify(osg::NOTICE)<<"  a2B   after to->_next = "<<to->_next<<std::endl;
+#endif
+    checkConsistency();
+}
+
+void GLBufferObjectSet::orphan(GLBufferObject* to)
+{
+    // osg::notify(osg::NOTICE)<<"GLBufferObjectSet::orphan("<<to<<")"<<std::endl;
+
+    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
+
+    // disconnect from original texture
+    to->setBufferObject(0);
+
+    // add orphan 'to' to the pending list of orphans, these will then be
+    // handled in the handlePendingOrphandedGLBufferObjects() where the TO's
+    // will be removed from the active list, and then placed in the orhpanGLBufferObject
+    // list.  This double buffered approach to handling orphaned TO's is used
+    // to avoid having to mutex the process of appling active TO's.
+    _pendingOrphanedGLBufferObjects.push_back(to);
+
+#if 0
+    osg::notify(osg::NOTICE)<<"GLBufferObjectSet::orphan("<<to<<")  _pendingOrphanedGLBufferObjects.size()="<<_pendingOrphanedGLBufferObjects.size()<<std::endl;
+    osg::notify(osg::NOTICE)<<"                                    _orphanedGLBufferObjects.size()="<<_orphanedGLBufferObjects.size()<<std::endl;
+#endif
+}
+
+void GLBufferObjectSet::remove(GLBufferObject* to)
+{
+    if (to->_previous!=0)
+    {
+        (to->_previous)->_next = to->_next;
+    }
+    else
+    {
+        // 'to' was head so assign _head to the next in list
+        _head = to->_next;
+    }
+
+    if (to->_next!=0)
+    {
+        (to->_next)->_previous = to->_previous;
+    }
+    else
+    {
+        // 'to' was tail so assing tail to the previous in list
+        _tail = to->_previous;
+    }
+
+    // reset the 'to' list pointers as it's no longer in the active list.
+    to->_next = 0;
+    to->_previous = 0;
+}
+
+
+GLBufferObjectManager::GLBufferObjectManager(unsigned int contextID):
+    _contextID(contextID),
+    _numActiveGLBufferObjects(0),
+    _numOrphanedGLBufferObjects(0),
+    _currGLBufferObjectPoolSize(0),
+    _maxGLBufferObjectPoolSize(0),
+    _frameNumber(0),
+    _numFrames(0),
+    _numDeleted(0),
+    _deleteTime(0.0),
+    _numGenerated(0),
+    _generateTime(0.0),
+    _numApplied(0),
+    _applyTime(0.0)
+{
+}
+
+void GLBufferObjectManager::setMaxGLBufferObjectPoolSize(unsigned int size)
+{
+    if (_maxGLBufferObjectPoolSize == size) return;
+
+    if (size<_currGLBufferObjectPoolSize)
+    {
+        osg::notify(osg::NOTICE)<<"Warning: new MaxGLBufferObjectPoolSize="<<size<<" is smaller than current GLBufferObjectPoolSize="<<_currGLBufferObjectPoolSize<<std::endl;
+    }
+
+    _maxGLBufferObjectPoolSize = size;
+}
+
+bool GLBufferObjectManager::makeSpace(unsigned int size)
+{
+    for(GLBufferObjectSetMap::iterator itr = _glBufferObjectSetMap.begin();
+        itr != _glBufferObjectSetMap.end() && size>0;
+        ++itr)
+    {
+        if ((*itr).second->makeSpace(size)) return true;
+    }
+
+    return size==0;
+}
+
+
+GLBufferObject* GLBufferObjectManager::generateGLBufferObject(const BufferObject* bufferObject)
+{
+    ElapsedTime elapsedTime(&(getGenerateTime()));
+    ++getNumberGenerated();
+
+    BufferObjectProfile profile(bufferObject->getTarget(), bufferObject->getUsage(), bufferObject->computeRequiredBufferSize());
+
+    // osg::notify(osg::NOTICE)<<"GLBufferObjectManager::generateGLBufferObject size="<<bufferObject->computeRequiredBufferSize()<<std::endl;
+
+    GLBufferObjectSet* glbos = getGLBufferObjectSet(profile);
+    return glbos->takeOrGenerate(const_cast<BufferObject*>(bufferObject));
+}
+
+GLBufferObjectSet* GLBufferObjectManager::getGLBufferObjectSet(const BufferObjectProfile& profile)
+{
+    osg::ref_ptr<GLBufferObjectSet>& tos = _glBufferObjectSetMap[profile];
+    if (!tos) tos = new GLBufferObjectSet(this, profile);
+    return tos.get();
+}
+
+void GLBufferObjectManager::handlePendingOrphandedGLBufferObjects()
+{
+    for(GLBufferObjectSetMap::iterator itr = _glBufferObjectSetMap.begin();
+        itr != _glBufferObjectSetMap.end();
+        ++itr)
+    {
+        (*itr).second->handlePendingOrphandedGLBufferObjects();
+    }
+}
+
+void GLBufferObjectManager::flushAllDeletedGLBufferObjects()
+{
+    ElapsedTime elapsedTime(&(getDeleteTime()));
+
+    for(GLBufferObjectSetMap::iterator itr = _glBufferObjectSetMap.begin();
+        itr != _glBufferObjectSetMap.end();
+        ++itr)
+    {
+        (*itr).second->flushAllDeletedGLBufferObjects();
+    }
+}
+
+void GLBufferObjectManager::discardAllDeletedGLBufferObjects()
+{
+    for(GLBufferObjectSetMap::iterator itr = _glBufferObjectSetMap.begin();
+        itr != _glBufferObjectSetMap.end();
+        ++itr)
+    {
+        (*itr).second->discardAllDeletedGLBufferObjects();
+    }
+}
+
+void GLBufferObjectManager::flushDeletedGLBufferObjects(double currentTime, double& availableTime)
+{
+    ElapsedTime elapsedTime(&(getDeleteTime()));
+
+    for(GLBufferObjectSetMap::iterator itr = _glBufferObjectSetMap.begin();
+        (itr != _glBufferObjectSetMap.end()) && (availableTime > 0.0);
+        ++itr)
+    {
+        (*itr).second->flushDeletedGLBufferObjects(currentTime, availableTime);
+    }
+}
+
+void GLBufferObjectManager::releaseGLBufferObject(GLBufferObject* to)
+{
+    if (to->_set) to->_set->orphan(to);
+    else osg::notify(osg::NOTICE)<<"GLBufferObjectManager::releaseGLBufferObject(GLBufferObject* to) Not implemented yet"<<std::endl;
+}
+
+
+void GLBufferObjectManager::newFrame(osg::FrameStamp* fs)
+{
+    if (fs) _frameNumber = fs->getFrameNumber();
+    else ++_frameNumber;
+
+    ++_numFrames;
+}
+
+void GLBufferObjectManager::reportStats()
+{
+    double numFrames(_numFrames==0 ? 1.0 : _numFrames);
+    osg::notify(osg::NOTICE)<<"GLBufferObjectMananger::reportStats()"<<std::endl;
+    osg::notify(osg::NOTICE)<<"   total _numOfGLBufferObjects="<<_numActiveGLBufferObjects<<", _numOrphanedGLBufferObjects="<<_numOrphanedGLBufferObjects<<" _currGLBufferObjectPoolSize="<<_currGLBufferObjectPoolSize<<std::endl;
+    osg::notify(osg::NOTICE)<<"   total _numGenerated="<<_numGenerated<<", _generateTime="<<_generateTime<<", averagePerFrame="<<_generateTime/numFrames*1000.0<<"ms"<<std::endl;
+    osg::notify(osg::NOTICE)<<"   total _numDeleted="<<_numDeleted<<", _deleteTime="<<_deleteTime<<", averagePerFrame="<<_deleteTime/numFrames*1000.0<<"ms"<<std::endl;
+    osg::notify(osg::NOTICE)<<"   total _numApplied="<<_numApplied<<", _applyTime="<<_applyTime<<", averagePerFrame="<<_applyTime/numFrames*1000.0<<"ms"<<std::endl;
+}
+
+void GLBufferObjectManager::resetStats()
+{
+    _numFrames = 0;
+    _numDeleted = 0;
+    _deleteTime = 0;
+
+    _numGenerated = 0;
+    _generateTime = 0;
+
+    _numApplied = 0;
+    _applyTime = 0;
+}
+
+
+
+osg::ref_ptr<GLBufferObjectManager>& GLBufferObjectManager::getGLBufferObjectManager(unsigned int contextID)
+{
+    typedef osg::buffered_object< ref_ptr<GLBufferObjectManager> > GLBufferObjectManagerBuffer;
+    static GLBufferObjectManagerBuffer s_GLBufferObjectManager;
+    if (!s_GLBufferObjectManager[contextID]) s_GLBufferObjectManager[contextID] = new GLBufferObjectManager(contextID);
+    return s_GLBufferObjectManager[contextID];
+}
+
+GLBufferObject* GLBufferObject::createGLBufferObject(unsigned int contextID, const BufferObject* bufferObject)
+{
+    return GLBufferObjectManager::getGLBufferObjectManager(contextID)->generateGLBufferObject(bufferObject);
+}
+
+void GLBufferObject::flushAllDeletedBufferObjects(unsigned int contextID)
+{
+    GLBufferObjectManager::getGLBufferObjectManager(contextID)->flushAllDeletedGLBufferObjects();
+}
+
+void GLBufferObject::discardAllDeletedBufferObjects(unsigned int contextID)
+{
+    GLBufferObjectManager::getGLBufferObjectManager(contextID)->discardAllDeletedGLBufferObjects();
+}
+
+void GLBufferObject::flushDeletedBufferObjects(unsigned int contextID,double currentTime, double& availbleTime)
+{
+    GLBufferObjectManager::getGLBufferObjectManager(contextID)->flushDeletedGLBufferObjects(currentTime, availbleTime);
+}
+
+void GLBufferObject::releaseGLBufferObject(unsigned int contextID, GLBufferObject* to)
+{
+    GLBufferObjectManager::getGLBufferObjectManager(contextID)->releaseGLBufferObject(to);
+}
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+//
 // BufferObject
 //
-BufferObject::BufferObject():
-    _target(0),
-    _usage(0)
+BufferObject::BufferObject()
 {
 }
@@ -442,4 +1082,5 @@
 }
 
+
 void BufferObject::setBufferData(unsigned int index, BufferData* bd)
 {
@@ -465,9 +1106,21 @@
     if (state)
     {
-        _glBufferObjects[state->getContextID()] = 0;
+        unsigned int contextID = state->getContextID();
+        if (_glBufferObjects[contextID].valid())
+        {
+            GLBufferObject::releaseGLBufferObject(contextID, _glBufferObjects[contextID].get());
+            _glBufferObjects[contextID] = 0;
+        }
     }
     else
     {
-        _glBufferObjects.clear();
+        for(unsigned int i=0; i<_glBufferObjects.size();++i)
+        {
+            if (_glBufferObjects[i].valid())
+            {
+                GLBufferObject::releaseGLBufferObject(i, _glBufferObjects[i].get());
+                _glBufferObjects[i] = 0;
+            }
+        }
     }
 }
@@ -529,4 +1182,17 @@
 }
 
+unsigned int BufferObject::computeRequiredBufferSize() const
+{
+    unsigned int newTotalSize = 0;
+    for(BufferDataList::const_iterator itr = _bufferDataList.begin();
+        itr != _bufferDataList.end();
+        ++itr)
+    {
+        BufferData* bd = *itr;
+        newTotalSize += bd->getTotalDataSize();
+    }
+    return newTotalSize;
+}
+
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 //
@@ -557,6 +1223,6 @@
 VertexBufferObject::VertexBufferObject()
 {
-    _target = GL_ARRAY_BUFFER_ARB;
-    _usage = GL_STATIC_DRAW_ARB;
+    setTarget(GL_ARRAY_BUFFER_ARB);
+    setUsage(GL_STATIC_DRAW_ARB);
 //    _usage = GL_DYNAMIC_DRAW_ARB;
 //    _usage = GL_STREAM_DRAW_ARB;
@@ -596,175 +1262,4 @@
     return dynamic_cast<const osg::Array*>(getBufferData(i));
 }
-#if 0
-void VertexBufferObject::compileBuffer(State& state) const
-{
-    unsigned int contextID = state.getContextID();
-
-    _compiledList[contextID] = 1;
-
-    Extensions* extensions = getExtensions(contextID,true);
-
-    // osg::notify(osg::NOTICE)<<"VertexBufferObject::compileBuffer frameNumber="<<state.getFrameStamp()->getFrameNumber()<<std::endl;
-
-    unsigned int totalSizeRequired = 0;
-    unsigned int numNewArrays = 0;
-    for(BufferEntryArrayPairs::const_iterator itr = _bufferEntryArrayPairs.begin();
-        itr != _bufferEntryArrayPairs.end();
-        ++itr)
-    {
-        const BufferEntryArrayPair& bep = *itr;
-        if (bep.second)
-        {
-            totalSizeRequired += bep.second->getTotalDataSize();
-            if (bep.first.dataSize == 0) ++numNewArrays;
-        }
-    }
-
-    bool copyAll = false;
-    GLuint& vbo = buffer(contextID);
-    if (vbo==0)
-    {
-        // building for the first time.
-
-        _totalSize = totalSizeRequired;
-
-        // don't generate buffer if size is zero.
-        if (_totalSize==0) return;
-
-        extensions->glGenBuffers(1, &vbo);
-        extensions->glBindBuffer(_target, vbo);
-        extensions->glBufferData(_target, _totalSize, NULL, _usage);
-
-        copyAll = true;
-    }
-    else
-    {
-        extensions->glBindBuffer(_target, vbo);
-
-        if (_totalSize != totalSizeRequired)
-        {
-            // resize vbo.
-            _totalSize = totalSizeRequired;
-            extensions->glBufferData(_target, _totalSize, NULL, _usage);
-
-            copyAll = true;
-        }
-    }
-
-    typedef std::map<unsigned int,std::vector<unsigned int> > SizePosMap_t;
-    SizePosMap_t freeList;
-    if (copyAll == false && numNewArrays > 0)
-    {
-        std::map<unsigned int,unsigned int> usedList;
-        for(BufferEntryArrayPairs::const_iterator itr = _bufferEntryArrayPairs.begin();
-            itr != _bufferEntryArrayPairs.end();
-            ++itr)
-        {
-            const BufferEntryArrayPair& bep = *itr;
-            if (bep.second==NULL) continue;
-            if (bep.first.dataSize == 0) continue;
-            usedList[bep.first.offset] = bep.first.dataSize;
-        }
-        unsigned int numFreeBlocks = 0;
-        unsigned int pos=0;
-
-        for (std::map<unsigned int,unsigned int>::const_iterator it=usedList.begin(); it!=usedList.end(); ++it)
-        {
-            unsigned int start = it->first;
-            unsigned int length = it->second;
-            if (pos < start)
-            {
-                freeList[start-pos].push_back(pos);
-                ++numFreeBlocks;
-            }
-            pos = start+length;
-        }
-        if (pos < totalSizeRequired)
-        {
-            freeList[totalSizeRequired-pos].push_back(pos);
-            ++numFreeBlocks;
-        }
-        if (numNewArrays < numFreeBlocks)
-        {
-            copyAll = true;     // too fragmented, fallback to copyAll
-            freeList.clear();
-        }
-    }
-
-
-//    osg::Timer_t start_tick = osg::Timer::instance()->tick();
-
-
-    void* vboMemory = 0;
-
-#if 0
-    vboMemory = extensions->glMapBuffer(_target, GL_WRITE_ONLY_ARB);
-#endif
-
-    unsigned int offset = 0;
-    for(BufferEntryArrayPairs::const_iterator itr = _bufferEntryArrayPairs.begin();
-        itr != _bufferEntryArrayPairs.end();
-        ++itr)
-    {
-        const BufferEntryArrayPair& bep = *itr;
-        const Array* de = bep.second;
-        if (de)
-        {
-            const unsigned int arraySize = de->getTotalDataSize();
-            if (copyAll ||
-                bep.first.modifiedCount[contextID] != bep.second->getModifiedCount() ||
-                bep.first.dataSize != arraySize)
-            {
-                // copy data across
-                unsigned int newOffset = bep.first.offset;              
-                if (copyAll)
-                {
-                    newOffset = offset;
-                    offset += arraySize;
-                }
-                else if (bep.first.dataSize == 0)
-                {
-                    SizePosMap_t::iterator findIt = freeList.lower_bound(arraySize);
-                    if (findIt==freeList.end())
-                    {
-                        osg::notify(osg::FATAL)<<"No suitable Memory in VBO found!"<<std::endl;
-                        continue;
-                    }
-                    const unsigned int oldOffset = findIt->second.back();
-                    newOffset = oldOffset;
-                    if (findIt->first > arraySize) // using larger block
-                    {
-                        freeList[findIt->first-arraySize].push_back(oldOffset+arraySize);
-                    }
-                    findIt->second.pop_back();
-                    if (findIt->second.empty())
-                    {
-                        freeList.erase(findIt);
-                    }
-                }
-                bep.first.dataSize = arraySize;
-                bep.first.modifiedCount[contextID] = de->getModifiedCount();
-                bep.first.offset = newOffset;
-                de->setVertexBufferObjectOffset((GLvoid*)newOffset);
-
-                // osg::notify(osg::NOTICE)<<"   copying vertex buffer data "<<bep.first.dataSize<<" bytes"<<std::endl;
-
-                if (vboMemory)
-                    memcpy((char*)vboMemory + bep.first.offset, de->getDataPointer(), bep.first.dataSize);
-                else
-                    extensions->glBufferSubData(_target, bep.first.offset, bep.first.dataSize, de->getDataPointer());
-
-            }
-        }
-    }
-
-
-    // Unmap the texture image buffer
-    if (vboMemory) extensions->glUnmapBuffer(_target);
-
-//    osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<<std::endl;
-//    osg::notify(osg::NOTICE)<<"pbo "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl;
-}
-#endif
 
 //////////////////////////////////////////////////////////////////////////////////
@@ -774,6 +1269,6 @@
 ElementBufferObject::ElementBufferObject()
 {
-    _target = GL_ELEMENT_ARRAY_BUFFER_ARB;
-    _usage = GL_STATIC_DRAW_ARB;
+    setTarget(GL_ELEMENT_ARRAY_BUFFER_ARB);
+    setUsage(GL_STATIC_DRAW_ARB);
 }
 
@@ -813,110 +1308,4 @@
 
 
-#if 0
-void ElementBufferObject::compileBuffer(State& state) const
-{
-    unsigned int contextID = state.getContextID();
-
-    _compiledList[contextID] = 1;
-
-    // osg::notify(osg::NOTICE)<<"ElementBufferObject::compile"<<std::endl;
-
-    Extensions* extensions = getExtensions(contextID,true);
-
-    unsigned int totalSizeRequired = 0;
-//    unsigned int numModified = 0;
-//    unsigned int numNotModified = 0;
-    for(BufferEntryDrawElementsPairs::const_iterator itr = _bufferEntryDrawElementsPairs.begin();
-        itr != _bufferEntryDrawElementsPairs.end();
-        ++itr)
-    {
-        const BufferEntryDrawElementsPair& bep = *itr;
-        if (bep.second)
-        {
-            totalSizeRequired += bep.second->getTotalDataSize();
-        }
-    }
-
-    bool copyAll = false;
-    GLuint& ebo = buffer(contextID);
-    if (ebo==0)
-    {
-        // building for the first time.
-
-        _totalSize = totalSizeRequired;
-
-        // don't generate buffer if size is zero.
-        if (_totalSize==0) return;
-
-        extensions->glGenBuffers(1, &ebo);
-        extensions->glBindBuffer(_target, ebo);
-        extensions->glBufferData(_target, _totalSize, NULL, _usage);
-
-        copyAll = true;
-    }
-    else
-    {
-        extensions->glBindBuffer(_target, ebo);
-
-        if (_totalSize != totalSizeRequired)
-        {
-            // resize EBO.
-            _totalSize = totalSizeRequired;
-            extensions->glBufferData(_target, _totalSize, NULL, _usage);
-
-            copyAll = true;
-        }
-    }
-
-//    osg::Timer_t start_tick = osg::Timer::instance()->tick();
-
-
-    void* eboMemory = 0;
-
-#if 0
-    eboMemory = extensions->glMapBuffer(_target, GL_WRITE_ONLY_ARB);
-#endif
-
-    size_t offset = 0;
-    for(BufferEntryDrawElementsPairs::const_iterator itr = _bufferEntryDrawElementsPairs.begin();
-        itr != _bufferEntryDrawElementsPairs.end();
-        ++itr)
-    {
-        const BufferEntryDrawElementsPair& bep = *itr;
-        const DrawElements* de = bep.second;
-        if (de)
-        {
-            if (copyAll ||
-                bep.first.modifiedCount[contextID] != bep.second->getModifiedCount() ||
-                bep.first.dataSize != bep.second->getTotalDataSize())
-            {
-                // copy data across
-                bep.first.dataSize = bep.second->getTotalDataSize();
-                bep.first.modifiedCount[contextID] = de->getModifiedCount();
-                if (copyAll)
-                {
-                    bep.first.offset = offset;
-                    de->setElementBufferObjectOffset((GLvoid*)offset);
-                    offset += bep.first.dataSize;
-                }
-
-                if (eboMemory)
-                    memcpy((char*)eboMemory + bep.first.offset, de->getDataPointer(), bep.first.dataSize);
-                else
-                    extensions->glBufferSubData(_target, bep.first.offset, bep.first.dataSize, de->getDataPointer());
-
-            }
-        }
-    }
-
-
-    // Unmap the texture image buffer
-    if (eboMemory) extensions->glUnmapBuffer(_target);
-
-//    osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<<std::endl;
-//    osg::notify(osg::NOTICE)<<"pbo "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl;
-}
-#endif
-
 //////////////////////////////////////////////////////////////////////////////////
 //
@@ -926,6 +1315,6 @@
     BufferObject()
 {
-    _target = GL_PIXEL_UNPACK_BUFFER_ARB;
-    _usage = GL_STREAM_DRAW_ARB;
+    setTarget(GL_PIXEL_UNPACK_BUFFER_ARB);
+    setTarget(GL_STREAM_DRAW_ARB);
 
     osg::notify(osg::NOTICE)<<"Constructing PixelBufferObject for image="<<image<<std::endl;
@@ -958,62 +1347,4 @@
 }
 
-#if 0
-void PixelBufferObject::compileBuffer(State& state) const
-{
-    unsigned int contextID = state.getContextID();
-
-    _compiledList[contextID] = 1;
-
-    osg::Image* image = _bufferEntryImagePair.second;
-
-    _bufferEntryImagePair.first.modifiedCount[contextID] = image->getModifiedCount();
-    if (!image->valid()) return;
-
-    Extensions* extensions = getExtensions(contextID,true);
-
-    GLuint& pbo = buffer(contextID);
-    if (pbo==0)
-    {
-        // building for the first time.
-
-        _totalSize = image->getTotalSizeInBytes();
-
-        // don't generate buffer if size is zero.
-        if (_totalSize==0) return;
-
-        extensions->glGenBuffers(1, &pbo);
-        extensions->glBindBuffer(_target, pbo);
-        extensions->glBufferData(_target, _totalSize, NULL, _usage);
-
-    }
-    else
-    {
-        extensions->glBindBuffer(_target, pbo);
-
-        if (_totalSize != image->getTotalSizeInBytes())
-        {
-            // resize PBO.
-            _totalSize = image->getTotalSizeInBytes();
-            extensions->glBufferData(_target, _totalSize, NULL, _usage);
-        }
-    }
-
-//    osg::Timer_t start_tick = osg::Timer::instance()->tick();
-
-    void* pboMemory = extensions->glMapBuffer(_target,
-                 GL_WRITE_ONLY_ARB);
-
-    // copy data across
-    memcpy(pboMemory, image->data(), _totalSize);
-
-    // Unmap the texture image buffer
-    extensions->glUnmapBuffer(_target);
-
-    _bufferEntryImagePair.first.modifiedCount[contextID] = image->getModifiedCount();
-
-//    osg::notify(osg::NOTICE)<<"pbo _totalSize="<<_totalSize<<std::endl;
-//    osg::notify(osg::NOTICE)<<"pbo "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl;
-}
-#endif
 
 //////////////////////////////////////////////////////////////////////////////////
@@ -1024,6 +1355,6 @@
 PixelDataBufferObject::PixelDataBufferObject()
 {
-    _target = GL_ARRAY_BUFFER_ARB;
-    _usage = GL_DYNAMIC_DRAW_ARB;
+    setTarget(GL_ARRAY_BUFFER_ARB);
+    setTarget(GL_DYNAMIC_DRAW_ARB);
 }
 
@@ -1043,12 +1374,12 @@
 {
     unsigned int contextID = state.getContextID();    
-    if ( _dataSize == 0) return;
+    if ( _profile._size == 0) return;
 
     GLBufferObject* bo = getOrCreateGLBufferObject(contextID);
     if (!bo || !bo->isDirty()) return;
 
-    bo->_extensions->glBindBuffer(_target, bo->getGLObjectID());
-    bo->_extensions->glBufferData(_target, _dataSize, NULL, _usage);
-    bo->_extensions->glBindBuffer(_target, 0);
+    bo->_extensions->glBindBuffer(_profile._target, bo->getGLObjectID());
+    bo->_extensions->glBufferData(_profile._target, _profile._size, NULL, _profile._usage);
+    bo->_extensions->glBindBuffer(_profile._target, 0);
 }
 
@@ -1097,5 +1428,5 @@
             break;
         default:
-            extensions->glBindBuffer(_target,0);
+            extensions->glBindBuffer(_profile._target,0);
             break;
     }
@@ -1111,5 +1442,2 @@
     _mode.resize(maxSize);
 }
-
-
-#endif
Index: /OpenSceneGraph/trunk/src/osg/GLObjects.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osg/GLObjects.cpp (revision 10600)
+++ /OpenSceneGraph/trunk/src/osg/GLObjects.cpp (revision 10601)
@@ -54,5 +54,5 @@
 void osg::discardAllDeletedGLObjects(unsigned int contextID)
 {
-    osg::GLBufferObject::discardDeletedBufferObjects(contextID);
+    osg::GLBufferObject::discardAllDeletedBufferObjects(contextID);
     osg::Drawable::discardAllDeletedDisplayLists(contextID);
     osg::FragmentProgram::discardDeletedFragmentProgramObjects(contextID);
Index: /OpenSceneGraph/trunk/src/osg/State.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osg/State.cpp (revision 10590)
+++ /OpenSceneGraph/trunk/src/osg/State.cpp (revision 10601)
@@ -90,6 +90,5 @@
 
     _maxTexturePoolSize = 0;
-    _maxVBOPoolSize = 0;
-    _maxFBOPoolSize = 0;
+    _maxBufferObjectPoolSize = 0;
 }
 
@@ -233,14 +232,9 @@
 }
 
-void State::setMaxVBOPoolSize(unsigned int size)
-{
-    _maxVBOPoolSize = size;
-    osg::notify(osg::NOTICE)<<"_maxVBOPoolSize="<<_maxVBOPoolSize<<std::endl;
-}
-
-void State::setMaxFBOPoolSize(unsigned int size)
-{
-    _maxFBOPoolSize = size;
-    osg::notify(osg::NOTICE)<<"_maxFBOPoolSize="<<_maxFBOPoolSize<<std::endl;
+void State::setMaxBufferObjectPoolSize(unsigned int size)
+{
+    _maxBufferObjectPoolSize = size;
+    osg::GLBufferObjectManager::getGLBufferObjectManager(getContextID())->setMaxGLBufferObjectPoolSize(_maxBufferObjectPoolSize);
+    osg::notify(osg::NOTICE)<<"_maxBufferObjectPoolSize="<<_maxBufferObjectPoolSize<<std::endl;
 }
 
Index: /OpenSceneGraph/trunk/src/osg/DisplaySettings.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osg/DisplaySettings.cpp (revision 10588)
+++ /OpenSceneGraph/trunk/src/osg/DisplaySettings.cpp (revision 10601)
@@ -83,6 +83,5 @@
 
     _maxTexturePoolSize = vs._maxTexturePoolSize;
-    _maxVBOPoolSize = vs._maxVBOPoolSize;
-    _maxFBOPoolSize = vs._maxFBOPoolSize;
+    _maxBufferObjectPoolSize = vs._maxBufferObjectPoolSize;
 }
 
@@ -110,6 +109,5 @@
 
     if (vs._maxTexturePoolSize>_maxTexturePoolSize) _maxTexturePoolSize = vs._maxTexturePoolSize;
-    if (vs._maxVBOPoolSize>_maxVBOPoolSize) _maxVBOPoolSize = vs._maxVBOPoolSize;
-    if (vs._maxFBOPoolSize>_maxFBOPoolSize) _maxFBOPoolSize = vs._maxFBOPoolSize;
+    if (vs._maxBufferObjectPoolSize>_maxBufferObjectPoolSize) _maxBufferObjectPoolSize = vs._maxBufferObjectPoolSize;
 }
 
@@ -158,6 +156,5 @@
 
     _maxTexturePoolSize = 0;
-    _maxVBOPoolSize = 0;
-    _maxFBOPoolSize = 0;
+    _maxBufferObjectPoolSize = 0;
 }
 
@@ -200,5 +197,5 @@
 static ApplicationUsageProxy DisplaySetting_e17(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MULTI_SAMPLES <int>","Set the hint for the number of samples to use when multi-sampling.");
 static ApplicationUsageProxy DisplaySetting_e18(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_TEXTURE_POOL_SIZE <int>","Set the hint size of texture pool to manage.");
-static ApplicationUsageProxy DisplaySetting_e19(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_VBO_POOL_SIZE <int>","Set the hint size of vertex buffer object pool to manage.");
+static ApplicationUsageProxy DisplaySetting_e19(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_BUFFER_OBJECT_POOL_SIZE <int>","Set the hint size of vertex buffer object pool to manage.");
 static ApplicationUsageProxy DisplaySetting_e20(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_FBO_POOL_SIZE <int>","Set the hint size of frame buffer object pool to manage.");
 
@@ -404,12 +401,7 @@
     }
 
-    if( (ptr = getenv("OSG_VBO_POOL_SIZE")) != 0)
-    {
-        _maxVBOPoolSize = atoi(ptr);
-    }
-
-    if( (ptr = getenv("OSG_FBO_POOL_SIZE")) != 0)
-    {
-        _maxFBOPoolSize = atoi(ptr);
+    if( (ptr = getenv("OSG_BUFFER_OBJECT_POOL_SIZE")) != 0)
+    {
+        _maxBufferObjectPoolSize = atoi(ptr);
     }
 }
@@ -501,9 +493,8 @@
 
     while(arguments.read("--texture-pool-size",_maxTexturePoolSize)) {}
-    while(arguments.read("--vbo-pool-size",_maxVBOPoolSize)) {}
-    while(arguments.read("--fbo-pool-size",_maxFBOPoolSize)) {}
-
-}
-
-
-
+    while(arguments.read("--buffer-object-pool-size",_maxBufferObjectPoolSize)) {}
+
+}
+
+
+
Index: /OpenSceneGraph/trunk/src/osgViewer/Viewer.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgViewer/Viewer.cpp (revision 10588)
+++ /OpenSceneGraph/trunk/src/osgViewer/Viewer.cpp (revision 10601)
@@ -482,11 +482,7 @@
     if (_displaySettings.valid()) maxTexturePoolSize = std::max(maxTexturePoolSize, _displaySettings->getMaxTexturePoolSize());
 
-    unsigned int maxVBOPoolSize = osg::DisplaySettings::instance()->getMaxVBOPoolSize();
-    if (_displaySettings.valid()) maxVBOPoolSize = std::max(maxVBOPoolSize, _displaySettings->getMaxVBOPoolSize());
-    if (_camera->getDisplaySettings()) maxVBOPoolSize = std::max(maxVBOPoolSize, _camera->getDisplaySettings()->getMaxVBOPoolSize());
-
-    unsigned int maxFBOPoolSize = osg::DisplaySettings::instance()->getMaxFBOPoolSize();
-    if (_displaySettings.valid()) maxFBOPoolSize = std::max(maxFBOPoolSize, _displaySettings->getMaxFBOPoolSize());
-    if (_camera->getDisplaySettings()) maxFBOPoolSize = std::max(maxFBOPoolSize, _camera->getDisplaySettings()->getMaxFBOPoolSize());
+    unsigned int maxBufferObjectPoolSize = osg::DisplaySettings::instance()->getMaxBufferObjectPoolSize();
+    if (_displaySettings.valid()) maxBufferObjectPoolSize = std::max(maxBufferObjectPoolSize, _displaySettings->getMaxBufferObjectPoolSize());
+    if (_camera->getDisplaySettings()) maxBufferObjectPoolSize = std::max(maxBufferObjectPoolSize, _camera->getDisplaySettings()->getMaxBufferObjectPoolSize());
 
     for(Contexts::iterator citr = contexts.begin();
@@ -498,6 +494,5 @@
         // set the pool sizes, 0 the default will result in no GL object pools.
         gc->getState()->setMaxTexturePoolSize(maxTexturePoolSize);
-        gc->getState()->setMaxVBOPoolSize(maxVBOPoolSize);
-        gc->getState()->setMaxFBOPoolSize(maxFBOPoolSize);
+        gc->getState()->setMaxBufferObjectPoolSize(maxBufferObjectPoolSize);
 
         gc->realize();
Index: /OpenSceneGraph/trunk/src/osgViewer/CompositeViewer.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgViewer/CompositeViewer.cpp (revision 10588)
+++ /OpenSceneGraph/trunk/src/osgViewer/CompositeViewer.cpp (revision 10601)
@@ -542,6 +542,5 @@
 
     unsigned int maxTexturePoolSize = osg::DisplaySettings::instance()->getMaxTexturePoolSize();
-    unsigned int maxVBOPoolSize = osg::DisplaySettings::instance()->getMaxVBOPoolSize();
-    unsigned int maxFBOPoolSize = osg::DisplaySettings::instance()->getMaxFBOPoolSize();
+    unsigned int maxBufferObjectPoolSize = osg::DisplaySettings::instance()->getMaxBufferObjectPoolSize();
 
     for(Contexts::iterator citr = contexts.begin();
@@ -553,6 +552,5 @@
         // set the pool sizes, 0 the default will result in no GL object pools.
         gc->getState()->setMaxTexturePoolSize(maxTexturePoolSize);
-        gc->getState()->setMaxVBOPoolSize(maxVBOPoolSize);
-        gc->getState()->setMaxFBOPoolSize(maxFBOPoolSize);
+        gc->getState()->setMaxBufferObjectPoolSize(maxBufferObjectPoolSize);
 
         gc->realize();
Index: /OpenSceneGraph/trunk/src/osgViewer/StatsHandler.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgViewer/StatsHandler.cpp (revision 10098)
+++ /OpenSceneGraph/trunk/src/osgViewer/StatsHandler.cpp (revision 10601)
@@ -1401,5 +1401,5 @@
         viewStr << "Bins" << std::endl;
         viewStr << "Depth" << std::endl;
-        viewStr << "Matrices" << std::endl;
+        viewStr << "Materials" << std::endl;
         viewStr << "Imposters" << std::endl;
         viewStr << "Drawables" << std::endl;
Index: /OpenSceneGraph/trunk/src/osgWrappers/osg/BufferObject.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgWrappers/osg/BufferObject.cpp (revision 10600)
+++ /OpenSceneGraph/trunk/src/osgWrappers/osg/BufferObject.cpp (revision 10601)
@@ -14,4 +14,5 @@
 #include <osg/BufferObject>
 #include <osg/CopyOp>
+#include <osg/FrameStamp>
 #include <osg/Image>
 #include <osg/Object>
@@ -174,4 +175,14 @@
 	          "Get the type of usage the buffer object has been set up for. ",
 	          "");
+	I_Method0(osg::BufferObjectProfile &, getProfile,
+	          Properties::NON_VIRTUAL,
+	          __BufferObjectProfile_R1__getProfile,
+	          "",
+	          "");
+	I_Method0(const osg::BufferObjectProfile &, getProfile,
+	          Properties::NON_VIRTUAL,
+	          __C5_BufferObjectProfile_R1__getProfile,
+	          "",
+	          "");
 	I_Method0(void, dirty,
 	          Properties::NON_VIRTUAL,
@@ -224,4 +235,9 @@
 	          "",
 	          "");
+	I_Method2(void, setGLBufferObject, IN, unsigned int, contextID, IN, osg::GLBufferObject *, glbo,
+	          Properties::NON_VIRTUAL,
+	          __void__setGLBufferObject__unsigned_int__GLBufferObject_P1,
+	          "",
+	          "");
 	I_Method1(osg::GLBufferObject *, getGLBufferObject, IN, unsigned int, contextID,
 	          Properties::NON_VIRTUAL,
@@ -232,4 +248,9 @@
 	          Properties::NON_VIRTUAL,
 	          __GLBufferObject_P1__getOrCreateGLBufferObject__unsigned_int,
+	          "",
+	          "");
+	I_Method0(unsigned int, computeRequiredBufferSize,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__computeRequiredBufferSize,
 	          "",
 	          "");
@@ -241,4 +262,11 @@
 	                0, 
 	                __void__removeBufferData__unsigned_int);
+	I_IndexedProperty(osg::GLBufferObject *, GLBufferObject, 
+	                  __GLBufferObject_P1__getGLBufferObject__unsigned_int, 
+	                  __void__setGLBufferObject__unsigned_int__GLBufferObject_P1, 
+	                  0);
+	I_SimpleProperty(osg::BufferObjectProfile &, Profile, 
+	                 __BufferObjectProfile_R1__getProfile, 
+	                 0);
 	I_SimpleProperty(GLenum, Target, 
 	                 __GLenum__getTarget, 
@@ -247,4 +275,28 @@
 	                 __GLenum__getUsage, 
 	                 __void__setUsage__GLenum);
+END_REFLECTOR
+
+BEGIN_VALUE_REFLECTOR(osg::BufferObjectProfile)
+	I_DeclaringFile("osg/BufferObject");
+	I_Constructor0(____BufferObjectProfile,
+	               "",
+	               "");
+	I_Constructor3(IN, GLenum, target, IN, GLenum, usage, IN, unsigned int, size,
+	               ____BufferObjectProfile__GLenum__GLenum__unsigned_int,
+	               "",
+	               "");
+	I_Constructor1(IN, const osg::BufferObjectProfile &, bpo,
+	               Properties::NON_EXPLICIT,
+	               ____BufferObjectProfile__C5_BufferObjectProfile_R1,
+	               "",
+	               "");
+	I_Method3(void, setProfile, IN, GLenum, target, IN, GLenum, usage, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __void__setProfile__GLenum__GLenum__unsigned_int,
+	          "",
+	          "");
+	I_PublicMemberProperty(GLenum, _target);
+	I_PublicMemberProperty(GLenum, _usage);
+	I_PublicMemberProperty(GLenum, _size);
 END_REFLECTOR
 
@@ -322,4 +374,14 @@
 	                           "",
 	                           "");
+	I_Method1(void, setProfile, IN, const osg::BufferObjectProfile &, profile,
+	          Properties::NON_VIRTUAL,
+	          __void__setProfile__C5_BufferObjectProfile_R1,
+	          "",
+	          "");
+	I_Method0(const osg::BufferObjectProfile &, getProfile,
+	          Properties::NON_VIRTUAL,
+	          __C5_BufferObjectProfile_R1__getProfile,
+	          "",
+	          "");
 	I_Method1(void, setBufferObject, IN, osg::BufferObject *, bufferObject,
 	          Properties::NON_VIRTUAL,
@@ -405,12 +467,20 @@
 	                "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,
+	I_StaticMethod1(void, flushAllDeletedBufferObjects, IN, unsigned int, contextID,
+	                __void__flushAllDeletedBufferObjects__unsigned_int_S,
+	                "",
+	                "");
+	I_StaticMethod1(void, discardAllDeletedBufferObjects, IN, unsigned int, contextID,
+	                __void__discardAllDeletedBufferObjects__unsigned_int_S,
+	                "",
+	                "");
+	I_StaticMethod3(void, flushDeletedBufferObjects, IN, unsigned int, contextID, IN, double, currentTime, IN, double &, availbleTime,
 	                __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(void, releaseGLBufferObject, IN, unsigned int, contextID, IN, osg::GLBufferObject *, to,
+	                __void__releaseGLBufferObject__unsigned_int__GLBufferObject_P1_S,
+	                "",
+	                "");
 	I_StaticMethod2(osg::GLBufferObject::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
 	                __Extensions_P1__getExtensions__unsigned_int__bool_S,
@@ -430,4 +500,11 @@
 	                 __GLuint__getGLObjectID, 
 	                 0);
+	I_SimpleProperty(const osg::BufferObjectProfile &, Profile, 
+	                 __C5_BufferObjectProfile_R1__getProfile, 
+	                 __void__setProfile__C5_BufferObjectProfile_R1);
+	I_PublicMemberProperty(osg::GLBufferObjectSet *, _set);
+	I_PublicMemberProperty(osg::GLBufferObject *, _previous);
+	I_PublicMemberProperty(osg::GLBufferObject *, _next);
+	I_PublicMemberProperty(unsigned int, _frameLastUsed);
 	I_PublicMemberProperty(osg::GLBufferObject::Extensions *, _extensions);
 END_REFLECTOR
@@ -447,4 +524,299 @@
 	I_PublicMemberProperty(GLsizeiptrARB, offset);
 	I_PublicMemberProperty(osg::BufferData *, dataSource);
+END_REFLECTOR
+
+BEGIN_OBJECT_REFLECTOR(osg::GLBufferObjectManager)
+	I_DeclaringFile("osg/BufferObject");
+	I_BaseType(osg::Referenced);
+	I_Constructor1(IN, unsigned int, contextID,
+	               Properties::NON_EXPLICIT,
+	               ____GLBufferObjectManager__unsigned_int,
+	               "",
+	               "");
+	I_Method0(unsigned int, getContextID,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__getContextID,
+	          "",
+	          "");
+	I_Method1(void, setNumberActiveGLBufferObjects, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __void__setNumberActiveGLBufferObjects__unsigned_int,
+	          "",
+	          "");
+	I_Method0(unsigned int &, getNumberActiveGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int_R1__getNumberActiveGLBufferObjects,
+	          "",
+	          "");
+	I_Method0(unsigned int, getNumberActiveGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__getNumberActiveGLBufferObjects,
+	          "",
+	          "");
+	I_Method1(void, setNumberOrphanedGLBufferObjects, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __void__setNumberOrphanedGLBufferObjects__unsigned_int,
+	          "",
+	          "");
+	I_Method0(unsigned int &, getNumberOrphanedGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int_R1__getNumberOrphanedGLBufferObjects,
+	          "",
+	          "");
+	I_Method0(unsigned int, getNumberOrphanedGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__getNumberOrphanedGLBufferObjects,
+	          "",
+	          "");
+	I_Method1(void, setCurrGLBufferObjectPoolSize, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __void__setCurrGLBufferObjectPoolSize__unsigned_int,
+	          "",
+	          "");
+	I_Method0(unsigned int &, getCurrGLBufferObjectPoolSize,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int_R1__getCurrGLBufferObjectPoolSize,
+	          "",
+	          "");
+	I_Method0(unsigned int, getCurrGLBufferObjectPoolSize,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__getCurrGLBufferObjectPoolSize,
+	          "",
+	          "");
+	I_Method1(void, setMaxGLBufferObjectPoolSize, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __void__setMaxGLBufferObjectPoolSize__unsigned_int,
+	          "",
+	          "");
+	I_Method0(unsigned int, getMaxGLBufferObjectPoolSize,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__getMaxGLBufferObjectPoolSize,
+	          "",
+	          "");
+	I_Method1(bool, hasSpace, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __bool__hasSpace__unsigned_int,
+	          "",
+	          "");
+	I_Method1(bool, makeSpace, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __bool__makeSpace__unsigned_int,
+	          "",
+	          "");
+	I_Method1(osg::GLBufferObject *, generateGLBufferObject, IN, const osg::BufferObject *, bufferObject,
+	          Properties::NON_VIRTUAL,
+	          __GLBufferObject_P1__generateGLBufferObject__C5_osg_BufferObject_P1,
+	          "",
+	          "");
+	I_Method0(void, handlePendingOrphandedGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __void__handlePendingOrphandedGLBufferObjects,
+	          "",
+	          "");
+	I_Method0(void, flushAllDeletedGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __void__flushAllDeletedGLBufferObjects,
+	          "",
+	          "");
+	I_Method0(void, discardAllDeletedGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __void__discardAllDeletedGLBufferObjects,
+	          "",
+	          "");
+	I_Method2(void, flushDeletedGLBufferObjects, IN, double, currentTime, IN, double &, availableTime,
+	          Properties::NON_VIRTUAL,
+	          __void__flushDeletedGLBufferObjects__double__double_R1,
+	          "",
+	          "");
+	I_Method1(void, releaseGLBufferObject, IN, osg::GLBufferObject *, to,
+	          Properties::NON_VIRTUAL,
+	          __void__releaseGLBufferObject__GLBufferObject_P1,
+	          "",
+	          "");
+	I_Method1(osg::GLBufferObjectSet *, getGLBufferObjectSet, IN, const osg::BufferObjectProfile &, profile,
+	          Properties::NON_VIRTUAL,
+	          __GLBufferObjectSet_P1__getGLBufferObjectSet__C5_BufferObjectProfile_R1,
+	          "",
+	          "");
+	I_Method1(void, newFrame, IN, osg::FrameStamp *, fs,
+	          Properties::NON_VIRTUAL,
+	          __void__newFrame__osg_FrameStamp_P1,
+	          "",
+	          "");
+	I_Method0(void, resetStats,
+	          Properties::NON_VIRTUAL,
+	          __void__resetStats,
+	          "",
+	          "");
+	I_Method0(void, reportStats,
+	          Properties::NON_VIRTUAL,
+	          __void__reportStats,
+	          "",
+	          "");
+	I_Method0(unsigned int &, getFrameNumber,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int_R1__getFrameNumber,
+	          "",
+	          "");
+	I_Method0(unsigned int &, getNumberFrames,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int_R1__getNumberFrames,
+	          "",
+	          "");
+	I_Method0(unsigned int &, getNumberDeleted,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int_R1__getNumberDeleted,
+	          "",
+	          "");
+	I_Method0(double &, getDeleteTime,
+	          Properties::NON_VIRTUAL,
+	          __double_R1__getDeleteTime,
+	          "",
+	          "");
+	I_Method0(unsigned int &, getNumberGenerated,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int_R1__getNumberGenerated,
+	          "",
+	          "");
+	I_Method0(double &, getGenerateTime,
+	          Properties::NON_VIRTUAL,
+	          __double_R1__getGenerateTime,
+	          "",
+	          "");
+	I_Method0(unsigned int &, getNumberApplied,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int_R1__getNumberApplied,
+	          "",
+	          "");
+	I_Method0(double &, getApplyTime,
+	          Properties::NON_VIRTUAL,
+	          __double_R1__getApplyTime,
+	          "",
+	          "");
+	I_StaticMethod1(osg::ref_ptr< osg::GLBufferObjectManager > &, getGLBufferObjectManager, IN, unsigned int, contextID,
+	                __osg_ref_ptrT1_GLBufferObjectManager__R1__getGLBufferObjectManager__unsigned_int_S,
+	                "",
+	                "");
+	I_SimpleProperty(double &, ApplyTime, 
+	                 __double_R1__getApplyTime, 
+	                 0);
+	I_SimpleProperty(unsigned int, ContextID, 
+	                 __unsigned_int__getContextID, 
+	                 0);
+	I_SimpleProperty(unsigned int, CurrGLBufferObjectPoolSize, 
+	                 __unsigned_int__getCurrGLBufferObjectPoolSize, 
+	                 __void__setCurrGLBufferObjectPoolSize__unsigned_int);
+	I_SimpleProperty(double &, DeleteTime, 
+	                 __double_R1__getDeleteTime, 
+	                 0);
+	I_SimpleProperty(unsigned int &, FrameNumber, 
+	                 __unsigned_int_R1__getFrameNumber, 
+	                 0);
+	I_SimpleProperty(double &, GenerateTime, 
+	                 __double_R1__getGenerateTime, 
+	                 0);
+	I_SimpleProperty(unsigned int, MaxGLBufferObjectPoolSize, 
+	                 __unsigned_int__getMaxGLBufferObjectPoolSize, 
+	                 __void__setMaxGLBufferObjectPoolSize__unsigned_int);
+	I_SimpleProperty(unsigned int, NumberActiveGLBufferObjects, 
+	                 __unsigned_int__getNumberActiveGLBufferObjects, 
+	                 __void__setNumberActiveGLBufferObjects__unsigned_int);
+	I_SimpleProperty(unsigned int &, NumberApplied, 
+	                 __unsigned_int_R1__getNumberApplied, 
+	                 0);
+	I_SimpleProperty(unsigned int &, NumberDeleted, 
+	                 __unsigned_int_R1__getNumberDeleted, 
+	                 0);
+	I_SimpleProperty(unsigned int &, NumberFrames, 
+	                 __unsigned_int_R1__getNumberFrames, 
+	                 0);
+	I_SimpleProperty(unsigned int &, NumberGenerated, 
+	                 __unsigned_int_R1__getNumberGenerated, 
+	                 0);
+	I_SimpleProperty(unsigned int, NumberOrphanedGLBufferObjects, 
+	                 __unsigned_int__getNumberOrphanedGLBufferObjects, 
+	                 __void__setNumberOrphanedGLBufferObjects__unsigned_int);
+END_REFLECTOR
+
+BEGIN_OBJECT_REFLECTOR(osg::GLBufferObjectSet)
+	I_DeclaringFile("osg/BufferObject");
+	I_BaseType(osg::Referenced);
+	I_Constructor2(IN, osg::GLBufferObjectManager *, parent, IN, const osg::BufferObjectProfile &, profile,
+	               ____GLBufferObjectSet__GLBufferObjectManager_P1__C5_BufferObjectProfile_R1,
+	               "",
+	               "");
+	I_Method0(void, handlePendingOrphandedGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __void__handlePendingOrphandedGLBufferObjects,
+	          "",
+	          "");
+	I_Method0(void, flushAllDeletedGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __void__flushAllDeletedGLBufferObjects,
+	          "",
+	          "");
+	I_Method0(void, discardAllDeletedGLBufferObjects,
+	          Properties::NON_VIRTUAL,
+	          __void__discardAllDeletedGLBufferObjects,
+	          "",
+	          "");
+	I_Method2(void, flushDeletedGLBufferObjects, IN, double, currentTime, IN, double &, availableTime,
+	          Properties::NON_VIRTUAL,
+	          __void__flushDeletedGLBufferObjects__double__double_R1,
+	          "",
+	          "");
+	I_Method1(osg::GLBufferObject *, takeFromOrphans, IN, osg::BufferObject *, bufferObject,
+	          Properties::NON_VIRTUAL,
+	          __GLBufferObject_P1__takeFromOrphans__BufferObject_P1,
+	          "",
+	          "");
+	I_Method1(osg::GLBufferObject *, takeOrGenerate, IN, osg::BufferObject *, bufferObject,
+	          Properties::NON_VIRTUAL,
+	          __GLBufferObject_P1__takeOrGenerate__BufferObject_P1,
+	          "",
+	          "");
+	I_Method1(void, moveToBack, IN, osg::GLBufferObject *, to,
+	          Properties::NON_VIRTUAL,
+	          __void__moveToBack__GLBufferObject_P1,
+	          "",
+	          "");
+	I_Method1(void, addToBack, IN, osg::GLBufferObject *, to,
+	          Properties::NON_VIRTUAL,
+	          __void__addToBack__GLBufferObject_P1,
+	          "",
+	          "");
+	I_Method1(void, orphan, IN, osg::GLBufferObject *, to,
+	          Properties::NON_VIRTUAL,
+	          __void__orphan__GLBufferObject_P1,
+	          "",
+	          "");
+	I_Method1(void, remove, IN, osg::GLBufferObject *, to,
+	          Properties::NON_VIRTUAL,
+	          __void__remove__GLBufferObject_P1,
+	          "",
+	          "");
+	I_Method0(unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__size,
+	          "",
+	          "");
+	I_Method1(bool, makeSpace, IN, unsigned int &, size,
+	          Properties::NON_VIRTUAL,
+	          __bool__makeSpace__unsigned_int_R1,
+	          "",
+	          "");
+	I_Method0(bool, checkConsistency,
+	          Properties::NON_VIRTUAL,
+	          __bool__checkConsistency,
+	          "",
+	          "");
+	I_Method0(osg::GLBufferObjectManager *, getParent,
+	          Properties::NON_VIRTUAL,
+	          __GLBufferObjectManager_P1__getParent,
+	          "",
+	          "");
+	I_SimpleProperty(osg::GLBufferObjectManager *, Parent, 
+	                 __GLBufferObjectManager_P1__getParent, 
+	                 0);
 END_REFLECTOR
 
@@ -664,2 +1036,86 @@
 END_REFLECTOR
 
+TYPE_NAME_ALIAS(std::list< osg::ref_ptr< osg::GLBufferObject > >, osg::GLBufferObjectList)
+
+BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osg::GLBufferObject >)
+	I_DeclaringFile("osg/ref_ptr");
+	I_Constructor0(____ref_ptr,
+	               "",
+	               "");
+	I_Constructor1(IN, osg::GLBufferObject *, ptr,
+	               Properties::NON_EXPLICIT,
+	               ____ref_ptr__T_P1,
+	               "",
+	               "");
+	I_Constructor1(IN, const osg::ref_ptr< osg::GLBufferObject > &, rp,
+	               Properties::NON_EXPLICIT,
+	               ____ref_ptr__C5_ref_ptr_R1,
+	               "",
+	               "");
+	I_Method0(osg::GLBufferObject *, get,
+	          Properties::NON_VIRTUAL,
+	          __T_P1__get,
+	          "",
+	          "");
+	I_Method0(bool, valid,
+	          Properties::NON_VIRTUAL,
+	          __bool__valid,
+	          "",
+	          "");
+	I_Method0(osg::GLBufferObject *, release,
+	          Properties::NON_VIRTUAL,
+	          __T_P1__release,
+	          "",
+	          "");
+	I_Method1(void, swap, IN, osg::ref_ptr< osg::GLBufferObject > &, rp,
+	          Properties::NON_VIRTUAL,
+	          __void__swap__ref_ptr_R1,
+	          "",
+	          "");
+	I_SimpleProperty(osg::GLBufferObject *, , 
+	                 __T_P1__get, 
+	                 0);
+END_REFLECTOR
+
+BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osg::GLBufferObjectManager >)
+	I_DeclaringFile("osg/ref_ptr");
+	I_Constructor0(____ref_ptr,
+	               "",
+	               "");
+	I_Constructor1(IN, osg::GLBufferObjectManager *, ptr,
+	               Properties::NON_EXPLICIT,
+	               ____ref_ptr__T_P1,
+	               "",
+	               "");
+	I_Constructor1(IN, const osg::ref_ptr< osg::GLBufferObjectManager > &, rp,
+	               Properties::NON_EXPLICIT,
+	               ____ref_ptr__C5_ref_ptr_R1,
+	               "",
+	               "");
+	I_Method0(osg::GLBufferObjectManager *, get,
+	          Properties::NON_VIRTUAL,
+	          __T_P1__get,
+	          "",
+	          "");
+	I_Method0(bool, valid,
+	          Properties::NON_VIRTUAL,
+	          __bool__valid,
+	          "",
+	          "");
+	I_Method0(osg::GLBufferObjectManager *, release,
+	          Properties::NON_VIRTUAL,
+	          __T_P1__release,
+	          "",
+	          "");
+	I_Method1(void, swap, IN, osg::ref_ptr< osg::GLBufferObjectManager > &, rp,
+	          Properties::NON_VIRTUAL,
+	          __void__swap__ref_ptr_R1,
+	          "",
+	          "");
+	I_SimpleProperty(osg::GLBufferObjectManager *, , 
+	                 __T_P1__get, 
+	                 0);
+END_REFLECTOR
+
+STD_LIST_REFLECTOR(std::list< osg::ref_ptr< osg::GLBufferObject > >)
+
Index: /OpenSceneGraph/trunk/src/osgWrappers/osg/State.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgWrappers/osg/State.cpp (revision 10600)
+++ /OpenSceneGraph/trunk/src/osgWrappers/osg/State.cpp (revision 10601)
@@ -707,22 +707,12 @@
 	          "",
 	          "");
-	I_Method1(void, setMaxVBOPoolSize, IN, unsigned int, size,
-	          Properties::NON_VIRTUAL,
-	          __void__setMaxVBOPoolSize__unsigned_int,
-	          "",
-	          "");
-	I_Method0(unsigned int, getMaxVBOPoolSize,
-	          Properties::NON_VIRTUAL,
-	          __unsigned_int__getMaxVBOPoolSize,
-	          "",
-	          "");
-	I_Method1(void, setMaxFBOPoolSize, IN, unsigned int, size,
-	          Properties::NON_VIRTUAL,
-	          __void__setMaxFBOPoolSize__unsigned_int,
-	          "",
-	          "");
-	I_Method0(unsigned int, getMaxFBOPoolSize,
-	          Properties::NON_VIRTUAL,
-	          __unsigned_int__getMaxFBOPoolSize,
+	I_Method1(void, setMaxBufferObjectPoolSize, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __void__setMaxBufferObjectPoolSize__unsigned_int,
+	          "",
+	          "");
+	I_Method0(unsigned int, getMaxBufferObjectPoolSize,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__getMaxBufferObjectPoolSize,
 	          "",
 	          "");
@@ -881,13 +871,10 @@
 	                 __C5_Program_PerContextProgram_P1__getLastAppliedProgramObject, 
 	                 __void__setLastAppliedProgramObject__C5_Program_PerContextProgram_P1);
-	I_SimpleProperty(unsigned int, MaxFBOPoolSize, 
-	                 __unsigned_int__getMaxFBOPoolSize, 
-	                 __void__setMaxFBOPoolSize__unsigned_int);
+	I_SimpleProperty(unsigned int, MaxBufferObjectPoolSize, 
+	                 __unsigned_int__getMaxBufferObjectPoolSize, 
+	                 __void__setMaxBufferObjectPoolSize__unsigned_int);
 	I_SimpleProperty(unsigned int, MaxTexturePoolSize, 
 	                 __unsigned_int__getMaxTexturePoolSize, 
 	                 __void__setMaxTexturePoolSize__unsigned_int);
-	I_SimpleProperty(unsigned int, MaxVBOPoolSize, 
-	                 __unsigned_int__getMaxVBOPoolSize, 
-	                 __void__setMaxVBOPoolSize__unsigned_int);
 	I_IndexedProperty(bool, ModeValidity, 
 	                  __bool__getModeValidity__StateAttribute_GLMode, 
Index: /OpenSceneGraph/trunk/src/osgWrappers/osg/DisplaySettings.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgWrappers/osg/DisplaySettings.cpp (revision 10588)
+++ /OpenSceneGraph/trunk/src/osgWrappers/osg/DisplaySettings.cpp (revision 10601)
@@ -395,22 +395,12 @@
 	          "",
 	          "");
-	I_Method1(void, setMaxVBOPoolSize, IN, unsigned int, size,
-	          Properties::NON_VIRTUAL,
-	          __void__setMaxVBOPoolSize__unsigned_int,
-	          "",
-	          "");
-	I_Method0(unsigned int, getMaxVBOPoolSize,
-	          Properties::NON_VIRTUAL,
-	          __unsigned_int__getMaxVBOPoolSize,
-	          "",
-	          "");
-	I_Method1(void, setMaxFBOPoolSize, IN, unsigned int, size,
-	          Properties::NON_VIRTUAL,
-	          __void__setMaxFBOPoolSize__unsigned_int,
-	          "",
-	          "");
-	I_Method0(unsigned int, getMaxFBOPoolSize,
-	          Properties::NON_VIRTUAL,
-	          __unsigned_int__getMaxFBOPoolSize,
+	I_Method1(void, setMaxBufferObjectPoolSize, IN, unsigned int, size,
+	          Properties::NON_VIRTUAL,
+	          __void__setMaxBufferObjectPoolSize__unsigned_int,
+	          "",
+	          "");
+	I_Method0(unsigned int, getMaxBufferObjectPoolSize,
+	          Properties::NON_VIRTUAL,
+	          __unsigned_int__getMaxBufferObjectPoolSize,
 	          "",
 	          "");
@@ -442,7 +432,7 @@
 	                 __float__getEyeSeparation, 
 	                 __void__setEyeSeparation__float);
-	I_SimpleProperty(unsigned int, MaxFBOPoolSize, 
-	                 __unsigned_int__getMaxFBOPoolSize, 
-	                 __void__setMaxFBOPoolSize__unsigned_int);
+	I_SimpleProperty(unsigned int, MaxBufferObjectPoolSize, 
+	                 __unsigned_int__getMaxBufferObjectPoolSize, 
+	                 __void__setMaxBufferObjectPoolSize__unsigned_int);
 	I_SimpleProperty(unsigned int, MaxNumberOfGraphicsContexts, 
 	                 __unsigned_int__getMaxNumberOfGraphicsContexts, 
@@ -451,7 +441,4 @@
 	                 __unsigned_int__getMaxTexturePoolSize, 
 	                 __void__setMaxTexturePoolSize__unsigned_int);
-	I_SimpleProperty(unsigned int, MaxVBOPoolSize, 
-	                 __unsigned_int__getMaxVBOPoolSize, 
-	                 __void__setMaxVBOPoolSize__unsigned_int);
 	I_SimpleProperty(unsigned int, MinimumNumAccumAlphaBits, 
 	                 __unsigned_int__getMinimumNumAccumAlphaBits, 
