Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GLVideoDriver: Add another RemovePaletteTexture method (by texture id…

…), some code polishing
  • Loading branch information...
commit 99264285de1e1572ae180b478491c21a27a26f92 1 parent 2c2aa37
@BehoIder BehoIder authored lynxlynxlynx committed
View
17 gemrb/plugins/SDLVideo/GLPaletteManager.cpp
@@ -66,7 +66,24 @@ void GLPaletteManager::RemovePaletteTexture(Palette* palette, unsigned int color
textures.erase(key);
}
}
+}
+void GLPaletteManager::RemovePaletteTexture(GLuint texture)
+{
+ for(std::map<std::pair<Palette*, unsigned int>, PaletteValue>::iterator it = textures.begin(); it != textures.end(); ++it)
+ {
+ if(textures[it->first].first == texture)
+ {
+ if (textures[it->first].second > 1)
+ textures[it->first].second--;
+ else
+ {
+ glDeleteTextures(1, &texture);
+ textures.erase(it->first);
+ }
+ return;
+ }
+ }
}
void GLPaletteManager::Clear()
View
1  gemrb/plugins/SDLVideo/GLPaletteManager.h
@@ -17,6 +17,7 @@ namespace GemRB
public:
static GLuint CreatePaletteTexture(Palette* palette, unsigned int colorKey);
static void RemovePaletteTexture(Palette* palette, unsigned int colorKey);
+ static void RemovePaletteTexture(GLuint texture);
static void Clear();
};
}
View
6 gemrb/plugins/SDLVideo/GLTextureSprite2D.cpp
@@ -39,7 +39,7 @@ GLTextureSprite2D::~GLTextureSprite2D()
if (glTexture != 0) glDeleteTextures(1, &glTexture);
if (glMaskTexture != 0) glDeleteTextures(1, &glMaskTexture);
if (IsPaletted() && glPaletteTexture != 0)
- GLPaletteManager::RemovePaletteTexture(currentPalette, colorKeyIndex);
+ GLPaletteManager::RemovePaletteTexture(glPaletteTexture);
}
GLTextureSprite2D::GLTextureSprite2D(const GLTextureSprite2D &obj) : Sprite2D(obj)
@@ -73,7 +73,7 @@ void GLTextureSprite2D::SetPalette(Palette *pal)
{
currentPalette->release();
}
- GLPaletteManager::RemovePaletteTexture(currentPalette, colorKeyIndex);
+ if (glPaletteTexture != 0) GLPaletteManager::RemovePaletteTexture(glPaletteTexture);
currentPalette = pal;
glPaletteTexture = 0;
}
@@ -91,7 +91,7 @@ void GLTextureSprite2D::SetColorKey(ieDword index)
if(IsPaletted())
{
glDeleteTextures(1, &glMaskTexture);
- GLPaletteManager::RemovePaletteTexture(currentPalette, colorKeyIndex);
+ if (glPaletteTexture != 0) GLPaletteManager::RemovePaletteTexture(glPaletteTexture);
glPaletteTexture = 0;
glMaskTexture = 0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.