]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/shadanim.cxx
Do not modify danymically generated textures.
[simgear.git] / simgear / scene / model / shadanim.cxx
index ec1403b178b6fc9498f0875ca6fd2db6b5b0cc6a..9f94730df5687f824b82982ee260309d25258c61 100644 (file)
 #include <osg/Texture1D>
 #include <osgUtil/HighlightMapGenerator>
 
+#include <OpenThreads/Mutex>
+#include <OpenThreads/ScopedLock>
+
 #include <simgear/scene/util/SGUpdateVisitor.hxx>
-#include <simgear/threads/SGThread.hxx>
-#include <simgear/threads/SGGuard.hxx>
 
 #include <simgear/props/condition.hxx>
 #include <simgear/props/props.hxx>
 
 #include "animation.hxx"
 #include "model.hxx"
+
+using OpenThreads::Mutex;
+using OpenThreads::ScopedLock;
+
 /*
     <animation>
         <type>shader</type>
@@ -125,6 +130,8 @@ private:
   SGVec4f _lastLightColor;
 };
 
+static Mutex cubeMutex;
+
 static osg::TextureCubeMap*
 getOrCreateTextureCubeMap()
 {
@@ -132,8 +139,7 @@ getOrCreateTextureCubeMap()
   if (textureCubeMap.get())
     return textureCubeMap.get();
 
-  static SGMutex mutex;
-  SGGuard<SGMutex> locker(mutex);
+  ScopedLock<Mutex> lock(cubeMutex);
   if (textureCubeMap.get())
     return textureCubeMap.get();
 
@@ -178,12 +184,14 @@ static void create_specular_highlights(osg::Node *node)
 
 
 SGShaderAnimation::SGShaderAnimation(const SGPropertyNode* configNode,
-                                     SGPropertyNode* modelRoot) :
+                                     SGPropertyNode* modelRoot,
+                                     const osgDB::ReaderWriter::Options*
+                                     options) :
   SGAnimation(configNode, modelRoot)
 {
   const SGPropertyNode* node = configNode->getChild("texture");
   if (node)
-    _effect_texture = SGLoadTexture2D(node->getStringValue());
+    _effect_texture = SGLoadTexture2D(node->getStringValue(), options);
 }
 
 namespace {
@@ -206,17 +214,18 @@ public:
   }
 };
     
-typedef map<osg::ref_ptr<osg::Texture2D>, osg::ref_ptr<osg::StateSet> >
+typedef std::map<osg::ref_ptr<osg::Texture2D>, osg::ref_ptr<osg::StateSet> >
 StateSetMap;
 }
 
+static Mutex chromeMutex;
+
 // The chrome effect is mixed by the alpha channel of the texture
 // on the model, which will be attached to a node lower in the scene
 // graph: 0 -> completely chrome, 1 -> completely model texture.
 static void create_chrome(osg::Group* group, osg::Texture2D* texture)
 {
-    static SGMutex mutex;
-    SGGuard<SGMutex> locker(mutex);
+    ScopedLock<Mutex> lock(chromeMutex);
     static StateSetMap chromeMap;
     osg::StateSet *stateSet;
     StateSetMap::iterator iterator = chromeMap.find(texture);