BambooIsland: C:/Users/easterbunny/Desktop/Echtzeitgraphik-LU/trunk/src/TextureManager.h Source File

BambooIsland Abgabe 2

- Main Page
- Related Pages
- Classes
- Files

- File List

# C:/Users/easterbunny/Desktop/Echtzeitgraphik-LU/trunk/src/TextureManager.h

    00001 /*
    00002  * header file for TextureManager class
    00003  * written by: christian moellinger <ch.moellinger@gmail.com>
    00004  * 10/2010
    00005  */
    00006
    00007 #ifndef __realtime_lu_texture_manager_header
    00008 #define __realtime_lu_texture_manager_header
    00009
    00010 #include <string>
    00011 #include <map>
    00012 #include <list>
    00013 #include "common_gl.h"
    00014
    00015 /* if PREVENT_REBINDING_TEXTURE is defined, the texturemanager tries to prevent rebinding
    00016  * a texture if a texture is still bound to an unit but the unit is marked as "free for used".
    00017  * In this case, the texturemanager just marks the unit as "used" and prevents rebinding - but
    00018  * I think that the overhead to do this beats the benefit, so its disabled by default */
    00019 //#define PREVENT_REBINDING_TEXTURE
    00020
    00028 class TextureManager
    00029 {
    00030 private:
    00032     bool m_bDevIL_Initialized;
    00033
    00035     GLint m_iMaxTextureUnits;
    00036
    00038     std::map<std::string, GLuint> textures;
    00039
    00041     std::map<std::string, GLint> textures_in_units;
    00042     std::list<GLuint> free_units;
    00043
    00044 #ifdef PREVENT_REBINDING_TEXTURE
    00045
    00046     std::map<GLint, GLuint> unit_has_texture;
    00047 #endif
    00048
    00050     TextureManager();
    00051
    00052 public:
    00054     static TextureManager *instance();
    00055
    00057     ~TextureManager();
    00058
    00067     bool loadTexture(std::string sTextureName, std::string sFilename, bool bAlreadyGammaCorrected);
    00068
    00083     GLuint useTexture(std::string sTextureName);
    00084
    00099     void unuseTexture(std::string sTextureName);
    00100
    00114     GLuint getFreeUnit();
    00115
    00125     void releaseUnit(GLuint nUnit);
    00126
    00139     void registerManualTexture(std::string sTextureName, GLuint nTextureID);
    00140 };
    00141
    00142 #endif

All Classes Functions Variables Enumerations Enumerator