Permalink
Browse files

GLVideoDriver: Some fixes.

  • Loading branch information...
1 parent f7ecbac commit b7dbe6d2fdf7e456db9093a7a905e99460da4ebc @BehoIder BehoIder committed with lynxlynxlynx Jan 11, 2014
@@ -5,6 +5,8 @@
#include <GLES2/GL2ext.h>
#endif
+#include <cstring>
+
#include "GLPaletteManager.h"
#include "Palette.h"
@@ -57,12 +59,14 @@ void GLPaletteManager::RemovePaletteTexture(Palette* palette, unsigned int color
}
else
{
- PaletteValue value = textures[key];
- if (value.second > 1) value.second --;
+ if (textures[key].second > 1)
+ {
+ textures[key].second--;
+ }
else
{
- indexes.erase(value.first);
- glDeleteTextures(1, &(value.first));
+ indexes.erase(textures[key].first);
+ glDeleteTextures(1, &(textures[key].first));
textures.erase(key);
}
}
@@ -77,8 +81,10 @@ void GLPaletteManager::RemovePaletteTexture(GLuint texture)
else
{
PaletteKey key = indexes[texture];
- PaletteValue value = textures[key];
- if (value.second > 1) value.second --;
+ if (textures[key].second > 1)
+ {
+ textures[key].second--;
+ }
else
{
indexes.erase(texture);
@@ -98,6 +104,7 @@ void GLPaletteManager::Clear()
indexes.clear();
}
+
GLPaletteManager::GLPaletteManager()
{
}
@@ -210,17 +210,22 @@ GLuint GLTextureSprite2D::GetAttachedPaletteTexture(Palette* attached)
// we already have a texture for requested palette
if (attached == attachedPalette && glAttachedPaletteTexture != 0) return glAttachedPaletteTexture;
attachedPalette = attached;
- attachedPalette->acquire();
+ if(!attachedPalette->IsShared())
+ {
+ attachedPalette->acquire();
+ }
glAttachedPaletteTexture = paletteManager->CreatePaletteTexture(attachedPalette, colorKeyIndex);
return glAttachedPaletteTexture;
}
void GLTextureSprite2D::RemoveAttachedPaletteTexture()
{
+ if (!attachedPalette->IsShared())
+ {
+ attachedPalette->release();
+ }
if (glAttachedPaletteTexture != 0) paletteManager->RemovePaletteTexture(glAttachedPaletteTexture);
glAttachedPaletteTexture = 0;
- attachedPalette->release();
- attachedPalette = NULL;
}
GLuint GLTextureSprite2D::GetMaskTexture()
@@ -239,4 +244,10 @@ GLuint GLTextureSprite2D::GetTexture()
createGlTexture();
}
return glTexture;
-}
+}
+
+Uint8* GLTextureSprite2D::GetPixels()
+{
+ return NULL;
+}
+
@@ -45,6 +45,7 @@ namespace GemRB
~GLTextureSprite2D();
GLTextureSprite2D(const GLTextureSprite2D &obj);
GLTextureSprite2D* copy() const;
+ Uint8* GetPixels();
};
}
@@ -11,6 +11,7 @@
#pragma comment(lib, "libGLESv2")
#endif
#endif
+
#include "SDL20GLVideo.h"
#include "Interface.h"
#include "Game.h" // for GetGlobalTint
@@ -493,7 +494,7 @@ void GLVideoDriver::blitSprite(GLTextureSprite2D* spr, int x, int y, const Regio
glDisableVertexAttribArray(a_position);
// renove attached texture
- if (attachedPal && !attachedPal->IsShared()) spr->RemoveAttachedPaletteTexture();
+ if (attachedPal) spr->RemoveAttachedPaletteTexture();
glDeleteBuffers(1, &buffer);
spritesPerFrame++;
@@ -713,7 +714,7 @@ Sprite2D* GLVideoDriver::GetScreenshot(Region r)
// flip pixels vertical
Uint32* pixelDstPointer = pixels;
Uint32* pixelSrcPointer = glPixels + (h-1)*w;
- for(int i=0; i<h; i++)
+ for(unsigned int i=0; i<h; i++)
{
memcpy(pixelDstPointer, pixelSrcPointer, w*4);
pixelDstPointer += w;

0 comments on commit b7dbe6d

Please sign in to comment.