|
utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
|
The Material class represents a material that can be used for rendering objects in a graphics application. More...
#include <headers/utility/graphic/material.hpp>

Public Member Functions | |
| Material ()=default | |
| Constructs an empty Material. | |
| Material (RessourceProvider &ressourceProvider, const std::string &shaderName, const std::vector< File > &textureAssets) | |
| Constructs a Material object with the specified shader name and texture assets. | |
| virtual | ~Material ()=default |
| Destructs the Material object, releasing any allocated resources. | |
| std::shared_ptr< Texture > | getTexture (const std::string &name) const |
| Retrieves a texture by its name. | |
| std::vector< std::shared_ptr< Texture > > | getTextures () const |
| Retrieves the textures associated with this material. | |
| const std::string & | getShaderName () const |
| Retrieves the shader name associated with this material. | |
| AlphaMode | getAlphaMode (void) const |
| Retrieves the alpha semantics of this material. | |
| float | getAlphaCutoff (void) const |
| Retrieves the alpha cutoff of this material. | |
| uint32_t | getVersion () const |
| Retrieves the version number of the material. | |
Protected Attributes | |
| std::string | _shaderName |
| The name of the shader associated with this material. | |
| std::map< std::string, std::shared_ptr< Texture > > | _textures |
| A map of texture names to Texture objects associated with this material. | |
| uint32_t | _version = 0 |
| A version number for the material, used for tracking changes and updates. | |
| AlphaMode | _alphaMode = AlphaMode::Opaque |
| The alpha semantics of this material. | |
| float | _alphaCutoff = 0.5f |
| The alpha cutoff, only meaningful for AlphaMode::Mask. | |
The Material class represents a material that can be used for rendering objects in a graphics application.
The Material class manages a shader and its associated textures, allowing for efficient rendering of objects with the specified visual properties. It provides functionality to load textures from file assets and retrieve them for use in rendering operations.
The constructor of the Material class takes a shader name and a vector of File objects representing the textures to be loaded. The textures are loaded using the stb_image library, and the pixel data is stored in Texture objects for later use.
Definition at line 57 of file material.hpp.
|
default |
| utility::graphic::Material::Material | ( | RessourceProvider & | ressourceProvider, |
| const std::string & | shaderName, | ||
| const std::vector< File > & | textureAssets | ||
| ) |
Constructs a Material object with the specified shader name and texture assets.
This constructor initializes the Material with a shader name and loads the textures from the provided File objects. The textures are loaded using the stb_image library, and the pixel data is stored in Texture objects for later use in rendering operations.
| ressourceProvider | A reference to the RessourceProvider instance. |
| shaderName | The name of the shader associated with this material. |
| textureAssets | A vector of File objects representing the textures to be loaded for this material. |
| std::runtime_error | if any of the textures fail to load from the provided File objects. |
Definition at line 14 of file material.cpp.

| float utility::graphic::Material::getAlphaCutoff | ( | void | ) | const |
Retrieves the alpha cutoff of this material.
The cutoff is only meaningful for AlphaMode::Mask, where a sampled alpha below the cutoff is fully transparent.
Definition at line 62 of file material.cpp.
| AlphaMode utility::graphic::Material::getAlphaMode | ( | void | ) | const |
Retrieves the alpha semantics of this material.
Consumers use this to select the appropriate rendering behaviour without inferring it from texture types or shader names.
Definition at line 57 of file material.cpp.
| const std::string & utility::graphic::Material::getShaderName | ( | ) | const |
Retrieves the shader name associated with this material.
This method returns the name of the shader that is associated with this material. The shader name is used to identify which shader program should be used when rendering objects that use this material, allowing for proper rendering of the material's visual properties.
Definition at line 52 of file material.cpp.
| std::shared_ptr< Texture > utility::graphic::Material::getTexture | ( | const std::string & | name | ) | const |
Retrieves a texture by its name.
This method returns a shared pointer to the Texture object associated with the specified name. If the texture does not exist in the material, it returns a nullptr.
| name | The name of the texture to retrieve. |
Definition at line 33 of file material.cpp.
| std::vector< std::shared_ptr< Texture > > utility::graphic::Material::getTextures | ( | ) | const |
Retrieves the textures associated with this material.
This method returns a vector of shared pointers to the Texture objects associated with this material.
Definition at line 42 of file material.cpp.
| uint32_t utility::graphic::Material::getVersion | ( | ) | const |
Retrieves the version number of the material.
This method returns the version number of the material, which is used for tracking changes and updates to the material's properties and resources.
Definition at line 67 of file material.cpp.
|
protected |
The alpha cutoff, only meaningful for AlphaMode::Mask.
Definition at line 192 of file material.hpp.
|
protected |
The alpha semantics of this material.
Definition at line 187 of file material.hpp.
|
protected |
The name of the shader associated with this material.
Definition at line 170 of file material.hpp.
|
protected |
A map of texture names to Texture objects associated with this material.
Definition at line 176 of file material.hpp.
|
protected |
A version number for the material, used for tracking changes and updates.
Definition at line 182 of file material.hpp.