|
Flint Engine
Modular C++20 2D game engine powered by SDL3
|
Central resource cache and hot-reload coordinator. More...
#include <flint/resource/assets-manager.h>
Collaboration diagram for Flint::AssetManager:Classes | |
| class | WatchHandle |
| RAII handle returned by watch(). More... | |
Public Types | |
| using | ReloadCallback = std::function<void(const std::string &)> |
| Callback type invoked when a watched asset is reloaded. | |
Public Member Functions | |
| AssetManager (IAssetLoader &loader, SDL_GPUDevice *gpuDevice, bool hotReloadEnable) | |
| Construct an AssetManager. | |
| ~AssetManager () | |
| Destroy the AssetManager. | |
| GPUTexture & | getTexture (const std::string &path) |
Return a GPU texture for path, uploading it on first access. | |
| WatchHandle | watch (const std::string &path, ReloadCallback callback) |
Register a callback to be invoked whenever path is reloaded. | |
| void | update () |
| Poll for hot-reload changes and fire pending callbacks. | |
| IAssetLoader & | getLoader () |
| Return a reference to the underlying asset loader. | |
| void | setHotReloadEnabled (bool enabled) |
| Enable or disable hot-reload polling. | |
| bool | isHotReloadEnabled () const |
| Return whether hot-reload polling is currently active. | |
Central resource cache and hot-reload coordinator.
AssetManager sits between game code and the raw byte-loading layer (IAssetLoader). It caches GPU textures so repeated calls to getTexture() never re-upload the same asset, and—when hot-reload is enabled—polls the loader for revision bumps every HOT_RELOAD_INTERVAL milliseconds, invoking registered callbacks so the game can react without restarting.
AssetManager is non-copyable. Callbacks registered via watch() are automatically cancelled when their WatchHandle is destroyed, which prevents use-after-free if a system outlives the manager.
Definition at line 37 of file assets-manager.h.