diff --git a/TextureCache.cc b/TextureCache.cc index 888f9ff..95b4142 100644 --- a/TextureCache.cc +++ b/TextureCache.cc @@ -12,9 +12,6 @@ using namespace std; //#define DEBUG_GL_ERROR #ifdef DEBUG_GL_ERROR #define checkGLError() checkGLErrorLine(__FUNCTION__, __LINE__) -#else -#define checkGLError() -#endif static void checkGLErrorLine(const char * function, int line) { GLenum err = glGetError(); @@ -25,6 +22,9 @@ static void checkGLErrorLine(const char * function, int line) << dec << line << endl; } } +#else +#define checkGLError() +#endif TextureCache::~TextureCache() { @@ -41,9 +41,14 @@ GLuint TextureCache::load(const FileLoader::Path & path, return 0; map::iterator it = m_cache.find(filename); if (it != m_cache.end()) + { return it->second; + } GLuint tex = loadTexture(path, fileLoader, mipmaps, mode, quality); - m_cache[filename] = tex; + if (tex > 0) + { + m_cache[filename] = tex; + } return tex; } @@ -121,8 +126,6 @@ GLuint TextureCache::loadTexture(const FileLoader::Path & path, checkGLError(); } - checkGLError(); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode); checkGLError(); if (mipmaps)