44 using Id =
unsigned int;
64 static std::optional<Shader>
65 create(
const tenno::vector<Shader::Object> &objects);
85 static std::optional<Shader>
86 create(
const GLchar **feedback_varyings,
int num_varyings,
87 const tenno::vector<Shader::Object> &objects);
90 static bool set_bool(Shader::Id
id,
const std::string &unif_name,
92 static bool set_int(Shader::Id
id,
const std::string &unif_name,
94 static bool set_float(Shader::Id
id,
const std::string &unif_name,
96 static bool set_float2(Shader::Id
id,
const std::string &unif_name,
98 static bool set_float3(Shader::Id
id,
const std::string &unif_name,
99 float v1,
float v2,
float v3);
100 static bool set_mat4(Shader::Id
id,
const std::string &unif_name,
102 static bool set_vec3(Shader::Id
id,
const std::string &unif_name,
103 float x,
float y,
float z);
104 static bool set_vec3(Shader::Id
id,
const std::string &unif_name,
111 Shader(Shader::Id
id) : id(
id) {}
113 { this->
id = other.id; other.id = 0; }
116 Shader::Id get_id()
const;
123 bool set_bool(
const std::string &unif_name,
bool value);
124 bool set_int(
const std::string &unif_name,
int value);
125 bool set_float(
const std::string &unif_name,
float value);
126 bool set_float2(
const std::string &unif_name,
float v1,
float v2);
127 bool set_float3(
const std::string &unif_name,
float v1,
float v2,
float v3);
128 bool set_mat4(
const std::string &unif_name, glm::mat4 value);
129 bool set_vec3(
const std::string &unif_name,
float x,
float y,
float z);
130 bool set_vec3(
const std::string &unif_name, glm::vec3 value);
137 compile_shaders([[maybe_unused]] tenno::vector<Shader::Id> &compiled);
138 static bool compile_shaders(tenno::vector<Shader::Id> &compiled,
139 const tenno::vector<Shader::Object> &objects);
140 static std::optional<Shader::Id>
141 link_program(tenno::vector<Shader::Id>& compiled_shaders,
142 const GLchar **feedback_varyings,
int num_varyings);
143 static void clean_compilation(tenno::vector<Shader::Id>& compiled_shader);
144 static bool check_compile_errors(Shader::Id shader);
145 static bool check_link_errors(Shader::Id shader);
155 std::optional<std::filesystem::path> path;
158 Object(Type type,
const char* src)
159 : type(type), src(std::string(src)), path({}) {}
160 Object(Type type,
const std::string &src)
161 : type(type), src(src) {}
162 Object(Type type,
const std::filesystem::path &path);
166 static std::optional<std::string> read_file(
const std::filesystem::path &path);
175 Builder& objects(
const tenno::vector<Shader::Object> &objs);
176 Builder& feedback(
const GLchar **feedback_varyings,
int num_varyings);
179 Builder &watch(
const std::filesystem::path &path);
181 std::optional<Shader> build();
182 tenno::vector<std::filesystem::path> get_watch_paths()
const;
186 int num_varyings = 0;
187 const GLchar **feedback_varyings;
188 tenno::vector<Object> objs;
190 tenno::vector<std::filesystem::path> watch_paths = {};