cgv
Loading...
Searching...
No Matches
shader_library.h
1#pragma once
2
3#include "context.h"
4#include "shader_program.h"
5
6#include "lib_begin.h"
7
8namespace cgv {
9namespace render {
10
12class CGV_API shader_library {
13 struct shader_info {
14 std::string filename;
15 shader_program prog;
17 };
18
19 using shader_lib_map = std::map<std::string, shader_info>;
20
21public:
22 void clear(context& ctx);
23
24 bool add(const std::string& name, const std::string& file, const shader_compile_options& options = {});
25
26 bool contains(const std::string& name) const;
27
28 shader_program& get(const std::string& name);
29
30 shader_define_map& get_defines(const std::string& name);
31
32 shader_compile_options& get_compile_options(const std::string& name);
33
34 shader_lib_map::iterator begin() { return shaders.begin(); }
35 shader_lib_map::iterator end() { return shaders.end(); }
36
37 static bool load(context& ctx, shader_program& prog, const std::string& name, const shader_compile_options& options, const std::string& where = "");
38
39 static bool load(context& ctx, shader_program& prog, const std::string& name, const std::string& where = "");
40
41 bool load_all(context& ctx, const std::string& where = "");
42
43 bool reload(context& ctx, const std::string& name, const shader_compile_options& defines = {}, const std::string& where = "");
44
45private:
46 shader_info& get_shader_info(const std::string& name);
47
48 shader_lib_map shaders;
49};
50
51} // namespace render
52} // namespace cgv
53
54#include <cgv/config/lib_end.h>
base class for all drawables, which is independent of the used rendering API.
Definition context.h:626
provides a shader library that handles shader loading and stores shaders
a shader program combines several shader code fragments to a complete definition of the shading pipel...
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
Definition shader_code.h:52
the cgv namespace
Definition print.h:11
holds options applied before and during shader compilation, such as preprocessor defines and code sni...
Definition shader_code.h:87