1 //********************************************** 2 //Singleton Texture Manager class 3 //Written by Ben English 4 //benjamin.english@oit.edu 5 // 6 //For use with OpenGL and the FreeImage library 7 //********************************************** 8 9 #ifndef TextureManager_H 10 #define TextureManager_H 11 12 #include <windows.h> 13 #include <gl/gl.h> 14 #include "FreeImage.h" 15 #include <map> 16 17 class TextureManager 18 { 19 public: 20 static TextureManager* Inst(); 21 virtual ~TextureManager(); 22 23 //load a texture an make it the current texture 24 //if texID is already in use, it will be unloaded and replaced with this texture 25 bool LoadTexture(const char* filename, //where to load the file from 26 const unsigned int texID, //arbitrary id you will reference the texture by 27 //does not have to be generated with glGenTextures 28 GLenum image_format = GL_RGB, //format the image is in 29 GLint internal_format = GL_RGB, //format to store the image in 30 GLint level = 0, //mipmapping level 31 GLint border = 0); //border size 32 33 //free the memory for a texture 34 bool UnloadTexture(const unsigned int texID); 35 36 //set the current texture 37 bool BindTexture(const unsigned int texID); 38 39 //free all texture memory 40 void UnloadAllTextures(); 41 42 protected: 43 TextureManager(); 44 TextureManager(const TextureManager& tm); 45 TextureManager& operator=(const TextureManager& tm); 46 47 static TextureManager* m_inst; 48 std::map<unsigned int, GLuint> m_texID; 49 }; 50 51 #endif