Skip to main content

Material.ixx File

Material abstraction: shader + material properties. More...

Included Headers

Namespaces Index

namespacehelios
namespacerendering

Graphics rendering infrastructure. More...

namespacematerial

Classes Index

classMaterial

Represents a parameterizable material. More...

Macro Definitions Index

#defineHELIOS_LOG_SCOPE   "helios::rendering::material::Material"

Description

Material abstraction: shader + material properties.

Macro Definitions

HELIOS_LOG_SCOPE

#define HELIOS_LOG_SCOPE   "helios::rendering::material::Material"

Definition at line 17 of file Material.ixx.

17#define HELIOS_LOG_SCOPE "helios::rendering::material::Material"

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file Material.ixx
3 * @brief Material abstraction: shader + material properties.
4 */
5module;
6
7#include <memory>
8#include <stdexcept>
9
10export module helios.rendering.material.Material;
11
12import helios.rendering.shader.UniformValueMap;
13import helios.rendering.material.MaterialShaderProperties;
14import helios.util.log;
15import helios.rendering.shader.Shader;
16
17#define HELIOS_LOG_SCOPE "helios::rendering::material::Material"
19
20 /**
21 * @brief Represents a parameterizable material.
22 *
23 * A Material contains a reference to a shared, immutable `Shader` and
24 * material properties used to configure the shader at draw time.
25 */
26 class Material final {
27
28
29 protected:
30 Material() = default;
31
32 /**
33 * @brief Shared pointer for the raw, immutable MaterialShaderProperties.
34 */
35 std::shared_ptr<const helios::rendering::material::MaterialShaderProperties> materialProperties_;
36
37 /**
38 * @brief Shared pointer to the immutable Shader.
39 */
40 std::shared_ptr<const helios::rendering::shader::Shader> shader_{};
41
42 /**
43 * @brief Shared logger instance for all Material objects.
44 */
46
47 public:
48 virtual ~Material() = default;
49
50 /**
51 * @brief Creates a new Material.
52 *
53 * @param shader A shared pointer to the immutable Shader used by this instance.
54 * @param materialProperties A shared pointer to the MaterialShaderProperties for this Material.
55 *
56 * @throws std::invalid_argument if shader or materialProperties is a null shared pointer.
57 */
58 explicit Material(
59 std::shared_ptr<const helios::rendering::shader::Shader> shader,
60 std::shared_ptr<const helios::rendering::material::MaterialShaderProperties> materialProperties
61 ) :
62 shader_(std::move(shader)),
64 {
66 const std::string msg = !shader_ ?
67 "Material constructor received a shader nullptr." :
68 "Material constructor received a materialProperties nullptr.";
69 logger_.error(msg);
70 throw std::invalid_argument(msg);
71 }
72 }
73
74 /**
75 * @brief Returns a const reference to the underlying MaterialShaderProperties.
76 *
77 * @return The const reference to this Material's MaterialShaderProperties.
78 */
81 }
82
83
84 /**
85 * @brief Returns a const ref to the shader used by this instance.
86 *
87 * @return A const ref to the Shader used by this Material.
88 */
89 [[nodiscard]] const helios::rendering::shader::Shader& shader() const noexcept {
90 return *shader_;
91 }
92
93
94 /**
95 * @brief Writes this Material's uniform values into the given map.
96 *
97 * Delegates to MaterialShaderProperties::writeUniformValues().
98 *
99 * @param uniformValueMap Target map receiving the uniform values.
100 */
101 void writeUniformValues(helios::rendering::shader::UniformValueMap& uniformValueMap) const noexcept {
102 materialProperties_->writeUniformValues(uniformValueMap);
103 }
104 };
105
106} // namespace helios::rendering::model

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.