]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/cloud.cxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / sky / cloud.cxx
index 19d5c70ca9ee20fadcfd9e04fcebb7f8d88a4d21..3558cac90a01c489d7db12c5e4594e06a81081f6 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/misc/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>
+#include <simgear/scene/util/OsgMath.hxx>
 #include <simgear/scene/util/StateAttributeFactory.hxx>
 #include <simgear/screen/extensions.hxx>
 
@@ -78,9 +76,6 @@ static osg::ref_ptr<osg::StateSet> layer_states[SGCloudLayer::SG_MAX_CLOUD_COVER
 static osg::ref_ptr<osg::StateSet> layer_states2[SGCloudLayer::SG_MAX_CLOUD_COVERAGES];
 static osg::ref_ptr<osg::TextureCubeMap> cubeMap;
 static bool state_initialized = false;
-static bool bump_mapping = false;
-
-bool SGCloudLayer::enable_bump_mapping = false;
 
 const std::string SGCloudLayer::SG_CLOUD_OVERCAST_STRING = "overcast";
 const std::string SGCloudLayer::SG_CLOUD_BROKEN_STRING = "broken";
@@ -96,8 +91,8 @@ SGMakeState(const SGPath &path, const char* colorTexture,
 {
     osg::StateSet *stateSet = new osg::StateSet;
 
-    osg::ref_ptr<osgDB::ReaderWriter::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);
@@ -199,7 +194,10 @@ SGCloudLayer::SGCloudLayer( const string &tex_path ) :
                                        ->getWhiteTexture(),
                                        osg::StateAttribute::ON);
   rootSet->setDataVariance(osg::Object::DYNAMIC);
-
+  
+  // Ensure repeatability of the random seed within 10 minutes,
+  // to keep multi-computer systems in sync.
+  sg_srandom_time_10();
   base = osg::Vec2(sg_random(), sg_random());
   group_top->addChild(layer_transform.get());
   group_bottom->addChild(layer_transform.get());
@@ -381,18 +379,6 @@ SGCloudLayer::rebuild()
 
         SG_LOG(SG_ASTRO, SG_INFO, "initializing cloud layers");
 
-        osg::Texture::Extensions* extensions;
-        extensions = osg::Texture::getExtensions(0, true);
-        // OSGFIXME
-        bump_mapping = extensions->isMultiTexturingSupported() &&
-          (2 <= extensions->numTextureUnits()) &&
-          SGIsOpenGLExtensionSupported("GL_ARB_texture_env_combine") &&
-          SGIsOpenGLExtensionSupported("GL_ARB_texture_env_dot3");
-
-        osg::TextureCubeMap::Extensions* extensions2;
-        extensions2 = osg::TextureCubeMap::getExtensions(0, true);
-        bump_mapping = bump_mapping && extensions2->isCubeMapSupported();
-
         // This bump mapping code was inspired by the tutorial available at 
         // http://www.paulsprojects.net/tutorials/simplebump/simplebump.html
         // and a NVidia white paper