From 26c911acf39d152eea009b1434ed7fc54667641d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 9 Nov 2005 20:24:47 +0000 Subject: [PATCH] Added a s/getState() to osgTerrain::DataSet to allow better integration with applications. --- include/osgTerrain/DataSet | 6 +++++- src/osgTerrain/DataSet.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/osgTerrain/DataSet b/include/osgTerrain/DataSet index f0da839fb..76def058f 100644 --- a/include/osgTerrain/DataSet +++ b/include/osgTerrain/DataSet @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -1085,7 +1086,8 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced void _writeNodeFile(const osg::Node& node,const std::string& filename); void _writeImageFile(const osg::Image& image,const std::string& filename); - + void setState(osg::State* state) { _state = state; } + osg::State* getState() { return _state.get(); } protected: @@ -1152,6 +1154,8 @@ class OSGTERRAIN_EXPORT DataSet : public osg::Referenced bool _writeNodeBeforeSimplification; osg::ref_ptr _rootNode; + osg::ref_ptr _state; + }; diff --git a/src/osgTerrain/DataSet.cpp b/src/osgTerrain/DataSet.cpp index e8245a953..1241103dc 100644 --- a/src/osgTerrain/DataSet.cpp +++ b/src/osgTerrain/DataSet.cpp @@ -2264,14 +2264,12 @@ osg::StateSet* DataSet::DestinationTile::createStateSet() else texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT5_COMPRESSION); - osg::ref_ptr state = new osg::State; - // force the mip mapping off temporay if we intend the graphics hardware to do the mipmapping. if (_dataSet->getMipMappingMode()==DataSet::MIP_MAPPING_HARDWARE) texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); // get OpenGL driver to create texture from image. - texture->apply(*state); + texture->apply(*(_dataSet->getState())); image->readImageFromCurrentTexture(0,true); @@ -2304,7 +2302,7 @@ osg::StateSet* DataSet::DestinationTile::createStateSet() osg::ref_ptr state = new osg::State; // get OpenGL driver to create texture from image. - texture->apply(*state); + texture->apply(*(_dataSet->getState())); image->readImageFromCurrentTexture(0,true); @@ -4581,6 +4579,8 @@ osg::Node* DataSet::decorateWithMultiTextureControl(osg::Node* subgraph) void DataSet::_buildDestination(bool writeToDisk) { + if (!_state) _state = new osg::State; + osg::ref_ptr previous_options = osgDB::Registry::instance()->getOptions(); osgDB::Registry::instance()->setOptions(new osgDB::ReaderWriter::Options("precision 16"));