3#include <cgv/render/context.h>
40 std::string get_type_name()
const;
60 template<typename T, typename std::enable_if<!std::is_enum<T>::value,
bool>::type =
true>
61 static void set_define(
shader_define_map& defines,
const std::string& name,
const T& value,
const T& default_value) {
62 if(value != default_value)
63 defines[name] = std::to_string(value);
68 template<typename T, typename std::enable_if<std::is_enum<T>::value,
bool>::type =
true>
69 static void set_define(
shader_define_map& defines,
const std::string& name,
const T& value,
const T& default_value) {
70 if(value != default_value)
71 defines[name] = std::to_string((
unsigned)value);
76 static void set_define(
shader_define_map& defines,
const std::string& name,
const std::string& value,
const std::string& default_value) {
77 if(value != default_value)
78 defines[name] = value;
83 static void set_define(
shader_define_map& defines,
const std::string& name,
bool value,
bool default_value) {
84 if(value != default_value)
85 defines[name] = value ?
"1" :
"0";
107 static void decode_if_base64(std::string& content);
122 static std::string find_file(
const std::string& file_name,
bool search_exhaustive =
false);
124 static std::string get_last_error(
const std::string& file_name,
const std::string& last_error);
126 static std::string read_code_file(
const std::string &file_name, std::string* _last_error = 0);
128 static std::string retrieve_code(
const std::string& file_name,
bool use_cache, std::string* _last_error);
136 static ShaderType detect_shader_type(
const std::string& file_name);
138 static std::string resolve_includes(
const std::string& source,
bool use_cache, std::set<std::string>& included_file_names, std::string* _last_error = 0);
140 inline static std::string
resolve_includes(
const std::string& source,
bool use_cache, std::string* _last_error = 0) {
141 std::set<std::string> dummy;
142 return resolve_includes(source, use_cache, dummy, _last_error);
145 void destruct(
const context& ctx);
155 void set_vertex_attrib_locations(std::string& source);
159 bool compile(
const context& ctx);
165 bool is_compiled()
const;
172#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
static std::string resolve_includes(const std::string &source, bool use_cache, std::string *_last_error=0)
search for include directives in the given source code, replace them by the included file contents an...
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 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