|
cgv
|
Stores preprocessor options used for conditionally compiling shader programs. More...
#include <shader_code.h>
Public Types | |
| using | string_map = std::map< std::string, std::string > |
Public Member Functions | |
| bool | empty () const |
| Return true if no options are set. | |
| void | clear () |
| Clear everything, i.e. remove all defines and snippets. | |
| const string_map & | get_macros () const |
| Return const reference to defined macros. | |
| const string_map & | get_snippets () const |
| Return const reference to defined snippets. | |
| void | define_macro (const std::string &identifier) |
| Define a macro as identifier and no replacement text. | |
| template<typename T , typename std::enable_if< std::is_arithmetic_v< T >, bool >::type = true> | |
| void | define_macro (const std::string &identifier, const T &value) |
| Define identifier as a macro with value as replacement text. | |
| template<typename T , typename std::enable_if< std::is_enum_v< T >, bool >::type = true> | |
| void | define_macro (const std::string &identifier, const T &value) |
| void | define_macro (const std::string &identifier, bool value) |
| void | define_macro (const std::string &identifier, const std::string &value) |
| template<typename T , typename std::enable_if< std::is_arithmetic_v< T >, bool >::type = true> | |
| void | define_macro_if_not_default (const std::string &identifier, const T &value, const T &default_value) |
| Conditionally define identifier as a macro with value as replacement text. | |
| template<typename T , typename std::enable_if< std::is_enum_v< T >, bool >::type = true> | |
| void | define_macro_if_not_default (const std::string &identifier, const T &value, const T &default_value) |
| void | define_macro_if_not_default (const std::string &identifier, bool value, bool default_value) |
| void | define_macro_if_not_default (const std::string &identifier, const std::string &value, const std::string &default_value) |
| void | define_macro_if_true (bool predicate, const std::string &identifier) |
| Conditionally define identifier as a macro with replacement text 1. | |
| void | undefine_macro (const std::string &identifier) |
| Remove (undefine) the macro with the given identifier. | |
| void | define_snippet (const std::string &identifier, const std::string &replacement_text) |
| Define a text replacement snippet. | |
| void | undefine_snippet (const std::string &identifier) |
| Remove (undefine) the snippet with the given identifier. | |
| void | extend (const shader_compile_options &other, bool overwrite) |
| Extend options by content of other shader_compile_options via merging. | |
| bool | operator== (const shader_compile_options &other) const |
| Compare two shader_compile_options for equality. | |
| bool | operator!= (const shader_compile_options &other) const |
| Compare two shader_compile_options for inequality. | |
Stores preprocessor options used for conditionally compiling shader programs.
Options include standard preprocessor defines and text replacement snippets.
Preprocessor macros will be handled as follows:
Snippets will be handled as follows:
Definition at line 73 of file shader_code.h.
| using cgv::render::shader_compile_options::string_map = std::map<std::string, std::string> |
Definition at line 75 of file shader_code.h.
|
inline |
Clear everything, i.e. remove all defines and snippets.
Definition at line 83 of file shader_code.h.
Referenced by cgv::render::renderer::disable().
|
inline |
Define a macro as identifier and no replacement text.
Definition at line 99 of file shader_code.h.
Referenced by define_macro_if_true(), cgv::render::shader_program::extract_instances(), cgv::plot::plot2d::init(), cgv::render::group_renderer::update_shader_program_options(), and cgv::render::surface_renderer::update_shader_program_options().
|
inline |
Definition at line 124 of file shader_code.h.
|
inline |
Definition at line 128 of file shader_code.h.
|
inline |
Define identifier as a macro with value as replacement text.
If value is of arithmetic type, it is converted to a string. If value is of boolean type, it is converted to 1 if true and 0 if false. If value is of enum type, it is first converted into its underlying arithmetic type.
An existing macro with the same identifier is overwritten with the new value.
| T | The value type. |
| identifier | The macro name. |
| value | The macro replacement value. |
Definition at line 115 of file shader_code.h.
|
inline |
Definition at line 120 of file shader_code.h.
|
inline |
Definition at line 163 of file shader_code.h.
|
inline |
Definition at line 170 of file shader_code.h.
|
inline |
Conditionally define identifier as a macro with value as replacement text.
The macro is only defined if value is not equal to default_value (tested using operator !=). If value is equal to default_value and the macro is already defined it will be removed (undefined).
If value is of arithmetic type, it is converted to a string. If value is of boolean type, it is converted to 1 if true and 0 if false. If value is of enum type, it is first converted into its underlying arithmetic type.
An existing macro with the same identifier is overwritten with the new value.
| T | the value type. |
| identifier | The macro name. |
| value | The macro replacement value. |
| default | The default value used for comparison. |
Definition at line 148 of file shader_code.h.
Referenced by cgv::render::volume_renderer::update_shader_program_options().
|
inline |
Definition at line 156 of file shader_code.h.
|
inline |
Conditionally define identifier as a macro with replacement text 1.
Will only define the macro if predicate is true. If predicate is false and the macro is already defined it will be removed (undefined).
| predicate | The condition. |
| identifier | The macro name. |
Definition at line 184 of file shader_code.h.
References define_macro(), and undefine_macro().
Referenced by cgv::render::box_renderer::update_shader_program_options(), cgv::render::cone_renderer::update_shader_program_options(), cgv::render::group_renderer::update_shader_program_options(), and cgv::render::volume_renderer::update_shader_program_options().
|
inline |
Define a text replacement snippet.
| identifier | The snippet name. |
| replacement_text | The snippet content. |
Definition at line 200 of file shader_code.h.
|
inline |
Return true if no options are set.
Definition at line 78 of file shader_code.h.
|
inline |
Extend options by content of other shader_compile_options via merging.
If overwrite is true, existing defines and snippets are overwritten with the content from other.
| other | The other options. |
| overwrite | If true, existing options are overwritten with other. |
Definition at line 216 of file shader_code.h.
|
inline |
Return const reference to defined macros.
Definition at line 89 of file shader_code.h.
|
inline |
Return const reference to defined snippets.
Definition at line 94 of file shader_code.h.
|
inline |
Compare two shader_compile_options for inequality.
Definition at line 235 of file shader_code.h.
|
inline |
Compare two shader_compile_options for equality.
Definition at line 230 of file shader_code.h.
|
inline |
Remove (undefine) the macro with the given identifier.
| identifier | The macro name. |
Definition at line 193 of file shader_code.h.
Referenced by define_macro_if_true().
|
inline |
Remove (undefine) the snippet with the given identifier.
| identifier | The snippet name. |
Definition at line 206 of file shader_code.h.