#ifndef MSP_GL_MATERIAL_H_
#define MSP_GL_MATERIAL_H_
+#include <msp/core/typeregistry.h>
#include <msp/datafile/collection.h>
-#include <msp/datafile/loadabletyperegistry.h>
#include <msp/datafile/objectloader.h>
#include "color.h"
#include "programdata.h"
template<typename T>
struct AddType
{
- static void add(GenericLoader &ldr, const std::string &kw) { ldr.add(kw, &GenericLoader::typed_material<T>); }
+ void operator()(const std::string &kw, GenericLoader &ldr) const { ldr.add(kw, &GenericLoader::typed_material<T>); }
};
DataFile::Collection *coll;
};
private:
- typedef DataFile::LoadableTypeRegistry<GenericLoader, GenericLoader::AddType> MaterialRegistry;
+ typedef TypeRegistry<GenericLoader::AddType, GenericLoader &> MaterialRegistry;
protected:
const Sampler *sampler;
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 &);