#include <msp/core/algorithm.h>
#include "effect.h"
+using namespace std;
+
namespace Msp {
namespace GL {
}
+void Effect::Template::create_base(Effect &effect) const
+{
+ for(Tag m: enabled_methods)
+ effect.enable_for_method(m);
+}
+
+
Effect::Template::Loader::Loader(Template &t, Collection &c):
CollectionObjectLoader<Template>(t, &c)
{ }
void Effect::Template::Loader::init_actions()
{
add("content", &Template::content_name);
+ add("enable_for_method", &Loader::enable_for_method);
+}
+
+void Effect::Template::Loader::enable_for_method(const string &m)
+{
+ obj.enabled_methods.push_back(m);
}
} // namespace GL
Loader(Template &, Collection &);
protected:
virtual void init_actions();
+
+ private:
+ void enable_for_method(const std::string &);
};
std::string content_name;
+ std::vector<Tag> enabled_methods;
virtual ~Template() = default;
virtual Effect *create(const std::map<std::string, Renderable *> &) const = 0;
+ void create_base(Effect &) const;
};
protected:
env_map->set_fixed_position(fixed_position);
env_map->set_depth_clip(near_clip, far_clip);
+ create_base(*env_map);
+
return env_map.release();
}
throw invalid_operation("ShadowMap::Template::create");
}
+ create_base(*shadow_map);
+
return shadow_map.release();
}
Renderable *content = get_item(renderables, content_name);
if(!content || !sun)
throw invalid_operation("Sky::Template::create");
- return new Sky(*content, *sun);
+
+ RefPtr<Sky> sky = new Sky(*content, *sun);
+ create_base(*sky);
+
+ return sky.release();
}