-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTexture.h
51 lines (40 loc) · 1.25 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
#ifndef _TEXTURE_H_
#define _TEXTURE_H_
#include <GL/glew.h>
#include <cstdint>
#include <string>
enum class WrapMode {
eRepeat, eMirrorRepeat, eClampToEdge, eClampToBorder
};
enum class FilterMode {
eNearest, eLinear, eNearestMipmapLinear, eLinearMipmapLinear, eNearestMipmapNearest, eLinearMipmapNearest
};
enum class ColorType {
eRed, eRG, eRGB, eRGBA
};
class ITexture {
public:
virtual void bindToChannel(GLuint channel)=0;
virtual void setWrap(WrapMode s, WrapMode t, WrapMode r)=0;
virtual void setFilter(FilterMode min, FilterMode mag)=0;
virtual void release()=0;
virtual bool hasMipmap()=0;
};
class Texture2D : public ITexture {
public:
Texture2D(uint32_t width, uint32_t height, ColorType type=ColorType::eRGBA);
static Texture2D LoadFromFile(const std::string &pngfile);
virtual void bindToChannel(GLuint channel) override;
virtual void setWrap(WrapMode s, WrapMode t, WrapMode r = WrapMode::eRepeat) override;
virtual void setFilter(FilterMode min, FilterMode mag) override;
virtual void release() override;
virtual bool hasMipmap() override;
GLuint id() const
{ return m_id; }
private:
Texture2D(GLuint id);
GLuint m_id;
uint32_t m_width, m_height;
bool m_mipmap;
};
#endif