1 #ifndef MSP_GL_RENDERPASS_H_
2 #define MSP_GL_RENDERPASS_H_
4 #include <msp/core/refptr.h>
5 #include <msp/datafile/objectloader.h>
18 Encapsulates the data that determines the appearance of a rendered surface.
19 This includes shader and data for it, material and texturing.
24 class Loader: public DataFile::CollectionObjectLoader<RenderPass>
27 std::string inline_base_name;
29 static ActionMap shared_actions;
33 Loader(RenderPass &, Collection &);
35 virtual void init_actions();
38 void set_inline_base_name(const std::string &);
41 virtual void finish();
43 static std::string get_shader_name(const std::string &);
45 void material_inline();
46 void material(const std::string &);
47 void shader(const std::string &);
48 void texture(const std::string &);
49 void texunit(unsigned);
50 void texunit_named(unsigned, const std::string &);
52 void uniform_slot(const std::string &);
53 void uniform_slot2(const std::string &, const std::string &);
59 class Loader: public DataFile::CollectionObjectLoader<TextureSlot>
62 std::string auto_slot_name;
65 Loader(TextureSlot &, const std::string &, Collection *);
72 std::string slot_name;
73 const Texture *texture;
74 const Sampler *sampler;
76 TextureSlot(Tag t): tag(t), texture(0), sampler(0) { }
79 const Program *shprog;
80 bool shprog_from_material;
81 RefPtr<ProgramData> shdata;
82 std::map<Tag, Tag> uniform_slots;
83 const Material *material;
84 std::string material_slot;
85 std::vector<TextureSlot> textures;
88 bool image_based_lighting;
94 void maybe_create_material_shader();
95 void set_material_textures();
98 void set_shader_program(const Program *, const ProgramData *);
99 const Program *get_shader_program() const { return shprog; }
100 const ProgramData *get_shader_data() const { return shdata.get(); }
101 Tag get_slotted_uniform_tag(Tag) const;
102 void set_material(const Material *);
103 const Material *get_material() const { return material; }
104 const std::string &get_material_slot_name() const { return material_slot; }
105 void set_texture(Tag, const Texture *, const Sampler * = 0);
106 Tag get_texture_tag(const std::string &) const;
107 DEPRECATED void set_texture(unsigned, const Texture *, const Sampler * = 0);
108 DEPRECATED int get_texture_index(const std::string &) const;
109 void set_back_faces(bool);
110 bool get_back_faces() const { return back_faces; }
111 void set_receive_shadows(bool);
112 bool get_receive_shadows() const { return receive_shadows; }
113 void set_image_based_lighting(bool);
114 bool get_image_based_lighting() const { return image_based_lighting; }
116 void apply(Renderer &) const;
118 void set_debug_name(const std::string &);