21 #ifndef Tulip_GLTEXTUREMANAGER_H 22 #define Tulip_GLTEXTUREMANAGER_H 24 #include <tulip/tulipconf.h> 25 #ifndef TULIP_BUILD_GL_TEX_LOADER 26 #include <tulip/TulipException.h> 28 #include <tulip/OpenGlIncludes.h> 31 #include <unordered_map> 40 unsigned int spriteNumber;
46 class TLP_GL_SCOPE GlTextureLoader {
54 #ifdef TULIP_BUILD_GL_TEX_LOADER 55 virtual bool loadTexture(
const std::string &filename, GlTexture &texture);
57 virtual bool loadTexture(
const std::string &filename, GlTexture &texture) = 0;
59 virtual ~GlTextureLoader() {}
65 class TLP_GL_SCOPE GlTextureManager {
67 typedef std::unordered_map<std::string, GlTexture> TextureMap;
73 static GlTexture getTextureInfo(
const std::string &);
78 static bool existsTexture(
const std::string &filename);
82 static bool loadTexture(
const std::string &);
86 static void deleteTexture(
const std::string &);
90 static void beginNewTexture(
const std::string &);
94 static bool activateTexture(
const std::string &,
unsigned int);
98 static bool activateTexture(
const std::string &);
102 static void deactivateTexture();
106 static inline void setAnimationFrame(
unsigned int id) {
112 static inline unsigned int getAnimationFrame() {
113 return animationFrame;
118 static inline void clearErrorVector() {
119 texturesWithError.clear();
124 static inline void removeEntryOfErrorVector(
const std::string &name) {
125 texturesWithError.erase(name);
131 static void registerExternalTexture(
const std::string &textureName,
const GLuint textureId);
136 static inline GlTextureLoader *getTextureLoader() {
137 #ifdef TULIP_BUILD_GL_TEX_LOADER 138 return loader ? loader : (loader =
new GlTextureLoader());
141 throw TulipException(
"GlTextureLoader Error: no texture loader found");
149 static void setTextureLoader(GlTextureLoader *texLoader) {
156 static void deleteAllTextures();
159 static GlTextureLoader *loader;
161 static TextureMap texturesMap;
162 static std::set<std::string> texturesWithError;
164 static unsigned int animationFrame;
168 #endif // Tulip_GLTEXTUREMANAGER_H