21 #ifndef Tulip_GLTEXTUREMANAGER_H 22 #define Tulip_GLTEXTUREMANAGER_H 24 #include <tulip/tulipconf.h> 26 #include <tulip/OpenGlIncludes.h> 40 unsigned int spriteNumber;
46 class TLP_GL_SCOPE GlTextureLoader {
54 virtual bool loadTexture(
const std::string& filename, GlTexture& texture);
56 virtual ~GlTextureLoader() {}
62 class TLP_GL_SCOPE GlTextureManager {
64 typedef std::map<std::string,GlTexture> TextureUnit;
65 typedef std::map<uintptr_t,TextureUnit> ContextAndTextureMap;
72 static GlTextureManager &getInst() {
74 inst=
new GlTextureManager();
82 void changeContext(uintptr_t context);
86 void removeContext(uintptr_t context);
91 GlTexture getTextureInfo(
const std::string&);
96 bool existsTexture(
const std::string& filename);
100 bool loadTexture(
const std::string&);
104 void deleteTexture(
const std::string &);
108 void beginNewTexture(
const std::string&);
112 bool activateTexture(
const std::string&,
unsigned int);
116 bool activateTexture(
const std::string&);
120 void desactivateTexture();
124 void setAnimationFrame(
unsigned int id) {
130 unsigned int getAnimationFrame() {
131 return animationFrame;
136 void clearErrorVector() {
137 texturesWithError.clear();
142 void removeEntryOfErrorVector(
const std::string &name) {
143 texturesWithError.erase(name);
150 void registerExternalTexture(
const std::string &textureName,
const GLuint textureId);
155 static GlTextureLoader* getTextureLoader() {
156 return loader ? loader : (loader =
new GlTextureLoader());
162 static void setTextureLoader(GlTextureLoader* texLoader) {
176 static GlTextureManager* inst;
177 static GlTextureLoader* loader;
179 uintptr_t currentContext;
181 ContextAndTextureMap texturesMap;
182 std::set<std::string> texturesWithError;
184 unsigned int animationFrame;
190 #endif // Tulip_GLTEXTUREMANAGER_H