![]() |
Copperfield Engine 0.1
C++ Game Engine
|
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). | |
ResourceManager & | operator= (ResourceManager &other)=delete |
Copy assignment operator (deleted). | |
ResourceManager & | operator= (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... | |
Stores and offers access to all meshes, textures, and sounds of the engine.
const Texture & ResourceManager::getEmptyTexture | ( | ) | const |
Retrieve a white texture.
This is usually used when creating a RenderCmp and you don't want the object to have a texture.
const Mesh & ResourceManager::getMesh | ( | const BasicMesh | id | ) | const |
const Mesh & ResourceManager::getMesh | ( | const std::string & | id | ) | const |
Retrieve a mesh.
id | Name you assigned when you loaded the asset with loadResource. |
This is usually used when creating a RenderCmp.
const SoundBuffer & ResourceManager::getSound | ( | const std::string & | id | ) | const |
Retrieve a SoundBuffer.
id | Name you assigned when you loaded the asset with loadResource. |
This is usually used when creating a SoundCmp.
const Texture & ResourceManager::getTexture | ( | const std::string & | id | ) | const |
Retrieve a texture.
id | Name you assigned when you loaded the asset with loadResource. |
This is usually used when creating a RenderCmp.
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.
resource_type | Type of resource that you want to load. |
file_path | Path where the resource to load is located. |
identifier | Name with which you will identify the resource. Must be unique. |
Using an already assigned identifier will override the previous asset.
bool ResourceManager::WaitResourceLoad | ( | ) |
Stops the program, waiting for resource loading to complete.
Waits for all resources to finish loading. You must always use this function once before trying to use any of the loaded resources.