5#include <utility/system_io/file.hpp>
6#include <utility/system_io/system_io.hpp>
8#include <utility/graphic/pose.hpp>
9#include <utility/graphic/text/font.hpp>
10#include <utility/graphic/text/code_points.hpp>
11#include <utility/graphic/text/text_material.hpp>
12#include <utility/graphic/material.hpp>
13#include <utility/graphic/texture.hpp>
14#include <utility/graphic/model.hpp>
15#include <utility/graphic/shader.hpp>
17#include <utility/sound/audio_source.hpp>
18#include <utility/sound/decoder/decoder_registry.hpp>
19#include <utility/sound/audio_manager.hpp>
38 utility::logging::DefaultLogger>
73 const std::string &basePath =
"");
90 [[nodiscard]]
const std::map<uint32_t,
91 std::shared_ptr<graphic::Material>> &
104 [[nodiscard]]
const std::map<uint32_t,
105 std::shared_ptr<graphic::Texture>> &
118 [[nodiscard]]
const std::map<uint32_t,
119 std::shared_ptr<graphic::Model>> &
132 [[nodiscard]]
const std::map<uint32_t,
133 std::shared_ptr<graphic::Shader>> &
146 [[nodiscard]]
const std::map<uint32_t,
147 std::shared_ptr<graphic::CodePoints>> &
162 [[nodiscard]] uint64_t
version() const noexcept;
179 [[nodiscard]] uint32_t
getShaderID(const std::
string &shaderName) const;
238 std::shared_ptr<graphic::Font>
loadFont(const std::
string &path);
248 std::shared_ptr<graphic::Font>
269 const std::vector<std::shared_ptr<
utility::
File>> &fontAssets);
280 std::shared_ptr<graphic::Material>
loadMaterial(const std::
string &path,
293 std::shared_ptr<graphic::Material>
303 std::shared_ptr<graphic::Texture>
loadTexture(const std::
string &path);
313 std::shared_ptr<graphic::Texture>
335 std::shared_ptr<graphic::Material>
349 const std::
string &path,
351 const std::
string &material = "default_material");
367 const std::
string &material = "default_material");
385 graphic::Model::ModelType type,
387 const std::
string &material = "default_material");
402 const std::
string &path,
404 const std::
string &material = "default_material");
422 const std::
string &material = "default_material");
435 std::shared_ptr<graphic::Shader>
437 const std::
string &fragmentPath);
450 std::shared_ptr<graphic::Shader>
460 std::shared_ptr<graphic::CodePoints>
480 std::unique_ptr<sound::AudioSource>
491 std::unique_ptr<sound::AudioSource>
513 const std::
string &fragmentPath) const;
529 std::shared_ptr<graphic::Texture> atlas);
547 const std::
string &vertexPath,
548 std::shared_ptr<graphic::Shader> shader);
599 std::map<uint32_t, std::shared_ptr<graphic::Font>>
_fonts;
605 std::map<uint32_t, std::shared_ptr<graphic::Material>>
_materials;
610 std::map<uint32_t, std::shared_ptr<graphic::Texture>>
_textures;
615 std::map<uint32_t, std::shared_ptr<graphic::Model>>
_models;
620 std::map<uint32_t, std::shared_ptr<graphic::Shader>>
_shaders;
636 std::map<uint32_t, std::shared_ptr<graphic::CodePoints>>
_codePoints;
702 std::
string resolvePath(const std::
string &path) const;
717 std::shared_ptr<
utility::
File> loadDefaultTextureAsset();
The File class represents a I/O file asset.
The RessourceProvider class is responsible for managing and loading various resources such as fonts,...
const std::map< uint32_t, std::shared_ptr< graphic::Shader > > & getShaders() const
Retrieves a map of loaded shaders.
std::map< uint32_t, std::shared_ptr< graphic::Material > > _materials
Internal map to store loaded materials for efficient retrieval.
std::string _basePath
An optional base path to prepend to resource paths when loading resources.
std::shared_ptr< graphic::Font > loadFontFromAsset(std::shared_ptr< utility::File > fontAsset)
Loads a font resource from a specified asset.
std::shared_ptr< graphic::Model > loadModelFromAsset(std::shared_ptr< utility::File > modelAsset, const utility::graphic::PoseF &pose=utility::graphic::PoseF(), const std::string &material="default_material")
Loads a model resource from a specified asset.
std::string buildShaderPath(const std::string &vertexPath, const std::string &fragmentPath) const
Builds a unique shader name based on the vertex and fragment shader file paths.
std::shared_ptr< graphic::Shader > loadShader(const std::string &vertexPath, const std::string &fragmentPath)
Loads a shader resource from specified vertex and fragment shader file paths.
const std::map< uint32_t, std::shared_ptr< graphic::CodePoints > > & getCodePoints() const
Retrieves a map of loaded code points resources.
const std::map< uint32_t, std::shared_ptr< graphic::Model > > & getModels() const
Retrieves a map of loaded models.
std::map< uint32_t, std::shared_ptr< graphic::Font > > _fonts
Internal maps to store loaded fonts for efficient retrieval.
uint32_t _currentID
Internal counter for generating unique IDs for resources.
uint64_t _version
Monotonic counter bumped on every mutation of the resource maps.
ShaderType
Enumeration for different shader types that can be associated with materials.
std::shared_ptr< graphic::Model > loadObj(const std::string &path, const utility::graphic::PoseF &pose=utility::graphic::PoseF(), const std::string &material="default_material")
Loads an OBJ model resource from a specified file path.
std::shared_ptr< graphic::Font > loadFont(const std::string &path)
Loads a font resource from a specified file path.
uint32_t getDefaultMaterialID()
Retrieves the unique ID of the default material.
std::shared_ptr< graphic::Texture > loadTexture(const std::string &path)
Loads a texture resource from a specified file path.
std::unordered_map< std::string, uint32_t > _elementsIDs
Internal map to store resource IDs for efficient lookup based on file paths.
std::shared_ptr< graphic::Font > loadFontFamilyFromAssets(const std::vector< std::shared_ptr< utility::File > > &fontAssets)
Loads a font family resource from a vector of font assets.
std::shared_ptr< graphic::Material > loadImageMaterial(const std::string &path)
Loads an image texture and wraps it in a material bound to the default shader.
void touch() noexcept
Records a mutation of the provider's resource maps.
utility::sound::AudioManager _audioManager
Internal audio manager instance for managing audio operations.
RessourceProvider(SystemIO &systemInterface, const std::string &basePath="")
Constructs a RessourceProvider object with a reference to a SystemIO instance.
std::unique_ptr< sound::AudioSource > loadAudioSourceFromAsset(std::shared_ptr< utility::File > audioAsset)
Loads an audio source resource from a specified asset.
void onFontAtlasCreated(const std::string &name, std::shared_ptr< graphic::Texture > atlas)
Registers a font texture atlas produced by a Font instance.
std::map< uint32_t, std::shared_ptr< graphic::Shader > > _shaders
Internal map to store loaded shaders for efficient retrieval.
std::shared_ptr< graphic::Model > loadModel(const std::string &path, const utility::graphic::PoseF &pose=utility::graphic::PoseF(), const std::string &material="default_material")
Loads a model resource from a specified file path.
const std::map< uint32_t, std::shared_ptr< graphic::Texture > > & getTextures() const
Retrieves a map of loaded textures.
const std::map< uint32_t, std::shared_ptr< graphic::Material > > & getMaterials() const
Retrieves a map of loaded materials.
std::shared_ptr< graphic::Shader > loadShaderFromAssets(std::shared_ptr< utility::File > vertexAsset, std::shared_ptr< utility::File > fragmentAsset)
Loads a shader resource from specified vertex and fragment shader assets.
std::shared_ptr< graphic::CodePoints > loadCodePointsFromAsset(std::shared_ptr< utility::File > codePointsAsset)
Loads a code points resource from a specified asset.
std::shared_ptr< graphic::Texture > loadTextureFromAsset(std::shared_ptr< utility::File > textureAsset)
Loads a texture resource from a specified asset.
std::map< uint32_t, std::shared_ptr< graphic::Model > > _models
Internal map to store loaded models for efficient retrieval.
uint32_t getMeshMaterialID()
Retrieves the unique ID of the mesh material.
std::unique_ptr< sound::AudioSource > loadAudioSource(const std::string &path)
Loads an audio source resource from a specified file path.
uint32_t getMaterialID(const std::string &materialName)
Retrieves the unique material ID associated with a given material name.
std::unordered_map< std::string, uint32_t > _shaderIDs
Shader-only index mapping a shader name to its id.
uint32_t getNextID()
Retrieves the next unique ID for a resource.
std::map< uint32_t, std::shared_ptr< graphic::CodePoints > > _codePoints
Internal map to store loaded code points resources for efficient retrieval.
uint64_t version() const noexcept
Retrieves a monotonic counter bumped on every mutation of the provider's resource maps.
std::map< uint32_t, std::shared_ptr< sound::AudioBuffer > > _audioSources
Internal map to store loaded audio buffers for efficient retrieval.
~RessourceProvider()=default
Destructs the RessourceProvider object.
uint32_t getShaderID(const std::string &shaderName) const
Retrieves the unique shader ID associated with a given shader name.
std::shared_ptr< graphic::CodePoints > loadCodePoints(const std::string &path)
Loads a code points resource from a specified file path.
std::shared_ptr< graphic::Material > loadMaterialFromAsset(ShaderType shaderType, std::shared_ptr< utility::File > materialAsset)
Loads a material resource from a specified asset.
void registerShader(uint32_t id, const std::string &path, const std::string &vertexPath, std::shared_ptr< graphic::Shader > shader)
Registers a loaded shader in the internal resource maps and the shader-only lookup index used by getS...
std::shared_ptr< graphic::Material > loadMaterial(const std::string &path, ShaderType shaderType)
Loads a material resource from a specified file path.
std::map< uint32_t, std::shared_ptr< graphic::Texture > > _textures
Internal map to store loaded textures for efficient retrieval.
std::shared_ptr< graphic::Model > loadObjFromAsset(std::shared_ptr< utility::File > modelAsset, const utility::graphic::PoseF &pose=utility::graphic::PoseF(), const std::string &material="default_material")
Loads an OBJ model resource from a specified asset.
SystemIO & _systemInterface
Reference to the SystemIO instance used for loading assets from file paths.
The SystemIO class is an abstract base class for managing file assets.
Mixin base class providing logging capabilities to derived classes.
Loggable(void)
Construct a Loggable with the specified LoggerType.
LoggerType & getLogger(void)
Get the internal logger.
Platform-specific default logger alias.
Mixin class to provide logging capabilities to derived classes.
The utility namespace contains classes and functions for the utility project.