Antkeeper  0.0.1
Public Member Functions | List of all members
render::material Class Reference

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...
 
materialoperator= (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_baseget_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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ material() [1/2]

render::material::material ( )
default

Constructs a material.

◆ material() [2/2]

render::material::material ( const material other)

Constructs a copy of another material.

Parameters
otherMaterial to copy.

Definition at line 33 of file material.cpp.

◆ ~material()

render::material::~material ( )
default

Destroys a material.

Member Function Documentation

◆ get_blend_mode()

material_blend_mode render::material::get_blend_mode ( ) const
inlinenoexcept

Returns the material blend mode.

Definition at line 102 of file material.hpp.

◆ get_flags()

std::uint32_t render::material::get_flags ( ) const
inlinenoexcept

Returns the material flags.

Definition at line 114 of file material.hpp.

◆ get_shader_template()

const std::shared_ptr<gl::shader_template>& render::material::get_shader_template ( ) const
inlinenoexcept

Returns the shader template with which this material is associated.

Definition at line 134 of file material.hpp.

◆ get_shadow_mode()

material_shadow_mode render::material::get_shadow_mode ( ) const
inlinenoexcept

Returns the material shadow mode.

Definition at line 108 of file material.hpp.

◆ get_variable()

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.

Parameters
key32-bit FNV-1a hash value of the variable name.
Returns
Shared pointer to the material variable with the given name, or nullptr if not found.

Definition at line 100 of file material.cpp.

◆ get_variables()

const std::unordered_map<hash::fnv1a32_t, std::shared_ptr<material_variable_base> >& render::material::get_variables ( ) const
inlinenoexcept

Returns all material variables.

Returns
Map of 32-bit FNV-1a hash values of variable names to variables.

Definition at line 161 of file material.hpp.

◆ hash()

std::size_t render::material::hash ( ) const
inlinenoexcept

Returns a hash of the material state.

The followings functions may change the material hash:

Definition at line 179 of file material.hpp.

◆ is_two_sided()

bool render::material::is_two_sided ( ) const
inlinenoexcept

Returns true if the material surface is two-sided, and false otherwise.

Definition at line 96 of file material.hpp.

◆ operator=()

material & render::material::operator= ( const material other)

Makes this material a copy of aother material.

Parameters
otherMaterial to copy.
Returns
Reference to this material.

Definition at line 38 of file material.cpp.

◆ set_blend_mode()

void render::material::set_blend_mode ( material_blend_mode  mode)
noexcept

Sets the material blend mode.

Parameters
modeBlend mode.

Definition at line 67 of file material.cpp.

◆ set_flags()

void render::material::set_flags ( std::uint32_t  flags)
noexcept

Sets the material flags.

Parameters
flagsMaterial flags.

Definition at line 81 of file material.cpp.

◆ set_shader_template()

void render::material::set_shader_template ( std::shared_ptr< gl::shader_template shader_template)

Sets the material's shader template.

Parameters
shader_templateShader template with which to associate the material.

Definition at line 88 of file material.cpp.

◆ set_shadow_mode()

void render::material::set_shadow_mode ( material_shadow_mode  mode)
noexcept

Sets the material shadow mode.

Parameters
modeShadow mode.

Definition at line 74 of file material.cpp.

◆ set_two_sided()

void render::material::set_two_sided ( bool  two_sided)
noexcept

Enables or disables back-face culling of the material surface.

Parameters
two_sidedtrue to disable back-face culling, or false to enable it.

Definition at line 60 of file material.cpp.

◆ set_variable()

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.

Parameters
key32-bit FNV-1a hash value of the variable name.
valueShared pointer to the material variable value.

Definition at line 95 of file material.cpp.


The documentation for this class was generated from the following files: