|
emilib
|
#include <texture_mngr.hpp>
Public Types | |
| using | Recorder = std::function< void(const std::string &name)> |
Public Member Functions | |
| TextureMngr (const std::string &gfx_dir, ImageLoader image_loader) | |
| Look for textures relative to gfx_dir. | |
| void | update () |
| Call frequently (once a frame) for hot-reloading of textures. | |
| gl::Texture_SP | prefetch_retain (const std::string &name, const gl::TexParams ¶ms) |
| While holding on to this shared_ptr handle, the texture won't get evicted. | |
| gl::Texture_SP | get_retain (const std::string &name, const gl::TexParams ¶ms) |
| gl::Texture_SP | get_retain (const std::string &name) |
| gl::Texture * | get (const std::string &name, const gl::TexParams ¶ms) |
| Get a texture ready for use. | |
| gl::Texture * | get (const std::string &name) |
| gl::Texture * | prefetch (const std::string &name, const gl::TexParams ¶ms) |
| Get a handle to a texture which will be loaded by finalize_eviction. | |
| gl::Texture * | prefetch (const std::string &name) |
| void | prefetch_all (const std::string &sub_folder="") |
| Recursively prefetch all textures in gfx_dir/sub_folder. | |
| void | prepare_eviction () |
| void | finalize_eviction () |
| const gl::Texture * | black () const |
| const gl::Texture * | white () const |
| gl::TexParams | default_params () const |
| size_t | memory_usage (unsigned *out_tex_count) const |
| Bytes. | |
| void | print_memory_usage (const char *prefix="") const |
| void | start_recording (Recorder recorder) |
| void | stop_recording () |
Handles loading, unloading, memoization of textures. If a file changes on disk, that file is hot-reloaded by a call to update().
| void emilib::TextureMngr::prepare_eviction | ( | ) |
When we need to load a bunch of new things it is prudent to throw out the old. We do this in three steps: 1) call prepare_eviction 2) call prefetch (or get) on all textures you are planning to use 3) call finalize_eviction, which will, in order:
| void emilib::TextureMngr::start_recording | ( | Recorder | recorder | ) |
Let's say you want to load a bunch of resources and later reload the same ones. You can use a Recorder to record all things being loaded.
1.8.13