1 #ifndef MSP_GL_RENDERPASS_H_
2 #define MSP_GL_RENDERPASS_H_
4 #include <msp/core/refptr.h>
5 #include <msp/datafile/objectloader.h>
20 Encapsulates the data that determines the appearance of a rendered surface.
21 This includes shader and data for it, material and texturing.
26 class Loader: public DataFile::CollectionObjectLoader<RenderMethod>
29 std::string inline_base_name;
31 static ActionMap shared_actions;
34 Loader(RenderMethod &, Collection &);
36 virtual void init_actions();
39 void set_inline_base_name(const std::string &);
42 virtual void finish();
45 void blend_factors(BlendFactor, BlendFactor);
46 void material_inline();
47 void material(const std::string &);
48 void shader(const std::string &);
49 void texture(const std::string &);
51 void uniform_slot(const std::string &);
52 void uniform_slot2(const std::string &, const std::string &);
58 class Loader: public DataFile::CollectionObjectLoader<TextureSlot>
61 std::string auto_slot_name;
64 Loader(TextureSlot &, const std::string &, Collection *);
71 std::string slot_name;
72 const Texture *texture;
73 const Sampler *sampler;
75 TextureSlot(Tag t): tag(t), texture(0), sampler(0) { }
78 const Program *shprog = 0;
79 bool shprog_from_material = false;
80 RefPtr<ProgramData> shdata;
81 std::map<Tag, Tag> uniform_slots;
82 const Material *material = 0;
83 std::string material_slot;
84 std::vector<TextureSlot> textures;
85 CullMode face_cull = CULL_BACK;
87 bool receive_shadows = false;
88 bool image_based_lighting = false;
90 void maybe_create_material_shader();
91 void set_material_textures();
94 void set_shader_program(const Program *, const ProgramData *);
95 const Program *get_shader_program() const { return shprog; }
96 const ProgramData *get_shader_data() const { return shdata.get(); }
97 Tag get_slotted_uniform_tag(Tag) const;
98 void set_material(const Material *);
99 const Material *get_material() const { return material; }
100 const std::string &get_material_slot_name() const { return material_slot; }
101 void set_texture(Tag, const Texture *, const Sampler * = 0);
102 Tag get_texture_tag(const std::string &) const;
103 void set_face_cull(CullMode);
104 CullMode get_face_cull() const { return face_cull; }
105 void set_blend(const Blend &);
106 const Blend &get_blend() const { return blend; }
107 void set_receive_shadows(bool);
108 bool get_receive_shadows() const { return receive_shadows; }
109 void set_image_based_lighting(bool);
110 bool get_image_based_lighting() const { return image_based_lighting; }
112 void apply(Renderer &) const;
114 void set_debug_name(const std::string &);