Antkeeper
0.0.1
|
A material is associated with exactly one shader program and contains a set of material properties which can be uploaded to that shader program via shader inputs. More...
#include <material.hpp>
Public Member Functions | |
material ()=default | |
Constructs a material. More... | |
material (const material &other) | |
Constructs a copy of another material. More... | |
~material ()=default | |
Destroys a material. More... | |
material & | operator= (const material &other) |
Makes this material a copy of aother material. More... | |
std::size_t | hash () const noexcept |
Returns a hash of the material state. More... | |
Settings | |
void | set_two_sided (bool two_sided) noexcept |
Enables or disables back-face culling of the material surface. More... | |
void | set_blend_mode (material_blend_mode mode) noexcept |
Sets the material blend mode. More... | |
void | set_shadow_mode (material_shadow_mode mode) noexcept |
Sets the material shadow mode. More... | |
void | set_flags (std::uint32_t flags) noexcept |
Sets the material flags. More... | |
bool | is_two_sided () const noexcept |
Returns true if the material surface is two-sided, and false otherwise. More... | |
material_blend_mode | get_blend_mode () const noexcept |
Returns the material blend mode. More... | |
material_shadow_mode | get_shadow_mode () const noexcept |
Returns the material shadow mode. More... | |
std::uint32_t | get_flags () const noexcept |
Returns the material flags. More... | |
Shading | |
void | set_shader_template (std::shared_ptr< gl::shader_template > shader_template) |
Sets the material's shader template. More... | |
const std::shared_ptr< gl::shader_template > & | get_shader_template () const noexcept |
Returns the shader template with which this material is associated. More... | |
void | set_variable (hash::fnv1a32_t key, std::shared_ptr< material_variable_base > value) |
Sets the value of a material variable with the given name. More... | |
std::shared_ptr< material_variable_base > | get_variable (hash::fnv1a32_t key) const |
Returns a shared pointer to the material variable with the given name, or nullptr if not found. More... | |
const std::unordered_map< hash::fnv1a32_t, std::shared_ptr< material_variable_base > > & | get_variables () const noexcept |
Returns all material variables. More... | |
A material is associated with exactly one shader program and contains a set of material properties which can be uploaded to that shader program via shader inputs.
Definition at line 36 of file material.hpp.
|
default |
Constructs a material.
render::material::material | ( | const material & | other | ) |
Constructs a copy of another material.
other | Material to copy. |
Definition at line 33 of file material.cpp.
|
default |
Destroys a material.
|
inlinenoexcept |
Returns the material blend mode.
Definition at line 102 of file material.hpp.
|
inlinenoexcept |
Returns the material flags.
Definition at line 114 of file material.hpp.
|
inlinenoexcept |
Returns the shader template with which this material is associated.
Definition at line 134 of file material.hpp.
|
inlinenoexcept |
Returns the material shadow mode.
Definition at line 108 of file material.hpp.
std::shared_ptr< material_variable_base > render::material::get_variable | ( | hash::fnv1a32_t | key | ) | const |
Returns a shared pointer to the material variable with the given name, or nullptr
if not found.
key | 32-bit FNV-1a hash value of the variable name. |
nullptr
if not found. Definition at line 100 of file material.cpp.
|
inlinenoexcept |
Returns all material variables.
Definition at line 161 of file material.hpp.
|
inlinenoexcept |
Returns a hash of the material state.
The followings functions may change the material hash:
Definition at line 179 of file material.hpp.
|
inlinenoexcept |
Returns true
if the material surface is two-sided, and false
otherwise.
Definition at line 96 of file material.hpp.
Makes this material a copy of aother material.
other | Material to copy. |
Definition at line 38 of file material.cpp.
|
noexcept |
Sets the material blend mode.
mode | Blend mode. |
Definition at line 67 of file material.cpp.
|
noexcept |
Sets the material flags.
flags | Material flags. |
Definition at line 81 of file material.cpp.
void render::material::set_shader_template | ( | std::shared_ptr< gl::shader_template > | shader_template | ) |
Sets the material's shader template.
shader_template | Shader template with which to associate the material. |
Definition at line 88 of file material.cpp.
|
noexcept |
Sets the material shadow mode.
mode | Shadow mode. |
Definition at line 74 of file material.cpp.
|
noexcept |
Enables or disables back-face culling of the material surface.
two_sided | true to disable back-face culling, or false to enable it. |
Definition at line 60 of file material.cpp.
void render::material::set_variable | ( | hash::fnv1a32_t | key, |
std::shared_ptr< material_variable_base > | value | ||
) |
Sets the value of a material variable with the given name.
key | 32-bit FNV-1a hash value of the variable name. |
value | Shared pointer to the material variable value. |
Definition at line 95 of file material.cpp.