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
|
#pragma once
#include "pointers.hpp"
#include "glconstants.hpp"
#include "../geometry/rect2d.hpp"
#include "../std/stdint.hpp"
#include "../std/function.hpp"
namespace dp
{
class Texture
{
public:
enum TextureFormat
{
RGBA8,
RGBA4,
ALPHA
};
enum ResourceType
{
Symbol,
Glyph,
UniformValue
};
class Key
{
public:
virtual ~Key() {}
virtual ResourceType GetType() const = 0;
};
class ResourceInfo
{
public:
ResourceInfo(m2::RectF const & texRect);
virtual ~ResourceInfo() {}
virtual ResourceType GetType() const = 0;
m2::RectF const & GetTexRect() const;
private:
m2::RectF m_texRect;
};
Texture();
virtual ~Texture();
void Create(uint32_t width, uint32_t height, TextureFormat format);
void Create(uint32_t width, uint32_t height, TextureFormat format, RefPointer<void> data);
void SetFilterParams(glConst minFilter, glConst magFilter);
void SetWrapMode(glConst sMode, glConst tMode);
void UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, TextureFormat format,
RefPointer<void> data);
virtual ResourceInfo const * FindResource(Key const & key) const = 0;
uint32_t GetWidth() const;
uint32_t GetHeight() const;
float GetS(uint32_t x) const;
float GetT(uint32_t y) const;
void Bind() const;
static uint32_t GetMaxTextureSize();
private:
void UnpackFormat(TextureFormat format, glConst & layout, glConst & pixelType);
int32_t GetID() const;
private:
int32_t m_textureID;
uint32_t m_width;
uint32_t m_height;
};
} // namespace dp
|