use Translator's glTexImage2D in doCompressedTexImage2D

Instead of calling the dispatcher directly. This will make sure all Translator's
internals (such as TextureData data) are updated properly.
This also fixes the bug in "Replica Island" - when the green robot was invisible,
because it's TextureData wasn't updated by doCompressedTexImage2D

The pointer to glTexImage2D is passed as a parameter to doCompressedTexImage2D,
otherwise Windows resolve the glTexImage2D symbol in the external libGL rather
than the translator's code. Longer term, we will remove the translator's link
to libGL, at which point this parameter will be removed.
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
index 0f2c2c9..5922652 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -430,7 +430,7 @@
 
     doCompressedTexImage2D(ctx, target, level, internalformat,
                                 width, height, border,
-                                imageSize, data);
+                                imageSize, data, (void*)glTexImage2D);
 }
 
 GL_API void GL_APIENTRY  glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) {
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 29dd5c7..099504b 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -293,7 +293,7 @@
 
     doCompressedTexImage2D(ctx, target, level, internalformat,
                                 width, height, border,
-                                imageSize, data);
+                                imageSize, data, (void*)glTexImage2D);
 }
 
 GL_APICALL void  GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data){
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/TextureUtils.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/TextureUtils.cpp
index 28fb920..3e8fafc 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/TextureUtils.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/TextureUtils.cpp
@@ -15,6 +15,7 @@
 */
 #include <GLcommon/TextureUtils.h>
 #include <GLcommon/GLESmacros.h>
+#include <GLcommon/GLDispatch.h>
 #include <GLcommon/GLESvalidate.h>
 #include <stdio.h>
 #include <cmath>
@@ -41,8 +42,13 @@
 void  doCompressedTexImage2D(GLEScontext * ctx, GLenum target, GLint level, 
                                           GLenum internalformat, GLsizei width, 
                                           GLsizei height, GLint border, 
-                                          GLsizei imageSize, const GLvoid* data)
+                                          GLsizei imageSize, const GLvoid* data, void * funcPtr)
 {
+    /* XXX: This is just a hack to fix the resolve of glTexImage2D problem
+       It will be removed when we'll no longer link against ligGL */
+    typedef void (GLAPIENTRY *glTexImage2DPtr_t ) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+    glTexImage2DPtr_t glTexImage2DPtr;
+    glTexImage2DPtr =  (glTexImage2DPtr_t)funcPtr; 
 
     switch (internalformat) {
         case GL_ETC1_RGB8_OES:
@@ -60,7 +66,7 @@
                 etc1_byte* pOut = new etc1_byte[size];
                 int res = etc1_decode_image((const etc1_byte*)data, pOut, width, height, 3, bpr);
                 SET_ERROR_IF(res!=0, GL_INVALID_VALUE);
-                ctx->dispatcher().glTexImage2D(target,level,format,width,height,border,format,type,pOut);
+                glTexImage2DPtr(target,level,format,width,height,border,format,type,pOut);
                 delete [] pOut;
             }
             break;
@@ -88,7 +94,7 @@
                 {
                    GLenum uncompressedFrmt;
                    unsigned char* uncompressed = uncompressTexture(internalformat,uncompressedFrmt,width,height,imageSize,data,i);
-                   ctx->dispatcher().glTexImage2D(target,i,uncompressedFrmt,tmpWidth,tmpHeight,border,uncompressedFrmt,GL_UNSIGNED_BYTE,uncompressed);
+                   glTexImage2DPtr(target,i,uncompressedFrmt,tmpWidth,tmpHeight,border,uncompressedFrmt,GL_UNSIGNED_BYTE,uncompressed);
                    tmpWidth/=2;
                    tmpHeight/=2;
                    delete uncompressed;
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TextureUtils.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TextureUtils.h
index 25c38f8..9b0c4ea 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TextureUtils.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TextureUtils.h
@@ -26,6 +26,6 @@
 void  doCompressedTexImage2D(GLEScontext * ctx, GLenum target, GLint level, 
                                           GLenum internalformat, GLsizei width, 
                                           GLsizei height, GLint border, 
-                                          GLsizei imageSize, const GLvoid* data);
+                                          GLsizei imageSize, const GLvoid* data, void * funcPtr);
 
 #endif