소스 검색

improved material

dm 7 년 전
부모
커밋
ea1a6e381b
4개의 변경된 파일19개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 0
      oxygine/src/oxygine/Material.cpp
  2. 5 2
      oxygine/src/oxygine/Material.h
  3. 6 0
      oxygine/src/oxygine/VisualStyle.cpp
  4. 1 0
      oxygine/src/oxygine/VisualStyle.h

+ 7 - 0
oxygine/src/oxygine/Material.cpp

@@ -81,6 +81,13 @@ namespace oxygine
     }
 
 
+    spSTDMaterial STDMaterial::cloneDefaultShader() const
+    {
+        STDMaterial mat(*this);
+        mat._uberShader = &STDRenderer::uberShader;
+        return mc().cache(mat);
+    }
+
     Material::Material(const Material& other)
     {
         _hash = other._hash;

+ 5 - 2
oxygine/src/oxygine/Material.h

@@ -15,6 +15,7 @@ namespace oxygine
         init();\
     }\
     void copyTo(cl &d) const{d = *this;}\
+    void copyFrom(const cl &d) {*this = d;}\
     cl* clone() const override {return new cl(*this);}\
     void update(size_t &hash, compare &cm) const override {\
         typedef bool (*fn)(const cl&a, const cl&b);\
@@ -80,6 +81,7 @@ namespace oxygine
         void rehash(size_t& hash) const override {}
     };
 
+    DECLARE_SMART(STDMaterial, spSTDMaterial);
     class STDMaterial: public Material
     {
     public:
@@ -102,7 +104,8 @@ namespace oxygine
 
         void render(const AffineTransform& tr, const Color& c, const RectF& src, const RectF& dest) override;
         void render(const Color& c, const RectF& src, const RectF& dest) override;
-    };
 
-    DECLARE_SMART(STDMaterial, spSTDMaterial);
+        spSTDMaterial cloneDefaultShader() const;
+    };
+    
 }

+ 6 - 0
oxygine/src/oxygine/VisualStyle.cpp

@@ -131,4 +131,10 @@ namespace oxygine
         _mat = mat;
         matChanged();
     }
+
+    void VStyleActor::resetMaterial()
+    {
+        setMaterial(_mat->cloneDefaultShader());
+    }
+
 }

+ 1 - 0
oxygine/src/oxygine/VisualStyle.h

@@ -51,6 +51,7 @@ namespace oxygine
         typedef Property<Color, const Color&, VStyleActor, &VStyleActor::getAddColor, &VStyleActor::setAddColor> TweenAddColor;
 
         void                    setMaterial(spSTDMaterial mat);
+        void                    resetMaterial();
         spSTDMaterial _mat;
 
     protected: