My Project
Loading...
Searching...
No Matches
AssetManager Class Reference

Central manager responsible for loading, storing, and managing all engine assets. Supports meshes, textures, and materials. Ensures that assets are loaded only once and reused when requested again. More...

#include <AssetManager.hpp>

Public Member Functions

void Initialize (ID3D11Device *device, ID3D11DeviceContext *context)
 Initializes the AssetManager with the Direct3D device and context. These are required for creating GPU resources (buffers, textures, etc.).
template<typename T>
std::shared_ptr< T > Load (const std::string &path)
 Loads an asset of type T from the specified path. If the asset is already loaded, returns the cached version.
std::shared_ptr< MaterialLoadMaterialForMesh (const std::string &meshPath)
 Loads the material associated with a specific mesh. Typically used when meshes reference material files.
void Reload (const std::string &path)
 Reloads an asset from disk. Useful for hot-reloading during development.
void UnloadAll ()
 Unloads all currently loaded assets and frees associated resources.
const std::unordered_map< std::string, std::shared_ptr< MeshAsset > > & GetMeshes () const
 Returns the map of all loaded meshes.
const std::unordered_map< std::string, std::shared_ptr< TextureAsset > > & GetTextures () const
 Returns the map of all loaded textures.
 AssetManager ()=default
 Default constructor.
 ~AssetManager ()
 Destructor responsible for cleaning up loaded assets.
 AssetManager (const AssetManager &)=delete
 Disable copy constructor.
AssetManageroperator= (const AssetManager &)=delete
 Disable assignment operator.

Static Public Member Functions

static AssetManagerGet ()
 Returns the singleton instance of the AssetManager.

Detailed Description

Central manager responsible for loading, storing, and managing all engine assets. Supports meshes, textures, and materials. Ensures that assets are loaded only once and reused when requested again.

Constructor & Destructor Documentation

◆ AssetManager() [1/2]

AssetManager::AssetManager ( )
default

Default constructor.

◆ ~AssetManager()

AssetManager::~AssetManager ( )

Destructor responsible for cleaning up loaded assets.

◆ AssetManager() [2/2]

AssetManager::AssetManager ( const AssetManager & )
delete

Disable copy constructor.

Member Function Documentation

◆ Get()

AssetManager & AssetManager::Get ( )
static

Returns the singleton instance of the AssetManager.

Returns
Reference to the AssetManager instance

◆ GetMeshes()

const std::unordered_map< std::string, std::shared_ptr< MeshAsset > > & AssetManager::GetMeshes ( ) const
inline

Returns the map of all loaded meshes.

Returns
Reference to the mesh asset map

◆ GetTextures()

const std::unordered_map< std::string, std::shared_ptr< TextureAsset > > & AssetManager::GetTextures ( ) const
inline

Returns the map of all loaded textures.

Returns
Reference to the texture asset map

◆ Initialize()

void AssetManager::Initialize ( ID3D11Device * device,
ID3D11DeviceContext * context )

Initializes the AssetManager with the Direct3D device and context. These are required for creating GPU resources (buffers, textures, etc.).

Parameters
deviceD3D11 device used to create GPU resources
contextD3D11 device context used for rendering

◆ Load()

template<typename T>
std::shared_ptr< T > AssetManager::Load ( const std::string & path)
inline

Loads an asset of type T from the specified path. If the asset is already loaded, returns the cached version.

Template Parameters
TAsset type (MeshAsset or TextureAsset)
Parameters
pathFile path of the asset
Returns
Shared pointer to the loaded asset

◆ LoadMaterialForMesh()

std::shared_ptr< Material > AssetManager::LoadMaterialForMesh ( const std::string & meshPath)

Loads the material associated with a specific mesh. Typically used when meshes reference material files.

Parameters
meshPathPath of the mesh
Returns
Shared pointer to the material

◆ operator=()

AssetManager & AssetManager::operator= ( const AssetManager & )
delete

Disable assignment operator.

◆ Reload()

void AssetManager::Reload ( const std::string & path)

Reloads an asset from disk. Useful for hot-reloading during development.

Parameters
pathPath of the asset to reload

◆ UnloadAll()

void AssetManager::UnloadAll ( )

Unloads all currently loaded assets and frees associated resources.


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