diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index 5a012ceb7..6d6a0e969 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -166,24 +166,38 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl * before being removed.*/ double getExpiryDelay() const { return _expiryDelay; } - /** set whether the removed subgraphs should be deleted in the database thread or not.*/ + /** Set whether the removed subgraphs should be deleted in the database thread or not.*/ void setDeleteRemovedSubgraphsInDatabaseThread(bool flag) { _deleteRemovedSubgraphsInDatabaseThread = flag; } - /** get whether the removed subgraphs should be deleted in the database thread or not.*/ + /** Get whether the removed subgraphs should be deleted in the database thread or not.*/ bool getDeleteRemovedSubgraphsInDatabaseThread() const { return _deleteRemovedSubgraphsInDatabaseThread; } + enum DrawablePolicy + { + DO_NOT_MODIFY_DRAWABLE_SETTINGS, + USE_DISPLAY_LISTS, + USE_VERTEX_BUFFER_OBJECTS, + USE_VERTEX_ARRAYS + }; - /** set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/ + /** Set how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.*/ + void setDrawablePolicy(DrawablePolicy policy) { _drawablePolicy = policy; } + + /** Get how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.*/ + DrawablePolicy getDrawablePolicy() const { return _drawablePolicy; } + + + /** Set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/ void setUnrefImageDataAfterApplyPolicy(bool changeAutoUnRef, bool valueAutoUnRef) { _changeAutoUnRef = changeAutoUnRef; _valueAutoUnRef = valueAutoUnRef; } - /** get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/ + /** Get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/ void getUnrefImageDataAfterApplyPolicy(bool& changeAutoUnRef, bool& valueAutoUnRef) const { changeAutoUnRef = _changeAutoUnRef; valueAutoUnRef = _valueAutoUnRef; } - /** set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/ + /** Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/ void setMaxAnisotropyPolicy(bool changeAnisotropy, float valueAnisotropy) { _changeAnisotropy = changeAnisotropy; _valueAnisotropy = valueAnisotropy; } - /** set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/ + /** Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/ void getMaxAnisotropyPolicy(bool& changeAnisotropy, float& valueAnisotropy) const { changeAnisotropy = _changeAnisotropy; valueAnisotropy = _valueAnisotropy; } @@ -310,6 +324,8 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl DatabaseRequestList _dataToCompileList; mutable OpenThreads::Mutex _dataToCompileListMutex; + DrawablePolicy _drawablePolicy; + bool _changeAutoUnRef; bool _valueAutoUnRef; bool _changeAnisotropy; diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 7e8b80239..fe11619ae 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -23,7 +23,7 @@ using namespace OpenThreads; static osg::ApplicationUsageProxy DatabasePager_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DO_PRE_COMPILE ","Switch on or off the pre compile of OpenGL object database pager."); static osg::ApplicationUsageProxy DatabasePager_e1(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MINIMUM_COMPILE_TIME_PER_FRAME ","minimum compile time alloted to compiling OpenGL objects per frame in database pager."); static osg::ApplicationUsageProxy DatabasePager_e2(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAXIMUM_OBJECTS_TO_COMPILE_PER_FRAME ","maximum number of OpenGL objects to compile per frame in database pager."); - +static osg::ApplicationUsageProxy DatabasePager_e3(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DATABASE_PAGER_DRAWABLE ","Set the drawable policy for setting of loaded drawable to specified type."); DatabasePager::DatabasePager() { //osg::notify(osg::INFO)<<"Constructing DatabasePager()"<getStateSet()); - drawable->setUseDisplayList(_useDisplayLists); - drawable->setUseVertexBufferObjects(_useVertexBufferObjects); - + switch(_drawablePolicy) + { + case DatabasePager::DO_NOT_MODIFY_DRAWABLE_SETTINGS: + // do nothing, leave settings as they came in from loaded database. + // osg::notify(osg::NOTICE)<<"DO_NOT_MODIFY_DRAWABLE_SETTINGS"<setUseDisplayList(true); + drawable->setUseVertexBufferObjects(false); + break; + case DatabasePager::USE_VERTEX_BUFFER_OBJECTS: + drawable->setUseDisplayList(true); + drawable->setUseVertexBufferObjects(true); + // osg::notify(osg::NOTICE)<<"USE_VERTEX_BUFFER_OBJECTS"<setUseDisplayList(false); + drawable->setUseVertexBufferObjects(false); + // osg::notify(osg::NOTICE)<<"USE_VERTEX_ARRAYS"<getUseDisplayList() || drawable->getUseVertexBufferObjects()) { - //osg::notify(osg::INFO)<<"Found compilable drawable"<_loadedModel->accept(frov); diff --git a/src/osgWrappers/osgDB/DatabasePager.cpp b/src/osgWrappers/osgDB/DatabasePager.cpp index cf05271ac..ed5936079 100644 --- a/src/osgWrappers/osgDB/DatabasePager.cpp +++ b/src/osgWrappers/osgDB/DatabasePager.cpp @@ -39,6 +39,13 @@ TYPE_NAME_ALIAS(std::map< unsigned int COMMA osgDB::DatabasePager::DataToCompil TYPE_NAME_ALIAS(std::set< unsigned int >, osgDB::DatabasePager::ActiveGraphicsContexts); +BEGIN_ENUM_REFLECTOR(osgDB::DatabasePager::DrawablePolicy) + I_EnumLabel(osgDB::DatabasePager::DO_NOT_MODIFY_DRAWABLE_SETTINGS); + I_EnumLabel(osgDB::DatabasePager::USE_DISPLAY_LISTS); + I_EnumLabel(osgDB::DatabasePager::USE_VERTEX_BUFFER_OBJECTS); + I_EnumLabel(osgDB::DatabasePager::USE_VERTEX_ARRAYS); +END_REFLECTOR + BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager) I_BaseType(osg::NodeVisitor::DatabaseRequestHandler); I_Constructor0(); @@ -73,6 +80,8 @@ BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager) I_Method0(double, getExpiryDelay); I_Method1(void, setDeleteRemovedSubgraphsInDatabaseThread, IN, bool, flag); I_Method0(bool, getDeleteRemovedSubgraphsInDatabaseThread); + I_Method1(void, setDrawablePolicy, IN, osgDB::DatabasePager::DrawablePolicy, policy); + I_Method0(osgDB::DatabasePager::DrawablePolicy, getDrawablePolicy); I_Method2(void, setUnrefImageDataAfterApplyPolicy, IN, bool, changeAutoUnRef, IN, bool, valueAutoUnRef); I_Method2(void, getUnrefImageDataAfterApplyPolicy, IN, bool &, changeAutoUnRef, IN, bool &, valueAutoUnRef); I_Method2(void, setMaxAnisotropyPolicy, IN, bool, changeAnisotropy, IN, float, valueAnisotropy); @@ -88,6 +97,7 @@ BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager) I_Property(bool, DatabasePagerThreadPause); I_Property(bool, DeleteRemovedSubgraphsInDatabaseThread); I_Property(bool, DoPreCompile); + I_Property(osgDB::DatabasePager::DrawablePolicy, DrawablePolicy); I_Property(double, ExpiryDelay); I_ReadOnlyProperty(osg::Block *, FrameBlock); I_Property(unsigned int, MaximumNumOfObjectsToCompilePerFrame);