Copperfield Engine 0.1
C++ Game Engine
Loading...
Searching...
No Matches
ResourceManager Class Reference

Stores and offers access to all meshes, textures, and sounds of the engine. More...

#include <resource_manager.hpp>

Public Member Functions

 ResourceManager (const ResourceManager &other)=delete
 Copy constructor (deleted).
 
 ResourceManager (ResourceManager &&other)=delete
 Move constructor (deleted).
 
ResourceManageroperator= (ResourceManager &other)=delete
 Copy assignment operator (deleted).
 
ResourceManageroperator= (ResourceManager &&other)=delete
 Move assignment operator (deleted).
 
void loadResource (const ResourceType &resource_type, const std::string &file_path, const std::string &identifier)
 Load an external asset from a file using multithreading. More...
 
bool WaitResourceLoad ()
 Stops the program, waiting for resource loading to complete. More...
 
const Mesh & getMesh (const std::string &id) const
 Retrieve a mesh. More...
 
const Mesh & getMesh (const BasicMesh id) const
 Retrieve a mesh. More...
 
const Texture & getTexture (const std::string &id) const
 Retrieve a texture. More...
 
const Texture & getEmptyTexture () const
 Retrieve a white texture. More...
 
const SoundBuffer & getSound (const std::string &id) const
 Retrieve a SoundBuffer. More...
 

Detailed Description

Stores and offers access to all meshes, textures, and sounds of the engine.

Member Function Documentation

◆ getEmptyTexture()

const Texture & ResourceManager::getEmptyTexture ( ) const

Retrieve a white texture.

Returns
A white texture.

This is usually used when creating a RenderCmp and you don't want the object to have a texture.

◆ getMesh() [1/2]

const Mesh & ResourceManager::getMesh ( const BasicMesh  id) const

Retrieve a mesh.

Parameters
idEngine default loaded mesh.
Returns
Requested mesh.

This is usually used when creating a RenderCmp.

◆ getMesh() [2/2]

const Mesh & ResourceManager::getMesh ( const std::string &  id) const

Retrieve a mesh.

Parameters
idName you assigned when you loaded the asset with loadResource.
Returns
Requested mesh.

This is usually used when creating a RenderCmp.

◆ getSound()

const SoundBuffer & ResourceManager::getSound ( const std::string &  id) const

Retrieve a SoundBuffer.

Parameters
idName you assigned when you loaded the asset with loadResource.
Returns
Requested sound.

This is usually used when creating a SoundCmp.

◆ getTexture()

const Texture & ResourceManager::getTexture ( const std::string &  id) const

Retrieve a texture.

Parameters
idName you assigned when you loaded the asset with loadResource.
Returns
Requested texture.

This is usually used when creating a RenderCmp.

◆ loadResource()

void ResourceManager::loadResource ( const ResourceType resource_type,
const std::string &  file_path,
const std::string &  identifier 
)

Load an external asset from a file using multithreading.

You'll need to use WaitResourceLoad before trying to access the resource.

Parameters
resource_typeType of resource that you want to load.
file_pathPath where the resource to load is located.
identifierName with which you will identify the resource. Must be unique.

Using an already assigned identifier will override the previous asset.

◆ WaitResourceLoad()

bool ResourceManager::WaitResourceLoad ( )

Stops the program, waiting for resource loading to complete.

Returns
Return true if all resources are completed, else return false.

Waits for all resources to finish loading. You must always use this function once before trying to use any of the loaded resources.