]> git.tdb.fi Git - libs/gl.git/blobdiff - source/materials/material.h
Overhaul texture management in rendering classes
[libs/gl.git] / source / materials / material.h
index 571f4cb027c4da3a41e8d317e1e4c042603a2706..a04e74585e56c9fbfc9088b27bc9eb4f1ff96c81 100644 (file)
@@ -96,19 +96,22 @@ protected:
 public:
        virtual ~Material() { }
 
-       virtual Program *create_compatible_shader() const;
        virtual const Program *create_compatible_shader(DataFile::Collection &) const;
 protected:
-       virtual std::string create_program_source() const = 0;
+       virtual void fill_program_info(std::string &, std::map<std::string, int> &) const = 0;
 
 public:
        /** Returns the uniforms for the material. */
        const ProgramData &get_shader_data() const { return shdata; }
 
 protected:
-       void attach_texture_to(const Texture *, Texturing &, ProgramData &, const std::string &) const;
+       DEPRECATED void attach_texture_to(const Texture *, Texturing &, ProgramData &, const std::string &) const;
 public:
-       virtual void attach_textures_to(Texturing &, ProgramData &) const = 0;
+       DEPRECATED virtual void attach_textures_to(Texturing &, ProgramData &) const = 0;
+
+       virtual const Tag *get_texture_tags() const = 0;
+       virtual const Texture *get_texture(Tag) const = 0;
+       const Sampler *get_sampler() const { return sampler; }
 
        template<typename T>
        static void register_type(const std::string &);
@@ -127,7 +130,8 @@ template<typename C>
 void Material::PropertyLoader<C>::add_property(const std::string &kw, void (C::*set_value)(float), void (C::*set_texture)(const Texture *))
 {
        add(kw, &PropertyLoader<C>::property_value_scalar, set_value);
-       add(kw+"_map", &PropertyLoader<C>::property_texture, set_texture);
+       if(set_texture)
+               add(kw+"_map", &PropertyLoader<C>::property_texture, set_texture);
 }
 
 template<typename C>
@@ -140,7 +144,8 @@ void Material::PropertyLoader<C>::add_property(const std::string &kw, void (C::*
                add(kw, &PropertyLoader<C>::property_value_rgba, set_value);
                add(kw+"_srgb", &PropertyLoader<C>::property_value_srgb_alpha, set_value);
        }
-       add(kw+"_map", &PropertyLoader<C>::property_texture, set_texture);
+       if(set_texture)
+               add(kw+"_map", &PropertyLoader<C>::property_texture, set_texture);
 }
 
 template<typename C>