-
Notifications
You must be signed in to change notification settings - Fork 0
/
Texture.h
47 lines (34 loc) · 1022 Bytes
/
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
#ifndef TEXTURE_H
#define TEXTURE_H
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/glew.h>
#include <iostream>
#include "ResourceBase.h"
// -------------------------------
// Abstract Texture
// -------------------------------
class Texture : public ResourceBase
{
public:
virtual GLenum getTextureType() const = 0;
void Gen();
virtual bool Load(const std::string& name);
virtual void Destroy();
void Bind(GLuint slot) const;
void Unbind(GLuint slot) const;
GLuint getHandle() const {return m_nHandle;}
static void EnableGenerateMipmaps(bool b) {s_bGenerateMipmaps=b;}
Texture() {m_nHandle=0;}
~Texture() {Destroy();}
protected:
void Bind() const;
void Unbind() const;
bool LoadFile(GLenum target, const std::string& name);
void LoadData(GLenum target, GLubyte* ptr, unsigned int w, unsigned int h, unsigned int d);
protected:
GLuint m_nHandle; // texture opengl id
static bool s_bGenerateMipmaps; // generate mipmap or not
};
#endif