-
Notifications
You must be signed in to change notification settings - Fork 0
/
Texture.h
119 lines (101 loc) · 2.15 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "Util.h"
#include "Deletors.h"
#include "RessourceHandler.h"
#include <fstream>
NSP_STD
NSP_UTIL
class Shader;
typedef unsigned int GLuint;
typedef unsigned int GLenum;
#pragma once
class Image : public RessourceLoader
{
public:
enum ImageType
{
BMP,
PNG
};
enum PixelStructure
{
A = 1,
RGB = 3,
RGBA = 4
};
Image();
explicit Image(string&);
Image(const Image& other);
Image& operator=(const Image& other);
string getPath() { return path; }
void load(ifstream& f);
void* get() { return this; }
char* getData();
PixelStructure getPixelStructure();
unsigned int getHeight() { return _height; }
unsigned int getWidth() { return _width; }
~Image()
{
_data = nullptr;
_colorTable = nullptr;
}
private:
void format();
ImageType getFileImageType( ifstream&);
string path;
std::unique_ptr<char[]> _data;
PixelStructure _structure;
ImageType _type;
unsigned short _depth;
unsigned int _compression;
unsigned int _bitMasks[3];
int _width, _height;
unique_ptr<char[]> _colorTable;
unsigned int _tableSize;
};
#pragma once
class Texture
{
public:
Texture();
explicit Texture(string&, unsigned int samplerID = 0);
explicit Texture(Texture&& other);
~Texture();
virtual void load(RessourceHandler&);
virtual void glDownload();
virtual void bind(Shader&);
protected:
unsigned int _samplerID;
private:
GLenum getTextureType(Image::PixelStructure);
unique_ptr<GLuint, deleteGLTexture> _ID;
static GLuint _lastTexID;
const string _sampler;
Image _image;
RessourceHandler::Ressource _imgLink;
};
#pragma once
class LayeredTexture : public Texture
{
public:
explicit LayeredTexture(string&);
explicit LayeredTexture(vector<string>&);
~LayeredTexture();
virtual void load(RessourceHandler&);
virtual void glDownload();
virtual void bind(Shader&);
private:
vector<Texture> _samplerList;
};
#pragma once
class TextureAtlas : public LayeredTexture
{
public:
TextureAtlas(string&, unsigned int xCount, unsigned int yCount);
TextureAtlas(vector<string>&, unsigned int xCount, unsigned int yCount);
~TextureAtlas();
private:
unsigned int _countX;
unsigned int _countY;
double _xRatio, _yRatio;
const string _xUni, _yUni;
};