@@ -30,14 +30,44 @@ class Material
3030{
3131public:
3232
33- class Builder ;
33+ class Builder
34+ {
35+ public:
36+
37+ Builder& shader (tenno::shared_ptr<Shader> shader);
38+ Builder& integer (const std::string &name, int val);
39+ Builder& floating (const std::string &name, float val);
40+ Builder& vector (const std::string &name, glm::vec3 val);
41+ Builder& texture (const std::string &name,
42+ tenno::shared_ptr<Texture> val, int index);
43+
44+ // Add path to be watched for hot-reloading
45+ Builder &watch (const std::filesystem::path &path);
46+
47+ Material build ();
48+ tenno::vector<std::filesystem::path> get_watch_paths () const ;
49+
50+ private:
51+
52+ tenno::shared_ptr<Shader> _shader;
53+ tenno::vector<std::pair<std::string, int >> ints;
54+ tenno::vector<std::pair<std::string, float >> floats;
55+ tenno::vector<std::pair<std::string, glm::vec3>> vectors;
56+ tenno::vector<std::pair<std::string,
57+ std::pair<int , tenno::shared_ptr<Texture>>>> textures;
58+
59+ };
3460
3561 tenno::shared_ptr<Shader> shader;
3662
3763 Material () = default ;
3864 Material (tenno::shared_ptr<Shader> s) : shader(s) {}
3965 Material (Shader&& s);
4066 Material (Material&& other) = default ;
67+ Material (Material::Builder& builder)
68+ {
69+ *this = builder.build ();
70+ }
4171 Material &operator =(Material&& other) = default ;
4272
4373 void apply ();
@@ -58,32 +88,4 @@ class Material
5888
5989};
6090
61- class Material ::Builder
62- {
63- public:
64-
65- Builder& shader (tenno::shared_ptr<Shader> shader);
66- Builder& integer (const std::string &name, int val);
67- Builder& floating (const std::string &name, float val);
68- Builder& vector (const std::string &name, glm::vec3 val);
69- Builder& texture (const std::string &name,
70- tenno::shared_ptr<Texture> val, int index);
71-
72- // Add path to be watched for hot-reloading
73- Builder &watch (const std::filesystem::path &path);
74-
75- Material build ();
76- tenno::vector<std::filesystem::path> get_watch_paths () const ;
77-
78- private:
79-
80- tenno::shared_ptr<Shader> _shader;
81- tenno::vector<std::pair<std::string, int >> ints;
82- tenno::vector<std::pair<std::string, float >> floats;
83- tenno::vector<std::pair<std::string, glm::vec3>> vectors;
84- tenno::vector<std::pair<std::string,
85- std::pair<int , tenno::shared_ptr<Texture>>>> textures;
86-
87- };
88-
8991} // namespace brenta
0 commit comments