]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/mat.hxx
Memory leak fixes from Till Busch
[simgear.git] / simgear / scene / material / mat.hxx
index ea96ababb9ce2ea32c4df689ac69b4c723348ac9..0a0fbd13289c7781140497307ddad3fdf20b7393 100644 (file)
@@ -43,6 +43,7 @@
 
 #include <simgear/props/props.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
+#include <simgear/scene/util/SGSceneFeatures.hxx>
 
 #include "matmodel.hxx"
 
@@ -53,7 +54,6 @@ SG_USING_STD(map);
 
 class SGMaterialGlyph;
 
-
 /**
  * A material in the scene graph.
  *
@@ -113,19 +113,10 @@ public:
   // Public methods.
   ////////////////////////////////////////////////////////////////////
 
-  /**
-   * Force the texture to load if it hasn't already.
-   *
-   * @return true if the texture loaded, false if it was loaded
-   * already.
-   */
-  bool load_texture (int n = -1);
-
-
   /**
    * Get the textured state.
    */
-  osg::StateSet *get_state (int n = -1) const;
+  osg::StateSet *get_state (int n = -1);
 
 
   /**
@@ -208,6 +199,20 @@ public:
    */
   SGMaterialGlyph * get_glyph (const string& name) const;
 
+  void set_light_color(const SGVec4f& color)
+  { emission = color; }
+  const SGVec4f& get_light_color() const
+  { return emission; }
+
+  SGVec2f get_tex_coord_scale() const
+  {
+    float tex_width = get_xsize();
+    float tex_height = get_ysize();
+
+    return SGVec2f((0 < tex_width) ? 1000.0f/tex_width : 1.0f,
+                   (0 < tex_height) ? 1000.0f/tex_height : 1.0f);
+  }
+
 protected:
 
 \f
@@ -252,9 +257,6 @@ private:
   // use mipmapping?
   int mipmap;
 
-  // use anisotropic filtering
-  float filtering;
-
   // coverage of night lighting.
   double light_coverage;
 
@@ -296,7 +298,7 @@ private:
   void build_state( bool defer_tex_load );
   void set_state( osg::StateSet *s );
 
-  void assignTexture( osg::StateSet *state, const std::string &fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE, float filtering = 1.0f );
+  void assignTexture( osg::StateSet *state, const std::string &fname, int _wrapu = TRUE, int _wrapv = TRUE, int _mipmap = TRUE );
 
 };
 
@@ -321,7 +323,15 @@ public:
   const SGMaterial* getMaterial() const
   { return mMaterial; }
 private:
-  SGSharedPtr<const SGMaterial> mMaterial;
+  // this cannot be an SGSharedPtr since that would create a cicrular reference
+  // making it impossible to ever free the space needed by SGMaterial
+  const SGMaterial* mMaterial;
 };
 
+void
+SGSetTextureFilter( int max);
+
+int
+SGGetTextureFilter();
+
 #endif // _SG_MAT_HXX