3#include <cgv/render/context.h>
40 std::string get_type_name()
const;
106 template<typename T, typename std::enable_if<!std::is_enum<T>::value,
bool>::type =
true>
107 static void set_define(
shader_define_map& defines,
const std::string& name,
const T& value,
const T& default_value) {
108 if(value != default_value)
109 defines[name] = std::to_string(value);
114 template<typename T, typename std::enable_if<std::is_enum<T>::value,
bool>::type =
true>
115 static void set_define(
shader_define_map& defines,
const std::string& name,
const T& value,
const T& default_value) {
116 if(value != default_value)
117 defines[name] = std::to_string((
unsigned)value);
122 static void set_define(
shader_define_map& defines,
const std::string& name,
const std::string& value,
const std::string& default_value) {
123 if(value != default_value)
124 defines[name] = value;
129 static void set_define(
shader_define_map& defines,
const std::string& name,
bool value,
bool default_value) {
130 if(value != default_value)
131 defines[name] = value ?
"1" :
"0";
153 static void decode_if_base64(std::string& content);
168 static std::string find_file(
const std::string& file_name,
bool search_exhaustive =
false);
170 static std::string get_last_error(
const std::string& file_name,
const std::string& last_error);
172 static std::string read_code_file(
const std::string &file_name, std::string* _last_error = 0);
174 static std::string retrieve_code(
const std::string& file_name,
bool use_cache, std::string* _last_error);
182 static ShaderType detect_shader_type(
const std::string& file_name);
184 void destruct(
const context& ctx);
194 bool compile(
const context& ctx);
200 bool is_compiled()
const;
204 static std::string resolve_includes(
const std::string& source,
bool use_cache, std::set<std::string>& included_file_names, std::string* _last_error = 0);
206 static std::string resolve_includes(
const std::string& source,
bool use_cache, std::string* _last_error = 0);
208 static void resolve_version(std::string& source);
210 static void set_defines_and_snippets(std::string& source,
const shader_compile_options& options);
212 static void set_vertex_attrib_locations(std::string& source);
219#include <cgv/config/lib_end.h>
base class for all classes that can be registered with support for dynamic properties (see also secti...
reference counted pointer, which can work together with types that are derived from ref_counted,...
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
base class for all drawables, which is independent of the used rendering API.
base interface for all render components
a shader code object holds a code fragment of a geometry vertex or fragment shader and can be added t...
static bool shader_file_name_map_initialized
whether the shader file name map is initialized
static std::map< std::string, std::string > code_cache
map that caches shader file contents indexed by their file name
ShaderType st
store the shader type
static std::map< std::string, std::string > shader_file_name_map
map that caches full shader file paths indexed by the shader file name
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
shader_config_ptr get_shader_config()
return a reference to the current shader configuration
cgv::data::ref_ptr< shader_config > shader_config_ptr
type of ref counted pointer to shader configuration
ShaderType
different shader types
a snippet of shader code in raw text form.
std::string content
the snippet content; can be any valid piece of shader code
std::string id
the snippet id used for matching snippet markers in shader code
holds options applied before and during shader compilation, such as preprocessor defines and code sni...
std::vector< shader_code_snippet > snippets
shader code snippets
shader_define_map defines
map of pre-processor define names to values
a globally unique shader config is registered by default when the cgv library is used.
std::vector< std::string > shader_file_names
mapping of shader index to file name
bool show_file_paths
whether to output full paths of read shaders
bool trace_file_names
whether to keep track of file names
std::string shader_path
the path used to find shaders with the cgv::utils::file::find_in_paths function
std::vector< std::string > inserted_shader_file_names
mapping of shader index to inserted files name