|
Nameless Engine
|
#include <TextureManager.h>
Classes | |
| struct | TextureResource |
Public Member Functions | |
| TextureManager (const TextureManager &)=delete | |
| TextureManager & | operator= (const TextureManager &)=delete |
| TextureManager (GpuResourceManager *pResourceManager) | |
| ~TextureManager () | |
| size_t | getTextureInMemoryCount () |
| std::variant< std::unique_ptr< TextureHandle >, Error > | getTexture (const std::string &sPathToResourceRelativeRes) |
Private Member Functions | |
| void | releaseTextureResourceIfNotUsed (const std::string &sPathToResourceRelativeRes) |
| void | determineTextureFormatExtension () |
| std::unique_ptr< TextureHandle > | createNewTextureHandle (const std::string &sPathToResourceRelativeRes) |
| std::variant< std::unique_ptr< TextureHandle >, Error > | loadTextureAndCreateNewTextureHandle (const std::string &sPathToResourceRelativeRes) |
Private Attributes | |
| std::pair< std::recursive_mutex, std::unordered_map< std::string, TextureResource > > | mtxTextureResources |
| std::string | sTextureFormatExtension |
| GpuResourceManager *const | pResourceManager = nullptr |
Friends | |
| class | TextureHandle |
Controls texture loading and owns all textures.
| ne::TextureManager::TextureManager | ( | GpuResourceManager * | pResourceManager | ) |
Creates a new texture manager.
| pResourceManager | Resource manager that owns this object. |
| ne::TextureManager::~TextureManager | ( | ) |
Makes sure that no resource is loaded in the memory.
|
private |
Creates a new texture handle for the specified path by using mtxTextureResources.
| sPathToResourceRelativeRes | Path to texture (file/directory) relative to res directory. |
|
private |
Initializes sTextureFormatExtension depending on the current renderer.
| std::variant< std::unique_ptr< TextureHandle >, Error > ne::TextureManager::getTexture | ( | const std::string & | sPathToResourceRelativeRes | ) |
Looks if the specified texture is loaded in the GPU memory or not and if not loads it in the GPU memory and returns a new handle that references this texture (if the texture is already loaded just returns a new handle).
| sPathToResourceRelativeRes | Path to texture (file/directory) relative to res directory. |
std::unique_ptr so that the handle can be "moved" and "reset" and we don't need to care about implementing this functionality for the handle class. | size_t ne::TextureManager::getTextureInMemoryCount | ( | ) |
Returns the current number of textures loaded in the memory.
|
private |
Loads the texture from the specified path and creates a new handle using createNewTextureHandle.
| sPathToResourceRelativeRes | Path to texture (file/directory) relative to res directory. |
|
private |
Called by texture handles in their destructor to notify the manager about a texture handle no longer referencing a texture resource so that the manager can release the texture resource if no other texture handle is referencing it.
| sPathToResourceRelativeRes | Path to texture (file/directory) relative to res directory. |
|
private |
Stores pairs of "path to texture (file/directory) relative to `res` directory" - "loaded texture resource".
|
private |
Do not delete (free) this pointer. Resource manager that owns this object.
|
private |
Either ".dds" or ".ktx" depending on the current renderer.