Translator 1.1 conformance: fix ARRAY related gets

There is a set of glGets which query the client state of the
binded arrays. The data exists in the translator context and is not
passed to GL, so the glGets should be handled internaly.
This is done by implementing four glGet*v methods in GLEScontext, which
return a boolean value indicating whether we have set the return value
or not, and are called by the glGet*v functions in GLEScmImp.
Two of the glGets are handled by GLEScontext, and the other 15 by
GLEScmContext since they are specific to GLES 1.1. The same should be
done for 2.0 specific glGets in a later patch.
Also. bufferName is now saved in GLESPointer in to allow the
GL_*_ARRAY_BUFFER_BINDING get.
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
index f40525d..c26fb8d 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
@@ -17,6 +17,7 @@
 #include "GLEScmContext.h"
 #include "GLEScmUtils.h"
 #include <GLcommon/GLutils.h>
+#include <GLcommon/GLconversion_macros.h>
 #include <string.h>
 #include <GLES/gl.h>
 #include <GLES/glext.h>
@@ -285,3 +286,114 @@
 int GLEScmContext::getMaxTexUnits() {
     return getCaps()->maxTexUnits;
 }
+
+bool GLEScmContext::glGetBooleanv(GLenum pname, GLboolean *params)
+{
+    GLint iParam;
+
+    if(glGetIntegerv(pname, &iParam))
+    {
+        *params = (iParam != 0);
+        return true;
+    }
+
+    return false;
+}
+
+bool GLEScmContext::glGetFixedv(GLenum pname, GLfixed *params)
+{
+    GLint iParam;
+
+    if(glGetIntegerv(pname, &iParam))
+    {
+        *params = I2X(iParam);
+        return true;
+    }
+
+    return false;
+}
+
+bool GLEScmContext::glGetFloatv(GLenum pname, GLfloat *params)
+{
+    GLint iParam;
+
+    if(glGetIntegerv(pname, &iParam))
+    {
+        *params = (GLfloat)iParam;
+        return true;
+    }
+
+    return false;
+}
+
+bool GLEScmContext::glGetIntegerv(GLenum pname, GLint *params)
+{
+    if(GLEScontext::glGetIntegerv(pname, params))
+        return true;
+
+    const GLESpointer* ptr = NULL;
+
+    switch(pname){
+        case GL_VERTEX_ARRAY_BUFFER_BINDING:
+        case GL_VERTEX_ARRAY_SIZE:
+        case GL_VERTEX_ARRAY_STRIDE:
+        case GL_VERTEX_ARRAY_TYPE:
+            ptr = getPointer(GL_VERTEX_ARRAY_POINTER);
+            break;
+
+        case GL_NORMAL_ARRAY_BUFFER_BINDING:
+        case GL_NORMAL_ARRAY_STRIDE:
+        case GL_NORMAL_ARRAY_TYPE:
+            ptr = getPointer(GL_NORMAL_ARRAY_POINTER);
+            break;
+
+        case GL_COLOR_ARRAY_BUFFER_BINDING:
+        case GL_COLOR_ARRAY_SIZE:
+        case GL_COLOR_ARRAY_STRIDE:
+        case GL_COLOR_ARRAY_TYPE:
+            ptr = getPointer(GL_COLOR_ARRAY_POINTER);
+            break;
+
+        case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
+        case GL_TEXTURE_COORD_ARRAY_SIZE:
+        case GL_TEXTURE_COORD_ARRAY_STRIDE:
+        case GL_TEXTURE_COORD_ARRAY_TYPE:
+            ptr = getPointer(GL_TEXTURE_COORD_ARRAY_POINTER);
+            break;
+
+        default:
+            return false;
+    }
+
+    switch(pname)
+    {
+        case GL_VERTEX_ARRAY_BUFFER_BINDING:
+        case GL_NORMAL_ARRAY_BUFFER_BINDING:
+        case GL_COLOR_ARRAY_BUFFER_BINDING:
+        case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
+            *params = ptr ? ptr->getBufferName() : 0;
+            break;
+
+        case GL_VERTEX_ARRAY_STRIDE:
+        case GL_NORMAL_ARRAY_STRIDE:
+        case GL_COLOR_ARRAY_STRIDE:
+        case GL_TEXTURE_COORD_ARRAY_STRIDE:
+            *params = ptr ? ptr->getStride() : 0;
+            break;
+
+        case GL_VERTEX_ARRAY_SIZE:
+        case GL_COLOR_ARRAY_SIZE:
+        case GL_TEXTURE_COORD_ARRAY_SIZE:
+            *params = ptr ? ptr->getSize() : 0;
+            break;
+
+        case GL_VERTEX_ARRAY_TYPE:
+        case GL_NORMAL_ARRAY_TYPE:
+        case GL_COLOR_ARRAY_TYPE:
+        case GL_TEXTURE_COORD_ARRAY_TYPE:
+            *params = ptr ? ptr->getType() : 0;
+            break;
+    }
+
+    return true;
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
index 7ba4967..2bc08c0 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
@@ -44,6 +44,11 @@
     virtual const GLESpointer* getPointer(GLenum arrType);
     int  getMaxTexUnits();
 
+    virtual bool glGetIntegerv(GLenum pname, GLint *params);
+    virtual bool glGetBooleanv(GLenum pname, GLboolean *params);
+    virtual bool glGetFloatv(GLenum pname, GLfloat *params);
+    virtual bool glGetFixedv(GLenum pname, GLfixed *params);
+  
     ~GLEScmContext();
 protected:
 
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 27c9c8c..41ad175 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -662,6 +662,11 @@
 GL_API void GL_APIENTRY  glGetBooleanv( GLenum pname, GLboolean *params) {
     GET_CTX()
 
+    if(ctx->glGetBooleanv(pname, params))
+    {
+        return;
+    }
+
     GLint i;
 
     switch(pname)
@@ -734,6 +739,11 @@
 GL_API void GL_APIENTRY  glGetFixedv( GLenum pname, GLfixed *params) {
     GET_CTX()
 
+    if(ctx->glGetFixedv(pname, params))
+    {
+        return;
+    }
+
     size_t nParams = glParamSize(pname);
     GLfloat fParams[16];
     GLint i;
@@ -782,6 +792,11 @@
 GL_API void GL_APIENTRY  glGetFloatv( GLenum pname, GLfloat *params) {
     GET_CTX()
 
+    if(ctx->glGetFloatv(pname, params))
+    {
+        return;
+    }
+
     GLint i;
 
     switch(pname)
@@ -819,6 +834,12 @@
 
 GL_API void GL_APIENTRY  glGetIntegerv( GLenum pname, GLint *params) {
     GET_CTX()
+
+    if(ctx->glGetIntegerv(pname, params))
+    {
+        return;
+    }
+
     switch(pname)
     {
     case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
@@ -912,7 +933,12 @@
     GET_CTX()
     const GLESpointer* p = ctx->getPointer(pname);
     if(p) {
-        *params = const_cast<void *>( p->getArrayData());
+        if(p->isVBO())
+        {
+            *params = (void*)(p->getBufferOffset());
+        }else{
+            *params = const_cast<void *>( p->getArrayData());
+        }
     } else {
         ctx->setGLerror(GL_INVALID_ENUM);
     }
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
index 72089d2..51cdc6f 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
@@ -163,7 +163,7 @@
     if(bufferName) {
         unsigned int offset = reinterpret_cast<unsigned int>(data);
         GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr());
-        m_map[arrType]->setBuffer(size,type,stride,vbo,offset,normalize);
+        m_map[arrType]->setBuffer(size,type,stride,vbo,bufferName,offset,normalize);
         return  static_cast<const unsigned char*>(vbo->getData()) +  offset;
     }
     m_map[arrType]->setArray(size,type,stride,data,normalize);
@@ -514,3 +514,60 @@
     return false;
 }
 
+bool GLEScontext::glGetBooleanv(GLenum pname, GLboolean *params)
+{
+    GLint iParam;
+
+    if(glGetIntegerv(pname, &iParam))
+    {
+        *params = (iParam != 0);
+        return true;
+    }
+
+    return false;
+}
+
+bool GLEScontext::glGetFixedv(GLenum pname, GLfixed *params)
+{
+    GLint iParam;
+
+    if(glGetIntegerv(pname, &iParam))
+    {
+        *params = I2X(iParam);
+        return true;
+    }
+
+    return false;
+}
+
+bool GLEScontext::glGetFloatv(GLenum pname, GLfloat *params)
+{
+    GLint iParam;
+
+    if(glGetIntegerv(pname, &iParam))
+    {
+        *params = (GLfloat)iParam;
+        return true;
+    }
+
+    return false;
+}
+
+bool GLEScontext::glGetIntegerv(GLenum pname, GLint *params)
+{
+    switch(pname)
+    {
+        case GL_ARRAY_BUFFER_BINDING:
+            *params = m_arrayBuffer;
+            break;
+
+        case GL_ELEMENT_ARRAY_BUFFER_BINDING:
+            *params = m_elementBuffer;
+            break;
+
+        default:
+            return false;
+    }
+
+    return true;
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp
index a68f8ad..b7fe9b0 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp
@@ -23,6 +23,7 @@
                            m_normalize(false),
                            m_data(NULL),
                            m_buffer(NULL),
+                           m_bufferName(0),
                            m_buffOffset(0),
                            m_isVBO(false){};
 
@@ -55,6 +56,10 @@
     m_data = getBufferData();
 }
 
+GLuint GLESpointer::getBufferName() const {
+    return m_bufferName;
+}
+
 unsigned int GLESpointer::getBufferOffset() const {
 
     return  m_buffOffset;
@@ -82,16 +87,18 @@
     m_stride = stride;
     m_data   = data;
     m_buffer = NULL;
+    m_bufferName = 0;
     m_normalize = normalize;
     m_isVBO = false;
 }
 
-void GLESpointer::setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,int offset,bool normalize) {
+void GLESpointer::setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,GLuint bufferName,int offset,bool normalize) {
     m_size   = size;
     m_type   = type;
     m_stride = stride;
     m_data   = NULL;
     m_buffer = buf;
+    m_bufferName = bufferName;
     m_buffOffset = offset;
     m_normalize = normalize;
     m_isVBO = true;
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
index 1ed7f2c..03efdd7 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -134,6 +134,10 @@
     static int getMaxTexSize(){return s_glSupport.maxTexSize;}
     static Version glslVersion(){return s_glSupport.glslVersion;}
 
+    virtual bool glGetIntegerv(GLenum pname, GLint *params);
+    virtual bool glGetBooleanv(GLenum pname, GLboolean *params);
+    virtual bool glGetFloatv(GLenum pname, GLfloat *params);
+    virtual bool glGetFixedv(GLenum pname, GLfixed *params);
 
 protected:
     virtual bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id) = 0;
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h
index 7f3b396..b39c103 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h
@@ -29,13 +29,14 @@
     GLsizei       getStride() const;
     const GLvoid* getArrayData() const;
     GLvoid*       getBufferData() const;
+    GLuint        getBufferName() const;
     const GLvoid* getData() const;
     unsigned int  getBufferOffset() const;
     void          redirectPointerData();
     void          getBufferConversions(const RangeList& rl,RangeList& rlOut);
     bool          bufferNeedConversion(){ return !m_buffer->fullyConverted();}
     void          setArray (GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize = false);
-    void          setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,int offset,bool normalize = false);
+    void          setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,GLuint bufferName,int offset,bool normalize = false);
     bool          isEnable() const;
     bool          isNormalize() const;
     bool          isVBO() const;
@@ -49,6 +50,7 @@
     bool          m_normalize;
     const GLvoid* m_data;
     GLESbuffer*   m_buffer;
+    GLuint        m_bufferName;
     unsigned int  m_buffOffset;
     bool          m_isVBO;
 };