forked from AdrienTD/c47edit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
texture.h
40 lines (35 loc) · 1.39 KB
/
texture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <cstdint>
#include <map>
#include <string_view>
#include <vector>
struct Chunk;
struct Scene;
namespace std::filesystem {
class path;
}
struct TexInfo {
uint32_t id;
uint16_t height, width;
uint32_t numMipmaps;
uint32_t flags;
uint32_t random;
const char name[1];
TexInfo() = delete;
const char* getName() const { return name; }
};
extern std::map<uint32_t, void*> texmap;
void GlifyTexture(Chunk* c);
void GlifyAllTextures();
void InvalidateTexture(uint32_t texid);
void UncacheAllTextures();
uint32_t AddTexture(Scene& scene, uint8_t* pixels, int width, int height, std::string_view name);
uint32_t AddTexture(Scene& scene, const std::filesystem::path& filepath);
uint32_t AddTexture(Scene& scene, const void* mem, size_t memSize, std::string_view name);
void ImportTexture(uint8_t* pixels, int width, int height, std::string_view name, Chunk& chk, Chunk& dxtchk, int texid);
void ImportTexture(const std::filesystem::path& filepath, Chunk& chk, Chunk& dxtchk, int texid);
void ImportTexture(const void* mem, size_t memSize, std::string_view name, Chunk& chk, Chunk& dxtchk, int texid);
void ExportTexture(Chunk* texChunk, const std::filesystem::path& filepath);
std::vector<uint8_t> ExportTextureToPNGInMemory(Chunk* texChunk);
std::pair<Chunk*, Chunk*> FindTextureChunk(Scene& scene, uint32_t id);
std::pair<Chunk*, Chunk*> FindTextureChunkByName(Scene& scene, std::string_view name);