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;
71 static GlTextureManager &getInst() {
73 inst =
new GlTextureManager();
81 void changeContext(uintptr_t context);
85 void removeContext(uintptr_t context);
90 GlTexture getTextureInfo(
const std::string &);
95 bool existsTexture(
const std::string &filename);
99 bool loadTexture(
const std::string &);
103 void deleteTexture(
const std::string &);
107 void beginNewTexture(
const std::string &);
111 bool activateTexture(
const std::string &,
unsigned int);
115 bool activateTexture(
const std::string &);
119 void desactivateTexture();
123 void setAnimationFrame(
unsigned int id) {
129 unsigned int getAnimationFrame() {
130 return animationFrame;
135 void clearErrorVector() {
136 texturesWithError.clear();
141 void removeEntryOfErrorVector(
const std::string &name) {
142 texturesWithError.erase(name);
148 void registerExternalTexture(
const std::string &textureName,
const GLuint textureId);
153 static GlTextureLoader *getTextureLoader() {
154 return loader ? loader : (loader =
new GlTextureLoader());
160 static void setTextureLoader(GlTextureLoader *texLoader) {
173 static GlTextureManager *inst;
174 static GlTextureLoader *loader;
176 uintptr_t currentContext;
178 ContextAndTextureMap texturesMap;
179 std::set<std::string> texturesWithError;
181 unsigned int animationFrame;
185 #endif // Tulip_GLTEXTUREMANAGER_H