6#include <aegis2d/render/export.hpp>
47 TextureId load(std::string_view name,
const std::filesystem::path& path);
77 bool reload(
const std::filesystem::path& path);
116 [[nodiscard]] std::optional<TextureId>
find(std::string_view name)
const;
120 [[nodiscard]] std::size_t
size() const noexcept;
124 [[nodiscard]]
std::
size_t textures() const noexcept;
131 std::
size_t created_ = 0;
Watches files and reloads each one with its own function when it changes.
Definition hot_reload.hpp:40
What the game draws with, whatever the graphics API behind it.
Definition renderer.hpp:81
How a texture is cut into frames, numbered from 0.
Definition sprite_sheet.hpp:37
The game's textures, each loaded once and found by a name such as "player".
Definition texture_manager.hpp:33
TextureId load_sheet(std::string_view name, const std::filesystem::path &path, TextureSize frame, std::size_t count=0)
Loads an image file as a sprite sheet of frames of the same size in a grid.
TextureId get(std::string_view name) const
Texture of a name.
TextureId add(std::string_view name, const Image &image)
Adds an image made in memory, such as a marker or a font, under a name.
Rect source(TextureId texture, std::size_t frame) const
Part of a texture to draw for a frame, as Sprite::source takes it.
TextureId load(std::string_view name, const std::filesystem::path &path)
Loads an image file as a texture under a name, unless it is loaded already.
std::size_t size() const noexcept
Number of names.
std::optional< TextureId > find(std::string_view name) const
Looks a name up.
const SpriteSheet * sheet(TextureId texture) const noexcept
Sprite sheet of a texture.
TextureManager(IRenderer &renderer) noexcept
Creates an empty manager whose textures go to renderer.
void watch(core::HotReload &hot)
Reloads each file loaded so far whenever it changes on disk.
bool reload(const std::filesystem::path &path)
Reads a loaded file again and replaces its texture's image.
void set_sheet(TextureId texture, SpriteSheet sheet)
Cuts a texture into the frames of a sprite sheet, replacing its sheet if it had one.
Files reloaded while the game runs when they change on disk, in debug builds.
Images in memory: loaded from files, generated by the engine, saved as PNG.
OpenGL renderer: sprites, text and camera (client only).
Definition bitmap_font.hpp:16
std::uint32_t TextureId
Identifier of a texture loaded by the resource manager.
Definition renderer.hpp:32
Definition endpoint.hpp:85
Backend-independent renderer interface and the sprite it draws.
Frames of a sprite sheet: the rectangles of a texture that a sprite shows in turn.
RGBA image with 8 bits per channel, ready to become a texture.
Definition image.hpp:25
Axis-aligned rectangle.
Definition renderer.hpp:20
Width and height of a texture, in pixels.
Definition renderer.hpp:38