1#ifndef NNGN_GRAPHICS_TEXTURE_H
2#define NNGN_GRAPHICS_TEXTURE_H
41 static std::vector<std::byte>
read(
const char *filename);
44 const char *filename, std::span<const std::byte>
s,
Format fmt);
54 std::span<std::byte> dst, std::span<const std::byte> src);
56 static void flip_y(std::span<std::byte>
s);
95 void add_ref(
const char *filename, std::size_t
n = 1);
97 std::vector<std::tuple<std::string_view, u32>>
dump(
void)
const;
102 std::vector<std::string>
names = {{}};
name
Definition cathedral.lua:11
Texture manager, loads and caches image data from files/buffers.
Definition texture.h:34
Format
Definition texture.h:36
std::vector< u32 > counts
Definition texture.h:101
Graphics * graphics
Definition texture.h:99
static bool write(const char *filename, std::span< const std::byte > s, Format fmt)
Writes raw RGBA image data to a file.
Definition texture.cpp:116
u32 load_data(const char *name, const std::byte *p)
Loads RGBA texture data from a buffer.
Definition texture.cpp:188
void remove(u32 i)
Decrements a texture's reference count and cleans up if necessary.
Definition texture.cpp:238
bool reload(u32 i)
Reloads data for a single texture.
Definition texture.cpp:218
void set_max(u32 n)
Sets the maximum number of textures that can be loaded.
Definition texture.cpp:182
u32 max(void) const
Maximum number of textures that can be loaded, see set_max.
Definition texture.h:58
u64 generation(void) const
Counter incremented every time the cache is changed.
Definition texture.h:66
u64 gen
Definition texture.h:103
bool update_data(u32 i, const std::byte *p) const
Updates a previously loaded texture.
Definition texture.cpp:233
void add_ref(u32 i, std::size_t n=1)
Increments the reference count of a texture.
Definition texture.cpp:247
std::vector< std::string > names
Definition texture.h:102
static void red_to_rgba(std::span< std::byte > dst, std::span< const std::byte > src)
Expands single-channel data into full RGBA.
Definition texture.cpp:153
void set_graphics(Graphics *g)
Sets the graphics back end where textures will be uploaded.
Definition texture.h:72
std::vector< Hash > hashes
Definition texture.h:100
static void flip_y(std::span< std::byte > s)
Reverses the rows of a buffer containing raw RGBA image data.
Definition texture.cpp:163
bool reload_all(void)
Reloads all texture data.
Definition texture.cpp:226
u32 insert(u32 i, std::string_view name, const std::byte *p)
Definition texture.cpp:142
std::vector< std::tuple< std::string_view, u32 > > dump(void) const
Dumps name/ref_count pairs for all loaded textures.
Definition texture.cpp:263
static std::vector< std::byte > read(const char *filename)
Reads raw RGBA image data from a file.
Definition texture.cpp:91
u32 n(void) const
Number of active images in the cache.
Definition texture.cpp:177
for i
Definition font.lua:5
local g
Definition gamma.lua:7
std::string fmt(auto &&...args)
Definition string.h:11
std::uint32_t u32
Definition def.h:14
std::uint8_t u8
Definition def.h:12
std::uint64_t u64
Definition def.h:15
load
Definition entity.lua:7
Definition graphics.h:138
std::chrono::seconds s
Definition timing.cpp:6