#define MSP_GL_EFFECT_H_
#include <set>
+#include <msp/datafile/objectloader.h>
#include "renderable.h"
namespace Msp {
namespace GL {
/**
-Effects are used to wrap other renderables and give them additional visual
-properties. An Effect's render method should set up the necessary state, call
-the wrapped Renderable's render method, and clean up after itself.
+Base class for visual effects.
+
+Effects wrap other renderables and provide additional textures or uniform
+values which can be used by shaders to modify the appearance of the content
+renderable. Some material properties require certain Effects to be present in
+order to function properly.
+
+If an Effect subclass needs to do any sideband rendering to prepare for a
+frame, that should be done in setup_frame(). The render() function should only
+set up the necessary state and call the content renderable's render() function.
*/
class Effect: public Renderable
{
+public:
+ /**
+ Holds the parameters for an Effect. Used with SequenceTemplate.
+ */
+ struct Template
+ {
+ class Loader: public DataFile::CollectionObjectLoader<Template>
+ {
+ public:
+ Loader(Template &, Collection &);
+ protected:
+ virtual void init_actions();
+ };
+
+ std::string content_name;
+
+ virtual ~Template() = default;
+
+ virtual Effect *create(const std::map<std::string, Renderable *> &) const = 0;
+ };
+
protected:
- Renderable &renderable;
- std::set<Tag> enabled_passes;
+ Renderable &content;
+ std::vector<Tag> enabled_methods;
protected:
Effect(Renderable &);
public:
virtual ~Effect() { }
- void enable_for_pass(Tag);
- void disable_for_pass(Tag);
+ void enable_for_method(Tag);
+ void disable_for_method(Tag);
+ bool is_enabled_for_method(Tag) const;
- virtual const Matrix *get_matrix() const { return renderable.get_matrix(); }
- virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return renderable.get_bounding_sphere(); }
+ virtual const Matrix *get_matrix() const { return content.get_matrix(); }
+ virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return content.get_bounding_sphere(); }
- virtual void setup_frame(Renderer &r) { renderable.setup_frame(r); }
- virtual void finish_frame() { renderable.finish_frame(); }
+ virtual void setup_frame(Renderer &r) { content.setup_frame(r); }
+ virtual void finish_frame() { content.finish_frame(); }
virtual void set_debug_name(const std::string &) = 0;
};