blob: e68ce1fde8101700c2ae2c760e5635ddc59ae5c3 (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#ifndef _TEXTURE_H
#define _TEXTURE_H
#include "gl.h"
#include "assets.h"
namespace Mauri
{
enum TextureVersion
{
TEXB0001 = 0,
TEXB0002,
TEXB0003
};
enum TextureFormat
{
RGBA8888 = 0,
DXT5 = 4,
DXT3 = 6,
DXT1 = 7,
RG88 = 8,
R8 = 9
};
struct TextureFlags
{
bool NO_INTERPOLATION : 1;
bool CLAMP_UV : 1;
bool IS_GIF : 1;
u32 UNKNOWN : 29;
};
struct TextureFrame
{
u32 id;
f32 frame_time;
f32 x;
f32 y;
f32 width;
f32 unknown0;
f32 unknown1;
f32 height;
};
class Texture
{
public:
Texture(Asset *asset);
Texture(RenderFramebuffer *buffer);
~Texture();
bool wrapped;
RenderTexture *texture;
u32 width;
u32 height;
union { u32 i; TextureFlags m; } flags = { 0 };
auto is_gif() const -> bool
{
return this->flags.m.IS_GIF == 1;
}
u32 gif_width;
u32 gif_height;
u32 gif_index = 0;
f32 gif_update = 0.f;
vec4 *texture_resolution;
vec2 texture_translation = vec2(0.f);
vec4 texture_rotation = vec4(0.f);
auto bind(s32 index) -> void;
auto update(f32 time) -> void;
auto save_to_file(const std::string &filename) -> void;
private:
std::vector<RenderTexture *> textures;
std::vector<vec4> texture_resolutions;
std::vector<TextureFrame> frames;
};
class Framebuffer
{
public:
Framebuffer(std::string name, s32 width, s32 height, f32 scale);
~Framebuffer();
std::string name;
RenderFramebuffer *buffer;
Texture *texture;
};
} // namespace Mauri
#endif // _TEXTURE_H
|