From 03d0055dc9a93de12949294e34bed4c9d8bd89aa Mon Sep 17 00:00:00 2001 From: Yochai Shefi Simchon Date: Mon, 20 Jun 2011 18:42:44 +0300 Subject: [PATCH] 1.1 Translator: fix conversion of compressed textures There were several bugs in the code converting palleted textures into RGB/RGBA - fixed. --- .../host/libs/Translator/GLES_CM/TextureUtils.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/TextureUtils.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/TextureUtils.cpp index 1ff40d90f..81b1c9d9e 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/TextureUtils.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/TextureUtils.cpp @@ -87,19 +87,20 @@ Color paletteColor(const unsigned char* pallete,unsigned int index,GLenum format case GL_PALETTE8_R5_G6_B5_OES: case GL_PALETTE4_R5_G6_B5_OES: s = *((short *)(pallete+index)); - return Color(s >> 10,(s >> 5) & 0x3f ,s & 0x1f,0); + return Color((s >> 11)*255/31,((s >> 5) & 0x3f)*255/63 ,(s & 0x1f)*255/31,0); //RGBA case GL_PALETTE4_RGBA8_OES: case GL_PALETTE8_RGBA8_OES: return Color(pallete[index],pallete[index+1],pallete[index+2],pallete[index+3]); case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE8_RGBA4_OES: s = *((short *)(pallete+index)); - return Color((s >> 12) & 0xf,(s >> 8) & 0xf,(s >> 4) & 0xf ,s & 0xf); + return Color(((s >> 12) & 0xf)*255/15,((s >> 8) & 0xf)*255/15,((s >> 4) & 0xf)*255/15 ,(s & 0xf)*255/15); case GL_PALETTE4_RGB5_A1_OES: case GL_PALETTE8_RGB5_A1_OES: s = *((short *)(pallete+index)); - return Color((s >> 11) & 0x1f,(s >> 6) & 0x1f,(s >> 1) & 0x1f ,s & 0x1 * 255); + return Color(((s >> 11) & 0x1f)*255/31,((s >> 6) & 0x1f)*255/31,((s >> 1) & 0x1f)*255/31 ,s & 0x1 * 255); default: return Color(255,255,255,255); } @@ -148,7 +149,8 @@ unsigned char* uncompressTexture(GLenum internalformat,GLenum& formatOut,GLsizei int paletteIndex = 0; int indexOut = i*colorSizeOut; if(indexSizeBits == 4) { - paletteIndex = (i%2)? imageIndices[i/2] >> 4: //upper bits + paletteIndex = (i%2) == 0 ? + imageIndices[i/2] >> 4: //upper bits imageIndices[i/2] & 0xf; //lower bits } else { paletteIndex = imageIndices[i];