1 #ifndef MSP_GL_RENDERPASS_H_
2 #define MSP_GL_RENDERPASS_H_
4 #include <msp/core/refptr.h>
5 #include <msp/datafile/objectloader.h>
19 Encapsulates the data that determines the appearance of a rendered surface.
20 This includes shader and data for it, material and texturing.
25 class Loader: public DataFile::CollectionObjectLoader<RenderMethod>
28 std::string inline_base_name;
30 static ActionMap shared_actions;
33 Loader(RenderMethod &, Collection &);
35 virtual void init_actions();
38 void set_inline_base_name(const std::string &);
41 virtual void finish();
43 void material_inline();
44 void material(const std::string &);
45 void shader(const std::string &);
46 void texture(const std::string &);
48 void uniform_slot(const std::string &);
49 void uniform_slot2(const std::string &, const std::string &);
55 class Loader: public DataFile::CollectionObjectLoader<TextureSlot>
58 std::string auto_slot_name;
61 Loader(TextureSlot &, const std::string &, Collection *);
68 std::string slot_name;
69 const Texture *texture;
70 const Sampler *sampler;
72 TextureSlot(Tag t): tag(t), texture(0), sampler(0) { }
75 const Program *shprog = 0;
76 bool shprog_from_material = false;
77 RefPtr<ProgramData> shdata;
78 std::map<Tag, Tag> uniform_slots;
79 const Material *material = 0;
80 std::string material_slot;
81 std::vector<TextureSlot> textures;
82 CullMode face_cull = CULL_BACK;
83 bool receive_shadows = false;
84 bool image_based_lighting = false;
86 void maybe_create_material_shader();
87 void set_material_textures();
90 void set_shader_program(const Program *, const ProgramData *);
91 const Program *get_shader_program() const { return shprog; }
92 const ProgramData *get_shader_data() const { return shdata.get(); }
93 Tag get_slotted_uniform_tag(Tag) const;
94 void set_material(const Material *);
95 const Material *get_material() const { return material; }
96 const std::string &get_material_slot_name() const { return material_slot; }
97 void set_texture(Tag, const Texture *, const Sampler * = 0);
98 Tag get_texture_tag(const std::string &) const;
99 void set_face_cull(CullMode);
100 CullMode get_face_cull() const { return face_cull; }
101 void set_receive_shadows(bool);
102 bool get_receive_shadows() const { return receive_shadows; }
103 void set_image_based_lighting(bool);
104 bool get_image_based_lighting() const { return image_based_lighting; }
106 void apply(Renderer &) const;
108 void set_debug_name(const std::string &);