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>
66 const std::string &basePath =
"");
83 [[nodiscard]]
const std::map<uint32_t,
84 std::shared_ptr<graphic::Material>> &
97 [[nodiscard]]
const std::map<uint32_t,
98 std::shared_ptr<graphic::Texture>> &
111 [[nodiscard]]
const std::map<uint32_t,
112 std::shared_ptr<graphic::Model>> &
125 [[nodiscard]]
const std::map<uint32_t,
126 std::shared_ptr<graphic::Shader>> &
139 [[nodiscard]]
const std::map<uint32_t,
140 std::shared_ptr<graphic::CodePoints>> &
155 [[nodiscard]] uint64_t
version() const noexcept;
172 [[nodiscard]] uint32_t
getShaderID(const std::
string &shaderName) const;
214 std::shared_ptr<graphic::Font>
loadFont(const std::
string &path);
224 std::shared_ptr<graphic::Font>
245 const std::vector<std::shared_ptr<
utility::
File>> &fontAssets);
256 std::shared_ptr<graphic::Material>
loadMaterial(const std::
string &path,
269 std::shared_ptr<graphic::Material>
279 std::shared_ptr<graphic::Texture>
loadTexture(const std::
string &path);
289 std::shared_ptr<graphic::Texture>
311 std::shared_ptr<graphic::Material>
325 const std::
string &path,
327 const std::
string &material = "default_material");
343 const std::
string &material = "default_material");
361 graphic::Model::ModelType type,
363 const std::
string &material = "default_material");
378 const std::
string &path,
380 const std::
string &material = "default_material");
398 const std::
string &material = "default_material");
411 std::shared_ptr<graphic::Shader>
413 const std::
string &fragmentPath);
426 std::shared_ptr<graphic::Shader>
436 std::shared_ptr<graphic::CodePoints>
456 std::unique_ptr<sound::AudioSource>
467 std::unique_ptr<sound::AudioSource>
489 const std::
string &fragmentPath) const;
505 std::shared_ptr<graphic::Texture> atlas);
523 const std::
string &vertexPath,
524 std::shared_ptr<graphic::Shader> shader);
575 std::map<uint32_t, std::shared_ptr<graphic::Font>>
_fonts;
581 std::map<uint32_t, std::shared_ptr<graphic::Material>>
_materials;
586 std::map<uint32_t, std::shared_ptr<graphic::Texture>>
_textures;
591 std::map<uint32_t, std::shared_ptr<graphic::Model>>
_models;
596 std::map<uint32_t, std::shared_ptr<graphic::Shader>>
_shaders;
612 std::map<uint32_t, std::shared_ptr<graphic::CodePoints>>
_codePoints;
678 std::
string resolvePath(const std::
string &path) const;
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.