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. | |
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 |
Define a macro as identifier and no replacement text.
Definition at line 93 of file shader_code.h.
Referenced by define_macro_if_true(), cgv::render::shader_program::extract_instances(), and cgv::plot::plot2d::init().
|
inline |
Definition at line 118 of file shader_code.h.
|
inline |
Definition at line 122 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 109 of file shader_code.h.
|
inline |
Definition at line 114 of file shader_code.h.
|
inline |
Definition at line 157 of file shader_code.h.
|
inline |
Definition at line 164 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 142 of file shader_code.h.
Referenced by cgv::render::volume_renderer::update_shader_program_options().
|
inline |
Definition at line 150 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 178 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(), 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 194 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 210 of file shader_code.h.
|
inline |
Return const reference to defined macros.
Definition at line 83 of file shader_code.h.
|
inline |
Return const reference to defined snippets.
Definition at line 88 of file shader_code.h.
|
inline |
Compare two shader_compile_options for inequality.
Definition at line 229 of file shader_code.h.
|
inline |
Compare two shader_compile_options for equality.
Definition at line 224 of file shader_code.h.
|
inline |
Remove (undefine) the macro with the given identifier.
identifier | The macro name. |
Definition at line 187 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 200 of file shader_code.h.