-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextureManager.h
56 lines (43 loc) · 1.62 KB
/
TextureManager.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
//**********************************************
//Singleton Texture Manager class
//Written by Ben English
//
//For use with OpenGL and the FreeImage library
//**********************************************
#ifndef TextureManager_H
#define TextureManager_H
#include <windows.h>
#include <GL/gl.h>
#include "FreeImage.h"
#include <map>
class TextureManager
{
public:
static TextureManager* Inst();
virtual ~TextureManager();
//load a texture an make it the current texture
//if texID is already in use, it will be unloaded and replaced with this texture
bool LoadTexture(const char* filename, //where to load the file from
const unsigned int texID, //arbitrary id you will reference the texture by
//does not have to be generated with glGenTextures
GLenum image_format = GL_RGB, //format the image is in
GLint internal_format = GL_RGB, //format to store the image in
GLint level = 0, //mipmapping level
GLint border = 0); //border size
bool LoadTextureBMP(const char* filename, const unsigned int texID);
bool LoadTextureAlphaTexture(const char* filenameImage, const char* filenameAlphaChannel,const unsigned int texID);
//free the memory for a texture
bool UnloadTexture(const unsigned int texID);
//set the current texture
bool BindTexture(const unsigned int texID);
//free all texture memory
void UnloadAllTextures();
protected:
TextureManager();
TextureManager(const TextureManager& tm);
TextureManager& operator=(const TextureManager& tm);
static TextureManager* m_inst;
std::map<unsigned int, GLuint> m_texID;
};
#endif