]> git.mxchange.org Git - simgear.git/commitdiff
Centralize osgDB::Option handling in SGReaderWriterOptions.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Sun, 4 Mar 2012 07:33:21 +0000 (08:33 +0100)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Sun, 4 Mar 2012 07:33:21 +0000 (08:33 +0100)
projects/VC90/SimGear.vcproj
simgear/scene/sky/cloud.cxx
simgear/scene/sky/moon.cxx
simgear/scene/sky/newcloud.cxx
simgear/scene/sky/oursun.cxx
simgear/scene/util/CMakeLists.txt
simgear/scene/util/PathOptions.cxx [deleted file]
simgear/scene/util/PathOptions.hxx [deleted file]
simgear/scene/util/SGReaderWriterOptions.hxx

index 535d027dff67e186dc93ed362ad0ac698b9261f4..de01f387d3884b827090835ed1351c92ac93fca8 100644 (file)
                                RelativePath="..\..\simgear\scene\util\NodeAndDrawableVisitor.hxx"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\simgear\scene\util\PathOptions.cxx"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\simgear\scene\util\PathOptions.hxx"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\simgear\scene\util\PrimitiveUtils.cxx"\r
                                >\r
index aeac58ffe1ee0d59bc0a0e88957a47ece806018c..5517cff9ac2c754c0fe7f7cac752fad84acc54d5 100644 (file)
 #include <osg/TextureCubeMap>
 #include <osg/TexMat>
 #include <osg/Fog>
-#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5)
-#include <osgDB/Options>
-#endif
 
 #include <simgear/math/sg_random.h>
-#include <simgear/scene/util/PathOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/scene/model/model.hxx>
 #include <simgear/scene/util/RenderConstants.hxx>
@@ -94,8 +91,8 @@ SGMakeState(const SGPath &path, const char* colorTexture,
 {
     osg::StateSet *stateSet = new osg::StateSet;
 
-    osg::ref_ptr<osgDB::Options> options
-        = makeOptionsFromPath(path);
+    osg::ref_ptr<SGReaderWriterOptions> options;
+    options = SGReaderWriterOptions::fromPath(path.str());
     stateSet->setTextureAttribute(0, SGLoadTexture2D(colorTexture,
                                                      options.get()));
     stateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON);
index f6539309dfd2d577d763965061df99da458426e8..1fa724ef710a8479864a64ae5c506b0563c6c1d5 100644 (file)
 #include <osg/ShadeModel>
 #include <osg/TexEnv>
 #include <osg/Texture2D>
-#if SG_OSG_MIN_VERSION_REQUIRED(2,9,5)
-#include <osgDB/Options>
-#endif
 
 #include <simgear/constants.h>
 #include <simgear/screen/colors.hxx>
 #include <simgear/scene/model/model.hxx>
-#include <simgear/scene/util/PathOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 
 #include "sphere.hxx"
 #include "moon.hxx"
@@ -78,8 +75,8 @@ SGMoon::build( SGPath path, double moon_size ) {
     stateSet->setRenderBinDetails(-5, "RenderBin");
 
     // set up the orb state
-    osg::ref_ptr<osgDB::Options> options
-        = makeOptionsFromPath(path);
+    osg::ref_ptr<SGReaderWriterOptions> options;
+    options = SGReaderWriterOptions::fromPath(path.str());
 
     osg::Texture2D* texture = SGLoadTexture2D("moon.png", options.get());
     stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
index 3dee4ab479e90bba6a2f90e20fe8457440383c1f..04fb2207c8409ab4092410816484410a9d3c5f9f 100644 (file)
@@ -42,7 +42,6 @@
 
 #include <simgear/math/sg_random.h>
 #include <simgear/misc/sg_path.hxx>
-#include <simgear/scene/util/PathOptions.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/scene/model/model.hxx>
 #include <simgear/scene/util/SGReaderWriterOptions.hxx>
@@ -110,11 +109,9 @@ SGNewCloud::SGNewCloud(const SGPath &texture_root, const SGPropertyNode *cld_def
                                      "texture"),
                            "image"),
                  texture);
-        ref_ptr<osgDB::Options> options
-            = makeOptionsFromPath(texture_root);
-        ref_ptr<SGReaderWriterOptions> sgOptions
-            = new SGReaderWriterOptions(*options.get());
-        if ((effect = makeEffect(pcloudEffect, true, sgOptions.get())))
+        ref_ptr<SGReaderWriterOptions> options;
+        options = SGReaderWriterOptions::fromPath(texture_root.str());
+        if ((effect = makeEffect(pcloudEffect, true, options.get())))
             effectMap.insert(EffectMap::value_type(texture, effect));
     } else {
         effect = iter->second.get();
index f2af25f804ac42dfef67df8404933e08dd8ae359..f959200c60b3dd0079010600bcd7f3713f2e3c76 100644 (file)
@@ -42,7 +42,7 @@
 #include <osgDB/ReadFile>
 
 #include <simgear/math/SGMath.hxx>
-#include <simgear/scene/util/PathOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/screen/colors.hxx>
 #include <simgear/scene/model/model.hxx>
 #include "oursun.hxx"
@@ -69,8 +69,8 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
 
     env_node = property_tree_Node;
 
-    osg::ref_ptr<osgDB::Options> options
-        = makeOptionsFromPath(path);
+    osg::ref_ptr<SGReaderWriterOptions> options;
+    options = SGReaderWriterOptions::fromPath(path.str());
     // build the ssg scene graph sub tree for the sky and connected
     // into the provide scene graph branch
     sun_transform = new osg::MatrixTransform;
index 8d5e84a2496888fc944c1c0234719e30433f216c..8ec8d11960eced8a9a074890e70e953b07fde115 100644 (file)
@@ -22,7 +22,6 @@ set(HEADERS
     StateAttributeFactory.hxx
     UpdateOnceCallback.hxx
     VectorArrayAdapter.hxx
-    PathOptions.hxx
     project.hxx
     )
 
@@ -39,7 +38,6 @@ set(SOURCES
     SplicingVisitor.cxx
     StateAttributeFactory.cxx
     UpdateOnceCallback.cxx
-    PathOptions.cxx
     project.cxx
     )
 
diff --git a/simgear/scene/util/PathOptions.cxx b/simgear/scene/util/PathOptions.cxx
deleted file mode 100644 (file)
index 711b04b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// PathOptions.cxx -- make an osgDB Options object from a path
-// Copyright (C) 2007  Tim Moore timoore@redhat.com
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//
-// $Id$
-
-#ifdef HAVE_CONFIG_H
-#  include <simgear_config.h>
-#endif
-
-#include <osgDB/Registry>
-
-#include "PathOptions.hxx"
-
-using namespace simgear;
-
-osgDB::Options* simgear::makeOptionsFromPath(const SGPath& path)
-{
-    using namespace osgDB;
-    Options *options
-        = new Options(*(Registry::instance()->getOptions()));
-    options->setDatabasePath(path.str());
-    return options;
-}
diff --git a/simgear/scene/util/PathOptions.hxx b/simgear/scene/util/PathOptions.hxx
deleted file mode 100644 (file)
index e1bc331..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// PathOptions.hxx -- make an osgDB Options object from a path
-// Copyright (C) 2007  Tim Moore timoore@redhat.com
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//
-// $Id$
-
-#ifndef PATHOPTIONSHXX
-#define PATHOPTIONSHXX 1
-
-#include <osgDB/ReaderWriter>
-#include <simgear/misc/sg_path.hxx>
-
-namespace simgear
-{
-osgDB::Options* makeOptionsFromPath(const SGPath&);
-}
-
-#endif
index ef7a586487e54c78eadf00c5f0f3baee8aa3e0f6..798c85fef3ca4c35da3979cb2774cd31859e043f 100644 (file)
@@ -104,6 +104,13 @@ public:
         return new SGReaderWriterOptions(*static_cast<const SGReaderWriterOptions*>(options));
     }
 
+    static SGReaderWriterOptions* fromPath(const std::string& path)
+    {
+        SGReaderWriterOptions* options = copyOrCreate(0);
+        options->setDatabasePath(path);
+        return options;
+    }
+
 protected:
     virtual ~SGReaderWriterOptions() {}