Manifest-driven cache for sf::Texture resources.
More...
#include <TextureManager.h>
|
| static const sf::Texture & | get (const Asset &asset) |
| | Retrieve the cached resource for an asset enum value.
|
| static void | unload (Asset asset) |
| | Remove a resource from the cache.
|
template<typename
Manifest>
class ml::TextureManager< Manifest >
Manifest-driven cache for sf::Texture resources.
TextureManager<Manifest> extends ResourceManager to provide lazy-loaded, cached access to textures declared in a manifest's Images enum.
Usage
static std::enable_if_t< has_Image< M >::value, const sf::Texture & > get(typename M::Images image)
Retrieve a cached sf::Texture by manifest enum value.
static const sf::Texture & get(const Asset &asset)
- Template Parameters
-
| Manifest | A Manifest subclass with an Images enum whose values map to texture file paths. |
- See also
- ResourceManager, AssetsManager, Manifest
TextureManager.
Definition at line 39 of file TextureManager.h.
◆ get()
Retrieve the cached resource for an asset enum value.
Loads and caches on first access. Throws std::runtime_error if the path is not registered or loading fails.
- Template Parameters
-
| Asset | An enum type declared inside Manifest. |
- Parameters
-
| asset | The specific enum value to load. |
- Returns
- Const reference to the cached
Resource.
◆ unload()
Remove a resource from the cache.
The next get(asset) call will reload from disk. If called during draw(), the unload is deferred until after the frame completes to prevent mid-frame dangling references.
- Template Parameters
-
| Asset | The enum type of the key to remove. |
- Parameters
-
| asset | The specific enum value to evict from the cache. |
The documentation for this class was generated from the following file: