21 #ifndef Tulip_GLTEXTUREMANAGER_H 22 #define Tulip_GLTEXTUREMANAGER_H 24 #include <tulip/tulipconf.h> 30 #if defined(__APPLE__) 31 #include <OpenGL/gl.h> 48 unsigned int spriteNumber;
54 class TLP_GL_SCOPE GlTextureLoader {
62 virtual bool loadTexture(
const std::string& filename, GlTexture& texture);
64 virtual ~GlTextureLoader() {}
70 class TLP_GL_SCOPE GlTextureManager {
72 typedef std::map<std::string,GlTexture> TextureUnit;
73 typedef std::map<uintptr_t,TextureUnit> ContextAndTextureMap;
80 static GlTextureManager &getInst() {
82 inst=
new GlTextureManager();
90 void changeContext(uintptr_t context);
94 void removeContext(uintptr_t context);
99 GlTexture getTextureInfo(
const std::string&);
104 bool existsTexture(
const std::string& filename);
108 bool loadTexture(
const std::string&);
112 void deleteTexture(
const std::string &);
116 void beginNewTexture(
const std::string&);
120 bool activateTexture(
const std::string&,
unsigned int);
124 bool activateTexture(
const std::string&);
128 void desactivateTexture();
132 void setAnimationFrame(
unsigned int id) {
138 unsigned int getAnimationFrame() {
139 return animationFrame;
144 void clearErrorVector() {
145 texturesWithError.clear();
150 void removeEntryOfErrorVector(
const std::string &name) {
151 texturesWithError.erase(name);
158 void registerExternalTexture(
const std::string &textureName,
const GLuint textureId);
163 static GlTextureLoader* getTextureLoader() {
164 return loader ? loader : (loader =
new GlTextureLoader());
170 static void setTextureLoader(GlTextureLoader* texLoader) {
184 static GlTextureManager* inst;
185 static GlTextureLoader* loader;
187 uintptr_t currentContext;
189 ContextAndTextureMap texturesMap;
190 std::set<std::string> texturesWithError;
192 unsigned int animationFrame;
198 #endif // Tulip_GLTEXTUREMANAGER_H