Texture error checking and removed redundant caching

This commit is contained in:
2014-05-30 18:51:11 +02:00
parent 235a03ab4c
commit 55db057e50
+5 -4
View File
@@ -8,13 +8,14 @@ Texture::Texture(std::string path)
void Texture::Load(std::string path)
{
auto cachedTexture = m_TextureCache.find(path);
if (cachedTexture == m_TextureCache.end())
m_Texture = SOIL_load_OGL_texture(path.c_str(), 0, 0, SOIL_FLAG_INVERT_Y);
if (m_Texture == 0)
{
m_TextureCache[path] = SOIL_load_OGL_texture(path.c_str(), 0, 0, SOIL_FLAG_INVERT_Y);
LOG_ERROR("SOIL: Failed to load texture \"%s\"", path.c_str());
return;
}
m_Texture = m_TextureCache[path];
glBindTexture(GL_TEXTURE_2D, m_Texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);