Emulator opengl - Opengl ES 1.1 encoder

This change the opengl target side encoder library (libGLESv1_enc)
The library includes api definition files for 'emugen' code generation
tool and a serrounding code to handle opengl specific sematics (such as client state)
tracking

Change-Id: I8708b945c8c9c7fbe06147b703bdee27a576c7a0
diff --git a/tools/emulator/opengl/system/Android.mk b/tools/emulator/opengl/system/Android.mk
index cc5a5da..7125f0a 100644
--- a/tools/emulator/opengl/system/Android.mk
+++ b/tools/emulator/opengl/system/Android.mk
@@ -31,3 +31,47 @@
 # LOCAL_CFLAGS := -O0 -g
 include $(BUILD_HOST_STATIC_LIBRARY)
 
+
+### GLESv1_enc Encoder ###########################################
+include $(CLEAR_VARS)
+
+
+LOCAL_SRC_FILES := \
+        GLESv1_enc/GLEncoder.cpp \
+        GLESv1_enc/GLEncoderUtils.cpp
+
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libGLESv1_enc
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+glesv1_intermediates := $(local-intermediates-dir)
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS += -DLOG_TAG=\"egl_GLESv1_enc\"
+LOCAL_C_INCLUDES +=  \
+    $(LOCAL_PATH)/OpenglCodecCommon \
+    $(LOCAL_PATH)/GLESv1_enc $(glesv1_intermediates)
+
+LOCAL_STATIC_LIBRARIES := \
+        libOpenglCodecCommon
+LOCAL_SHARED_LIBRARIES := libcutils
+
+EMUGEN := $(HOST_OUT_EXECUTABLES)/emugen
+
+GEN_GL := \
+	$(glesv1_intermediates)/gl_entry.cpp \
+	$(glesv1_intermediates)/gl_enc.cpp \
+	$(glesv1_intermediates)/gl_enc.h
+
+$(GEN_GL) : PRIVATE_PATH := $(LOCAL_PATH)
+$(GEN_GL) : PRIVATE_CUSTOM_TOOL := \
+        $(EMUGEN) -E $(glesv1_intermediates) -i $(PRIVATE_PATH)/GLESv1_enc gl
+$(GEN_GL) : $(EMUGEN) \
+        $(LOCAL_PATH)/GLESv1_enc/gl.attrib \
+        $(LOCAL_PATH)/GLESv1_enc/gl.in \
+        $(LOCAL_PATH)/GLESv1_enc/gl.types
+	$(transform-generated-source)
+
+LOCAL_GENERATED_SOURCES += $(GEN_GL)
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.cpp b/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.cpp
new file mode 100644
index 0000000..01656cf
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.cpp
@@ -0,0 +1,419 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include "GLEncoder.h"
+#include "glUtils.h"
+#include "FixedBuffer.h"
+
+#include <cutils/log.h>
+#include <assert.h>
+
+static GLubyte *gVendorString= (GLubyte *) "Android";
+static GLubyte *gRendererString= (GLubyte *) "Android HW-GLES 1.0";
+static GLubyte *gVersionString= (GLubyte *) "OpenGL ES-CM 1.0";
+static GLubyte *gExtensionsString= (GLubyte *) ""; // no extensions at this point;
+
+
+GLint * GLEncoder::getCompressedTextureFormats()
+{
+    if (m_compressedTextureFormats == NULL) {
+        this->glGetIntegerv(this, GL_NUM_COMPRESSED_TEXTURE_FORMATS,
+                            &m_num_compressedTextureFormats);
+        if (m_num_compressedTextureFormats > 0) {
+            // get number of texture formats;
+            m_compressedTextureFormats = new GLint[m_num_compressedTextureFormats];
+            this->glGetCompressedTextureFormats(this, m_num_compressedTextureFormats, m_compressedTextureFormats);
+        }
+    }
+    return m_compressedTextureFormats;
+}
+
+
+void GLEncoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    if (param == GL_COMPRESSED_TEXTURE_FORMATS) {
+        GLint * compressedTextureFormats = ctx->getCompressedTextureFormats();
+        if (ctx->m_num_compressedTextureFormats > 0 && compressedTextureFormats != NULL) {
+            memcpy(ptr, compressedTextureFormats, ctx->m_num_compressedTextureFormats * sizeof(GLint));
+        }
+    } else {
+        ctx->m_glGetIntegerv_enc(self, param, ptr);
+    }
+}
+
+void GLEncoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    if (param == GL_COMPRESSED_TEXTURE_FORMATS) {
+        GLint * compressedTextureFormats = ctx->getCompressedTextureFormats();
+        if (ctx->m_num_compressedTextureFormats > 0 && compressedTextureFormats != NULL) {
+            for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) {
+                ptr[i] = (GLfloat) compressedTextureFormats[i];
+            }
+        }
+    } else {
+        ctx->m_glGetFloatv_enc(self, param, ptr);
+    }
+}
+
+void GLEncoder::s_glGetFixedv(void *self, GLenum param, GLfixed *ptr)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    if (param == GL_COMPRESSED_TEXTURE_FORMATS) {
+        GLint * compressedTextureFormats = ctx->getCompressedTextureFormats();
+        if (ctx->m_num_compressedTextureFormats > 0 && compressedTextureFormats != NULL) {
+            for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) {
+                ptr[i] =  compressedTextureFormats[i] << 16;
+            }
+        }
+    } else {
+        ctx->m_glGetFixedv_enc(self, param, ptr);
+    }
+}
+
+void GLEncoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    if (param == GL_COMPRESSED_TEXTURE_FORMATS) {
+        // ignore the command, although we should have generated a GLerror;
+    } else {
+        ctx->m_glGetBooleanv_enc(self, param, ptr);
+    }
+}
+
+void GLEncoder::s_glFlush(void *self)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    ctx->m_glFlush_enc(self);
+    ctx->m_stream->flush();
+}
+
+GLubyte *GLEncoder::s_glGetString(void *self, GLenum name)
+{
+    GLubyte *retval =  (GLubyte *) "";
+    switch(name) {
+    case GL_VENDOR:
+        retval = gVendorString;
+        break;
+    case GL_RENDERER:
+        retval = gRendererString;
+        break;
+    case GL_VERSION:
+        retval = gVersionString;
+        break;
+    case GL_EXTENSIONS:
+        retval = gExtensionsString;
+        break;
+    }
+    return retval;
+}
+
+void GLEncoder::s_glPixelStorei(void *self, GLenum param, GLint value)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    ctx->m_glPixelStorei_enc(ctx, param, value);
+    assert(m_state != NULL);
+    ctx->m_state->setPixelStore(param, value);
+}
+
+void GLEncoder::s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(m_state != NULL);
+    ctx->m_state->setState(GLClientState::VERTEX_LOCATION, size, type, stride, data);
+}
+
+void GLEncoder::s_glNormalPointer(void *self, GLenum type, GLsizei stride, void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(m_state != NULL);
+    ctx->m_state->setState(GLClientState::NORMAL_LOCATION, 3, type, stride, data);
+}
+
+void GLEncoder::s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(m_state != NULL);
+    ctx->m_state->setState(GLClientState::COLOR_LOCATION, size, type, stride, data);
+}
+
+void GLEncoder::s_glPointsizePointer(void *self, GLenum type, GLsizei stride, void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(m_state != NULL);
+    ctx->m_state->setState(GLClientState::POINTSIZE_LOCATION, 1, type, stride, data);
+}
+
+void GLEncoder::s_glClientActiveTexture(void *self, GLenum texture)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(m_state != NULL);
+    ctx->m_state->setActiveTexture(texture - GL_TEXTURE0);
+}
+
+void GLEncoder::s_glTexcoordPointer(void *self, int size, GLenum type, GLsizei stride, void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(m_state != NULL);
+    int loc = ctx->m_state->getLocation(GL_TEXTURE_COORD_ARRAY);
+    ctx->m_state->setState(loc, size, type, stride, data);
+}
+
+void GLEncoder::s_glEnableClientState(void *self, GLenum state)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    assert(m_state != NULL);
+    int loc = ctx->m_state->getLocation(state);
+    ctx->m_state->enable(loc, 1);
+}
+
+void GLEncoder::s_glDisableClientState(void *self, GLenum state)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    assert(m_state != NULL);
+    int loc = ctx->m_state->getLocation(state);
+    ctx->m_state->enable(loc, 0);
+}
+
+void GLEncoder::s_glBindBuffer(void *self, GLenum target, GLuint id)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    assert(m_state != NULL);
+    ctx->m_state->bindBuffer(target, id);
+    // TODO set error state if needed;
+    ctx->m_glBindBuffer_enc(self, target, id);
+}
+
+void GLEncoder::sendVertexData(unsigned int first, unsigned int count)
+{
+    assert(m_state != NULL);
+    for (int i = 0; i < GLClientState::LAST_LOCATION; i++) {
+        bool enableDirty;
+        const GLClientState::VertexAttribState *state = m_state->getStateAndEnableDirty(i, &enableDirty);
+
+        // do not process if state not valid
+        if (!state) continue;
+
+        // do not send disable state if state was already disabled
+        if (!enableDirty && !state->enabled) continue;
+
+        if ( i >= GLClientState::TEXCOORD0_LOCATION &&
+            i <= GLClientState::TEXCOORD7_LOCATION ) {
+            m_glClientActiveTexture_enc(this, GL_TEXTURE0 + i - GLClientState::TEXCOORD0_LOCATION);
+        }
+
+        if (state->enabled) {
+
+            if (enableDirty)
+                m_glEnableClientState_enc(this, state->glConst);
+
+            unsigned int datalen = state->elementSize * count;
+            int stride = state->stride;
+            if (stride == 0) stride = state->elementSize;
+            int firstIndex = stride * first;
+
+            if (state->bufferObject == 0) {
+
+                switch(i) {
+                case GLClientState::VERTEX_LOCATION:
+                    this->glVertexPointerData(this, state->size, state->type, state->stride,
+                                              (unsigned char *)state->data + firstIndex, datalen);
+                    break;
+                case GLClientState::NORMAL_LOCATION:
+                    this->glNormalPointerData(this, state->type, state->stride,
+                                              (unsigned char *)state->data + firstIndex, datalen);
+                    break;
+                case GLClientState::COLOR_LOCATION:
+                    this->glColorPointerData(this, state->size, state->type, state->stride,
+                                             (unsigned char *)state->data + firstIndex, datalen);
+                    break;
+                case GLClientState::TEXCOORD0_LOCATION:
+                case GLClientState::TEXCOORD1_LOCATION:
+                case GLClientState::TEXCOORD2_LOCATION:
+                case GLClientState::TEXCOORD3_LOCATION:
+                case GLClientState::TEXCOORD4_LOCATION:
+                case GLClientState::TEXCOORD5_LOCATION:
+                case GLClientState::TEXCOORD6_LOCATION:
+                case GLClientState::TEXCOORD7_LOCATION:
+                    this->glTexCoordPointerData(this, i - GLClientState::TEXCOORD0_LOCATION, state->size, state->type, state->stride,
+                                                (unsigned char *)state->data + firstIndex, datalen);
+                    break;
+                case GLClientState::POINTSIZE_LOCATION:
+                    this->glPointSizePointerData(this, state->type, state->stride,
+                                                 (unsigned char *) state->data + firstIndex, datalen);
+                    break;
+                }
+            } else {
+                this->glBindBuffer(this, GL_ARRAY_BUFFER, state->bufferObject);
+
+                switch(i) {
+                case GLClientState::VERTEX_LOCATION:
+                    this->glVertexPointerOffset(this, state->size, state->type, state->stride,
+                                                (GLuint)state->data + firstIndex);
+                    break;
+                case GLClientState::NORMAL_LOCATION:
+                    this->glNormalPointerOffset(this, state->type, state->stride,
+                                                (GLuint) state->data + firstIndex);
+                    break;
+                case GLClientState::POINTSIZE_LOCATION:
+                    this->glPointSizePointerOffset(this, state->type, state->stride,
+                                                   (GLuint) state->data + firstIndex);
+                    break;
+                case GLClientState::COLOR_LOCATION:
+                    this->glColorPointerOffset(this, state->size, state->type, state->stride,
+                                               (GLuint) state->data + firstIndex);
+                    break;
+                case GLClientState::TEXCOORD0_LOCATION:
+                case GLClientState::TEXCOORD1_LOCATION:
+                case GLClientState::TEXCOORD2_LOCATION:
+                case GLClientState::TEXCOORD3_LOCATION:
+                case GLClientState::TEXCOORD4_LOCATION:
+                case GLClientState::TEXCOORD5_LOCATION:
+                case GLClientState::TEXCOORD6_LOCATION:
+                case GLClientState::TEXCOORD7_LOCATION:
+                    this->glTexCoordPointerOffset(this, state->size, state->type, state->stride,
+                                                  (GLuint) state->data + firstIndex);
+                    break;
+                }
+            }
+        } else {
+            this->m_glDisableClientState_enc(this, state->glConst);
+        }
+    }
+}
+
+void GLEncoder::s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+
+    ctx->sendVertexData(first, count);
+    ctx->m_glDrawArrays_enc(ctx, mode, /*first*/ 0, count);
+}
+
+void GLEncoder::s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, void *indices)
+{
+
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(m_state != NULL);
+
+    bool has_immediate_arrays = false;
+    bool has_indirect_arrays = false;
+
+    for (int i = 0; i < GLClientState::LAST_LOCATION; i++) {
+        const GLClientState::VertexAttribState *state = ctx->m_state->getState(i);
+        if (state->enabled) {
+            if (state->bufferObject != 0) {
+                has_indirect_arrays = true;
+            } else {
+                has_immediate_arrays = true;
+            }
+        }
+    }
+
+    if (!has_immediate_arrays && !has_indirect_arrays) {
+        LOGE("glDrawElements: no data bound to the command - ignoring\n");
+        return;
+    }
+
+    if (ctx->m_state->currentIndexVbo() != 0) {
+        if (!has_immediate_arrays) {
+            ctx->sendVertexData(0, count);
+            ctx->glDrawElementsOffset(ctx, mode, count, type, (GLuint)indices);
+        } else {
+            LOGE("glDrawElements: indirect index arrays, with immidate-mode data array is not supported\n");
+        }
+    } else {
+        void *adjustedIndices = indices;
+        int minIndex = 0, maxIndex = 0;
+
+        switch(type) {
+        case GL_BYTE:
+        case GL_UNSIGNED_BYTE:
+            ctx->minmax<unsigned char>((unsigned char *)indices, count, &minIndex, &maxIndex);
+            if (minIndex != 0) {
+                adjustedIndices =  ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                ctx->shiftIndices<unsigned char>((unsigned char *)indices,
+                                                 (unsigned char *)adjustedIndices,
+                                                 count, -minIndex);
+            }
+            break;
+        case GL_SHORT:
+        case GL_UNSIGNED_SHORT:
+            ctx->minmax<unsigned short>((unsigned short *)indices, count, &minIndex, &maxIndex);
+            if (minIndex != 0) {
+                adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                ctx->shiftIndices<unsigned short>((unsigned short *)indices,
+                                                 (unsigned short *)adjustedIndices,
+                                                 count, -minIndex);
+            }
+            break;
+        default:
+            LOGE("unsupported index buffer type %d\n", type);
+        }
+        if (has_indirect_arrays || 1) {
+            ctx->sendVertexData(minIndex, maxIndex - minIndex + 1);
+            ctx->glDrawElementsData(ctx, mode, count, type, adjustedIndices,
+                                      count * glSizeof(type));
+            // XXX - OPTIMIZATION (see the other else branch) should be implemented
+            if(!has_indirect_arrays) {
+                LOGD("unoptimized drawelements !!!\n");
+            }
+        } else {
+            // we are all direct arrays and immidate mode index array -
+            // rebuild the arrays and the index array;
+            LOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n");
+        }
+    }
+}
+
+GLEncoder::GLEncoder(IOStream *stream) : gl_encoder_context_t(stream)
+{
+    m_state = NULL;
+    m_compressedTextureFormats = NULL;
+    // overrides;
+    m_glFlush_enc = set_glFlush(s_glFlush);
+    m_glPixelStorei_enc = set_glPixelStorei(s_glPixelStorei);
+    m_glVertexPointer_enc = set_glVertexPointer(s_glVertexPointer);
+    m_glNormalPointer_enc = set_glNormalPointer(s_glNormalPointer);
+    m_glColorPointer_enc = set_glColorPointer(s_glColorPointer);
+    m_glPointSizePointerOES_enc = set_glPointSizePointerOES(s_glPointsizePointer);
+    m_glClientActiveTexture_enc = set_glClientActiveTexture(s_glClientActiveTexture);
+    m_glTexCoordPointer_enc = set_glTexCoordPointer(s_glTexcoordPointer);
+
+    m_glGetIntegerv_enc = set_glGetIntegerv(s_glGetIntegerv);
+    m_glGetFloatv_enc = set_glGetFloatv(s_glGetFloatv);
+    m_glGetBooleanv_enc = set_glGetBooleanv(s_glGetBooleanv);
+    m_glGetFixedv_enc = set_glGetFixedv(s_glGetFixedv);
+
+    m_glBindBuffer_enc = set_glBindBuffer(s_glBindBuffer);
+    m_glEnableClientState_enc = set_glEnableClientState(s_glEnableClientState);
+    m_glDisableClientState_enc = set_glDisableClientState(s_glDisableClientState);
+    m_glDrawArrays_enc = set_glDrawArrays(s_glDrawArrays);
+    m_glDrawElements_enc = set_glDrawElements(s_glDrawElements);
+    set_glGetString(s_glGetString);
+
+}
+
+GLEncoder::~GLEncoder()
+{
+    delete m_compressedTextureFormats;
+}
+
+size_t GLEncoder::pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack)
+{
+    assert(m_state != NULL);
+    return m_state->pixelDataSize(width, height, format, type, pack);
+}
diff --git a/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.h b/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.h
new file mode 100644
index 0000000..71c6089
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.h
@@ -0,0 +1,114 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef _GL_ENCODER_H_
+#define _GL_ENCODER_H_
+
+#include "gl_enc.h"
+#include "GLClientState.h"
+#include "FixedBuffer.h"
+
+class GLEncoder : public gl_encoder_context_t {
+
+public:
+    GLEncoder(IOStream *stream);
+    virtual ~GLEncoder();
+    void setClientState(GLClientState *state) {
+        m_state = state;
+    }
+    void flush() { m_stream->flush(); }
+    size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack);
+private:
+
+    GLClientState *m_state;
+    FixedBuffer m_fixedBuffer;
+    GLint *m_compressedTextureFormats;
+    GLint m_num_compressedTextureFormats;
+
+    GLint *getCompressedTextureFormats();
+    // original functions;
+    glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
+    glGetFloatv_client_proc_t m_glGetFloatv_enc;
+    glGetFixedv_client_proc_t m_glGetFixedv_enc;
+    glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
+
+    glPixelStorei_client_proc_t m_glPixelStorei_enc;
+    glVertexPointer_client_proc_t m_glVertexPointer_enc;
+    glNormalPointer_client_proc_t m_glNormalPointer_enc;
+    glColorPointer_client_proc_t m_glColorPointer_enc;
+    glPointSizePointerOES_client_proc_t m_glPointSizePointerOES_enc;
+    glTexCoordPointer_client_proc_t m_glTexCoordPointer_enc;
+    glClientActiveTexture_client_proc_t m_glClientActiveTexture_enc;
+
+    glBindBuffer_client_proc_t m_glBindBuffer_enc;
+    glEnableClientState_client_proc_t m_glEnableClientState_enc;
+    glDisableClientState_client_proc_t m_glDisableClientState_enc;
+    glDrawArrays_client_proc_t m_glDrawArrays_enc;
+    glDrawElements_client_proc_t m_glDrawElements_enc;
+    glFlush_client_proc_t m_glFlush_enc;
+
+    // statics
+    static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
+    static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
+    static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
+    static void s_glGetFixedv(void *self, GLenum pname, GLfixed *ptr);
+
+    static void s_glFlush(void * self);
+    static GLubyte * s_glGetString(void *self, GLenum name);
+    static void s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, void *data);
+    static void s_glNormalPointer(void *self, GLenum type, GLsizei stride, void *data);
+    static void s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, void *data);
+    static void s_glPointsizePointer(void *self, GLenum type, GLsizei stride, void *data);
+    static void s_glClientActiveTexture(void *self, GLenum texture);
+    static void s_glTexcoordPointer(void *self, int size, GLenum type, GLsizei stride, void *data);
+    static void s_glDisableClientState(void *self, GLenum state);
+    static void s_glEnableClientState(void *self, GLenum state);
+    static void s_glBindBuffer(void *self, GLenum target, GLuint id);
+    static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
+    static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, void *indices);
+    static void s_glPixelStorei(void *self, GLenum param, GLint value);
+    void sendVertexData(unsigned first, unsigned count);
+
+    template <class T> void minmax(T *indices, int count, int *min, int *max) {
+        *min = -1;
+        *max = -1;
+        T *ptr = indices;
+        for (int i = 0; i < count; i++) {
+            if (*min == -1 || *ptr < *min) *min = *ptr;
+            if (*max == -1 || *ptr > *max) *max = *ptr;
+            ptr++;
+        }
+    }
+
+    template <class T> void shiftIndices(T *indices, int count,  int offset) {
+        T *ptr = indices;
+        for (int i = 0; i < count; i++) {
+            *ptr += offset;
+            ptr++;
+        }
+    }
+
+
+    template <class T> void shiftIndices(T *src, T *dst, int count, int offset)
+    {
+        for (int i = 0; i < count; i++) {
+            *dst = *src + offset;
+            dst++;
+            src++;
+        }
+    }
+
+};
+#endif
diff --git a/tools/emulator/opengl/system/GLESv1_enc/GLEncoderUtils.cpp b/tools/emulator/opengl/system/GLESv1_enc/GLEncoderUtils.cpp
new file mode 100644
index 0000000..7866d53
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/GLEncoderUtils.cpp
@@ -0,0 +1,24 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include "GLEncoder.h"
+
+size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    return ctx->pixelDataSize(width, height, format, type, pack);
+}
diff --git a/tools/emulator/opengl/system/GLESv1_enc/GLEncoderUtils.h b/tools/emulator/opengl/system/GLESv1_enc/GLEncoderUtils.h
new file mode 100644
index 0000000..1d0c847
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/GLEncoderUtils.h
@@ -0,0 +1,22 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GL_ENCODER_UTILS_H
+#define GL_ENCLODER_UTILS_H
+
+extern "C" {
+    size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack);
+};
+#endif
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl.addon b/tools/emulator/opengl/system/GLESv1_enc/gl.addon
new file mode 100644
index 0000000..2331f87
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl.addon
@@ -0,0 +1,15 @@
+GL_ENTRY(void, glVertexPointerOffset, GLint size, GLenum type, GLsizei stride,  GLuint offset)
+GL_ENTRY(void, glColorPointerOffset, GLint size, GLenum type, GLsizei stride,  GLuint offset)
+GL_ENTRY(void, glNormalPointerOffset, GLenum type, GLsizei stride,  GLuint offset)
+GL_ENTRY(void, glPointSizePointerOffset, GLenum type, GLsizei stride,  GLuint offset)
+GL_ENTRY(void, glTexCoordPointerOffset, GLint size, GLenum type, GLsizei stride,  GLuint offset)
+
+GL_ENTRY(void, glVertexPointerData, GLint size, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+GL_ENTRY(void, glColorPointerData, GLint size, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+GL_ENTRY(void, glNormalPointerData, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+GL_ENTRY(void, glTexCoordPointerData, GLint size, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+GL_ENTRY(void, glPointSizePointerData, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+
+GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset);
+GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen);
+
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl.attrib b/tools/emulator/opengl/system/GLESv1_enc/gl.attrib
new file mode 100644
index 0000000..6245dc5
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl.attrib
@@ -0,0 +1,476 @@
+GLOBAL
+	base_opcode 1024
+	encoder_headers "glUtils.h" "GLEncoderUtils.h"
+	
+#void glClipPlanef(GLenum plane, GLfloat *equation)
+glClipPlanef
+	len equation (4 * sizeof(float))
+
+#void glFogfv(GLenum pname, GLfloat *params)
+glFogfv
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glGetFloatv(GLenum pname, GLfloat *params)
+glGetFloatv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glGetLightfv(GLenum light, GLenum pname, GLfloat *params)
+glGetLightfv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
+glGetMaterialfv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params)
+glGetTexEnvfv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
+glGetTexParameterfv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glLightModelfv(GLenum pname, GLfloat *params)
+glLightModelfv
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glLightfv(GLenum light, GLenum pname, GLfloat *params)
+glLightfv
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glLoadMatrixf(GLfloat *m)
+glLoadMatrixf
+	len m (16 * sizeof(GLfloat))
+
+#void glMaterialfv(GLenum face, GLenum pname, GLfloat *params)
+glMaterialfv
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glMultMatrixf(GLfloat *m)
+glMultMatrixf
+	len m (16 * sizeof(GLfloat))
+
+#void glPointParameterfv(GLenum pname, GLfloat *params)
+glPointParameterfv
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
+glTexEnvfv
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
+glTexParameterfv
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage)
+glBufferData
+	len data size
+
+#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)
+glBufferSubData
+	len data size
+
+#void glClipPlanex(GLenum plane, GLfixed *equation)
+glClipPlanex
+	len equation (4 * sizeof(GLfixed))
+
+#void glColorPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
+#we treat the pointer as offset to a VBO
+glColorPointer
+	len pointer (sizeof(unsigned int))
+	flag unsupported
+
+#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data)
+glCompressedTexImage2D
+	len data imageSize
+
+#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data)
+glCompressedTexSubImage2D
+	len data imageSize
+
+#void glDeleteBuffers(GLsizei n, GLuint *buffers)
+glDeleteBuffers
+	len buffers (n * sizeof(GLuint))
+
+#void glDeleteTextures(GLsizei n, GLuint *textures)
+glDeleteTextures
+	len textures (n * sizeof(GLuint))
+
+#this function is marked as unsupported - it shouldn't be called directly
+#instead it translated into - glDrawDirectElements and glDrawIndirectElements
+#void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices)
+glDrawElements
+	flag unsupported
+
+
+#void glFogxv(GLenum pname, GLfixed *params)
+glFogxv
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetBooleanv(GLenum pname, GLboolean *params)
+glGetBooleanv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLboolean))
+
+#void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
+glGetBufferParameteriv
+	len params (sizeof(GLint))
+
+#void glGenBuffers(GLsizei n, GLuint *buffers)
+glGenBuffers
+	len buffers (n * sizeof(GLuint))
+	dir buffers out
+
+#void glGenTextures(GLsizei n, GLuint *textures)
+glGenTextures
+	len textures (n * sizeof(GLuint))
+	dir textures out
+
+#void glGetFixedv(GLenum pname, GLfixed *params)
+glGetFixedv
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetIntegerv(GLenum pname, GLint *params)
+glGetIntegerv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glGetLightxv(GLenum light, GLenum pname, GLfixed *params)
+glGetLightxv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params)
+glGetMaterialxv
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetPointerv(GLenum pname, void **params)
+glGetPointerv
+	flag unsupported
+
+#GLubyte* glGetString(GLenum name)
+glGetString
+
+#void glGetTexEnviv(GLenum env, GLenum pname, GLint *params)
+glGetTexEnviv
+#FIXME
+	len params (4)
+
+#void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params)
+glGetTexEnvxv
+#FIXME
+	len params (4)
+
+#void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params)
+glGetTexParameteriv
+	dir params out
+	len params (sizeof(GLint))
+
+#void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
+glGetTexParameterxv
+	dir params out
+	len params (sizeof(GLfixed))
+
+#void glLightModelxv(GLenum pname, GLfixed *params)
+glLightModelxv
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glLightxv(GLenum light, GLenum pname, GLfixed *params)
+glLightxv
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glLoadMatrixx(GLfixed *m)
+glLoadMatrixx
+	len m (16 * sizeof(GLfixed))
+
+#void glMaterialxv(GLenum face, GLenum pname, GLfixed *params)
+glMaterialxv
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glMultMatrixx(GLfixed *m)
+glMultMatrixx
+	len m (16 * sizeof(GLfixed))
+
+#void glNormalPointer(GLenum type, GLsizei stride, GLvoid *pointer)
+#we treat the pointer as an offset to a VBO
+glNormalPointer
+	len pointer (sizeof(unsigned int))
+	flag unsupported
+
+#void glPointParameterxv(GLenum pname, GLfixed *params)
+glPointParameterxv
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+glReadPixels
+	dir pixels out
+	len pixels pixelDataSize(self, width, height, format, type, 0)
+
+#void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
+glTexCoordPointer
+	len pointer (sizeof(unsigned int))
+	flag unsupported
+
+#void glTexEnviv(GLenum target, GLenum pname, GLint *params)
+glTexEnviv
+	len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glTexEnvxv(GLenum target, GLenum pname, GLfixed *params)
+glTexEnvxv
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels)
+glTexImage2D
+	len pixels pixelDataSize(self, width, height, format, type, 1)
+
+#void glTexParameteriv(GLenum target, GLenum pname, GLint *params)
+glTexParameteriv
+	len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
+glTexParameterxv
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+glTexSubImage2D
+#FIXME: this is bad
+	len pixels pixelDataSize(self, width, height, format, type, 1)
+
+#void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
+# we treat the pointer as an offset to a VBO
+glVertexPointer
+	len pointer (sizeof(unsigned int))
+	flag unsupported
+
+#void glPointSizePointerOES(GLenum type, GLsizei stride, GLvoid *pointer)
+glPointSizePointerOES
+	len pointer (sizeof(unsigned int))
+	flag unsupported
+
+#void glGetClipPlanef(...)
+glGetClipPlanef
+	flag unsupported
+#void glGetClipPlanex(...)
+glGetClipPlanex
+	flag unsupported
+
+#void glVertexPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
+glVertexPointerData
+	len data datalen
+	custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
+	flag custom_decoder
+
+#void glColorPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
+glColorPointerData
+	len data datalen
+	flag custom_decoder
+	custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
+
+#void glNormalPointerData(GLenum type, GLsizei stride, void *data, GLuint datalen)
+glNormalPointerData
+	len data datalen
+	flag custom_decoder
+	custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 3, type, stride, datalen)
+
+#void glPointSizePointerData(GLenum type, GLsizei stride, void *data, GLuint datalen)
+glPointSizePointerData
+	len data datalen
+	flag custom_decoder
+	custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 1, type, stride, datalen)
+
+#void glTexCoordPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
+glTexCoordPointerData
+	len data datalen
+	flag custom_decoder
+	custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
+
+glVertexPointerOffset
+	flag custom_decoder
+glNormalPointerOffset
+	flag custom_decoder
+glTexCoordPointerOffset
+	flag custom_decoder
+glPointSizePointerOffset
+	flag custom_decoder
+glColorPointerOffset
+	flag custom_decoder
+
+glDrawElementsData
+	len data datalen
+	flag custom_decoder
+
+glDrawElementsOffset
+	flag custom_decoder
+
+	
+#void glDrawTexsvOES(GLshort *coords)
+glDrawTexsvOES
+	len coords (5 * sizeof(GLshort))
+
+#void glDrawTexivOES(GLint *coords)
+glDrawTexivOES
+	len coords (5 * sizeof(GLint))
+
+#void glDrawTexxvOES(GLfixed *coords)
+glDrawTexxvOES
+	len coords (5 * sizeof(GLfixed))
+
+#void glDrawTexfvOES(GLfloat *coords)
+glDrawTexfvOES
+	len coords (5 * sizeof(GLfloat))
+
+#void glClipPlanexOES(GLenum plane, GLfixed *equation)
+glClipPlanexOES
+	len equation (4 * sizeof(GLfixed))
+
+#void glFogxvOES(GLenum pname, GLfixed *params)
+glFogxvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetFixedvOES(GLenum pname, GLfixed *params)
+glGetFixedvOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetLightxvOES(GLenum light, GLenum pname, GLfixed *params)
+glGetLightxvOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed *params)
+glGetMaterialxvOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed *params)
+glGetTexEnvxvOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params)
+glGetTexParameterxvOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glLightModelxvOES(GLenum pname, GLfixed *params)
+glLightModelxvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glLightxvOES(GLenum light, GLenum pname, GLfixed *params)
+glLightxvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glLoadMatrixxOES(GLfixed *m)
+glLoadMatrixxOES
+	len m (16 * sizeof(GLfixed))
+
+#void glMaterialxvOES(GLenum face, GLenum pname, GLfixed *params)
+glMaterialxvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glMultMatrixxOES(GLfixed *m)
+glMultMatrixxOES
+	len m (16 * sizeof(GLfixed))
+
+#void glPointParameterxvOES(GLenum pname, GLfixed *params)
+glPointParameterxvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glTexEnvxvOES(GLenum target, GLenum pname, GLfixed *params)
+glTexEnvxvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params)
+glTexParameterxvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glDeleteRenderbuffersOES(GLsizei n, GLuint *renderbuffers)
+glDeleteRenderbuffersOES
+	len renderbuffers (n * sizeof(GLuint))
+
+#void glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers)
+glGenRenderbuffersOES
+	len renderbuffers (n * sizeof(GLuint))
+
+#void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint *params)
+glGetRenderbufferParameterivOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glDeleteFramebuffersOES(GLsizei n, GLuint *framebuffers)
+glDeleteFramebuffersOES
+	len framebuffers (n * sizeof(GLuint))
+
+#void glGenFramebuffersOES(GLsizei n, GLuint *framebuffers)
+glGenFramebuffersOES
+	len framebuffers (n * sizeof(GLuint))
+
+#void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params)
+glGetFramebufferAttachmentParameterivOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void* glMapBufferOES(GLenum target, GLenum access)
+glMapBufferOES
+	flag unsupported
+
+#void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
+glMatrixIndexPointerOES
+	flag unsupported
+
+#void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
+glWeightPointerOES
+	flag unsupported
+
+#void glClipPlanefOES(GLenum plane, GLfloat *equation)
+glClipPlanefOES
+	len equation (4 * sizeof(GLfloat))
+
+#void glTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params)
+glTexGenfvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glTexGenivOES(GLenum coord, GLenum pname, GLint *params)
+glTexGenivOES
+	len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params)
+glTexGenxvOES
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params)
+glGetTexGenfvOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glGetTexGenivOES(GLenum coord, GLenum pname, GLint *params)
+glGetTexGenivOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params)
+glGetTexGenxvOES
+	dir params out
+	len params (glUtilsParamSize(pname) * sizeof(GLfixed))
+
+#glGetClipPlanexOES(...)
+glGetClipPlanexOES
+	flag unsupported
+#glGetClipPlanefOES(...)
+glGetClipPlanefOES
+	flag unsupported
+
+#glQueryMatrixxOES
+glQueryMatrixxOES
+	flag unsupported
+
+glGetCompressedTextureFormats
+	dir formats out
+	len formats (count * sizeof(GLint))
+	flag custom_decoder
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl.in b/tools/emulator/opengl/system/GLESv1_enc/gl.in
new file mode 100644
index 0000000..10187b0
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl.in
@@ -0,0 +1,170 @@
+GL_ENTRY(void, glAlphaFunc, GLenum func, GLclampf ref)
+GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+GL_ENTRY(void, glClearDepthf, GLclampf depth)
+GL_ENTRY(void, glClipPlanef, GLenum plane, const GLfloat *equation)
+GL_ENTRY(void, glColor4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar)
+GL_ENTRY(void, glFogf, GLenum pname, GLfloat param)
+GL_ENTRY(void, glFogfv, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glFrustumf, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+GL_ENTRY(void, glGetClipPlanef, GLenum pname, GLfloat eqn[4])
+GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat *params)
+GL_ENTRY(void, glGetLightfv, GLenum light, GLenum pname, GLfloat *params)
+GL_ENTRY(void, glGetMaterialfv, GLenum face, GLenum pname, GLfloat *params)
+GL_ENTRY(void, glGetTexEnvfv, GLenum env, GLenum pname, GLfloat *params)
+GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat *params)
+GL_ENTRY(void, glLightModelf, GLenum pname, GLfloat param)
+GL_ENTRY(void, glLightModelfv, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glLightf, GLenum light, GLenum pname, GLfloat param)
+GL_ENTRY(void, glLightfv, GLenum light, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glLineWidth, GLfloat width)
+GL_ENTRY(void, glLoadMatrixf, const GLfloat *m)
+GL_ENTRY(void, glMaterialf, GLenum face, GLenum pname, GLfloat param)
+GL_ENTRY(void, glMaterialfv, GLenum face, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glMultMatrixf, const GLfloat *m)
+GL_ENTRY(void, glMultiTexCoord4f, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+GL_ENTRY(void, glNormal3f, GLfloat nx, GLfloat ny, GLfloat nz)
+GL_ENTRY(void, glOrthof, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+GL_ENTRY(void, glPointParameterf, GLenum pname, GLfloat param)
+GL_ENTRY(void, glPointParameterfv, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glPointSize, GLfloat size)
+GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units)
+GL_ENTRY(void, glRotatef, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+GL_ENTRY(void, glScalef, GLfloat x, GLfloat y, GLfloat z)
+GL_ENTRY(void, glTexEnvf, GLenum target, GLenum pname, GLfloat param)
+GL_ENTRY(void, glTexEnvfv, GLenum target, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param)
+GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat *params)
+GL_ENTRY(void, glTranslatef, GLfloat x, GLfloat y, GLfloat z)
+GL_ENTRY(void, glActiveTexture, GLenum texture)
+GL_ENTRY(void, glAlphaFuncx, GLenum func, GLclampx ref)
+GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer)
+GL_ENTRY(void, glBindTexture, GLenum target, GLuint texture)
+GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor)
+GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
+GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)
+GL_ENTRY(void, glClear, GLbitfield mask)
+GL_ENTRY(void, glClearColorx, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
+GL_ENTRY(void, glClearDepthx, GLclampx depth)
+GL_ENTRY(void, glClearStencil, GLint s)
+GL_ENTRY(void, glClientActiveTexture, GLenum texture)
+GL_ENTRY(void, glClipPlanex, GLenum plane, const GLfixed *equation)
+GL_ENTRY(void, glColor4ub, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
+GL_ENTRY(void, glColor4x, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+GL_ENTRY(void, glColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data)
+GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data)
+GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(void, glCullFace, GLenum mode)
+GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint *buffers)
+GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint *textures)
+GL_ENTRY(void, glDepthFunc, GLenum func)
+GL_ENTRY(void, glDepthMask, GLboolean flag)
+GL_ENTRY(void, glDepthRangex, GLclampx zNear, GLclampx zFar)
+GL_ENTRY(void, glDisable, GLenum cap)
+GL_ENTRY(void, glDisableClientState, GLenum array)
+GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count)
+GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
+GL_ENTRY(void, glEnable, GLenum cap)
+GL_ENTRY(void, glEnableClientState, GLenum array)
+GL_ENTRY(GLint, glFinish, void)
+GL_ENTRY(void, glFlush, void)
+GL_ENTRY(void, glFogx, GLenum pname, GLfixed param)
+GL_ENTRY(void, glFogxv, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glFrontFace, GLenum mode)
+GL_ENTRY(void, glFrustumx, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean *params)
+GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint *params)
+GL_ENTRY(void, glGetClipPlanex, GLenum pname, GLfixed eqn[4])
+GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint *buffers)
+GL_ENTRY(void, glGenTextures, GLsizei n, GLuint *textures)
+GL_ENTRY(GLenum, glGetError, void)
+GL_ENTRY(void, glGetFixedv, GLenum pname, GLfixed *params)
+GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint *params)
+GL_ENTRY(void, glGetLightxv, GLenum light, GLenum pname, GLfixed *params)
+GL_ENTRY(void, glGetMaterialxv, GLenum face, GLenum pname, GLfixed *params)
+GL_ENTRY(void, glGetPointerv, GLenum pname, GLvoid **params)
+GL_ENTRY(const GLubyte *, glGetString, GLenum name)
+GL_ENTRY(void, glGetTexEnviv, GLenum env, GLenum pname, GLint *params)
+GL_ENTRY(void, glGetTexEnvxv, GLenum env, GLenum pname, GLfixed *params)
+GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint *params)
+GL_ENTRY(void, glGetTexParameterxv, GLenum target, GLenum pname, GLfixed *params)
+GL_ENTRY(void, glHint, GLenum target, GLenum mode)
+GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer)
+GL_ENTRY(GLboolean, glIsEnabled, GLenum cap)
+GL_ENTRY(GLboolean, glIsTexture, GLuint texture)
+GL_ENTRY(void, glLightModelx, GLenum pname, GLfixed param)
+GL_ENTRY(void, glLightModelxv, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glLightx, GLenum light, GLenum pname, GLfixed param)
+GL_ENTRY(void, glLightxv, GLenum light, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glLineWidthx, GLfixed width)
+GL_ENTRY(void, glLoadIdentity, void)
+GL_ENTRY(void, glLoadMatrixx, const GLfixed *m)
+GL_ENTRY(void, glLogicOp, GLenum opcode)
+GL_ENTRY(void, glMaterialx, GLenum face, GLenum pname, GLfixed param)
+GL_ENTRY(void, glMaterialxv, GLenum face, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glMatrixMode, GLenum mode)
+GL_ENTRY(void, glMultMatrixx, const GLfixed *m)
+GL_ENTRY(void, glMultiTexCoord4x, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+GL_ENTRY(void, glNormal3x, GLfixed nx, GLfixed ny, GLfixed nz)
+GL_ENTRY(void, glNormalPointer, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glOrthox, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param)
+GL_ENTRY(void, glPointParameterx, GLenum pname, GLfixed param)
+GL_ENTRY(void, glPointParameterxv, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glPointSizex, GLfixed size)
+GL_ENTRY(void, glPolygonOffsetx, GLfixed factor, GLfixed units)
+GL_ENTRY(void, glPopMatrix, void)
+GL_ENTRY(void, glPushMatrix, void)
+GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+GL_ENTRY(void, glRotatex, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert)
+GL_ENTRY(void, glSampleCoveragex, GLclampx value, GLboolean invert)
+GL_ENTRY(void, glScalex, GLfixed x, GLfixed y, GLfixed z)
+GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(void, glShadeModel, GLenum mode)
+GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask)
+GL_ENTRY(void, glStencilMask, GLuint mask)
+GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass)
+GL_ENTRY(void, glTexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glTexEnvi, GLenum target, GLenum pname, GLint param)
+GL_ENTRY(void, glTexEnvx, GLenum target, GLenum pname, GLfixed param)
+GL_ENTRY(void, glTexEnviv, GLenum target, GLenum pname, const GLint *params)
+GL_ENTRY(void, glTexEnvxv, GLenum target, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
+GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param)
+GL_ENTRY(void, glTexParameterx, GLenum target, GLenum pname, GLfixed param)
+GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint *params)
+GL_ENTRY(void, glTexParameterxv, GLenum target, GLenum pname, const GLfixed *params)
+GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+GL_ENTRY(void, glTranslatex, GLfixed x, GLfixed y, GLfixed z)
+GL_ENTRY(void, glVertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(void, glPointSizePointerOES, GLenum type, GLsizei stride, const GLvoid *pointer)
+
+GL_ENTRY(void, glDrawTexsOES, GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
+GL_ENTRY(void, glDrawTexiOES, GLint x, GLint y, GLint z, GLint width, GLint height)
+GL_ENTRY(void, glDrawTexxOES, GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
+GL_ENTRY(void, glDrawTexsvOES, const GLshort *coords)
+GL_ENTRY(void, glDrawTexivOES, const GLint *coords)
+GL_ENTRY(void, glDrawTexxvOES, const GLfixed *coords)
+GL_ENTRY(void, glDrawTexfOES, GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
+GL_ENTRY(void, glDrawTexfvOES, const GLfloat *coords)
+
+GL_ENTRY(void, glVertexPointerOffset, GLint size, GLenum type, GLsizei stride,  GLuint offset)
+GL_ENTRY(void, glColorPointerOffset, GLint size, GLenum type, GLsizei stride,  GLuint offset)
+GL_ENTRY(void, glNormalPointerOffset, GLenum type, GLsizei stride,  GLuint offset)
+GL_ENTRY(void, glPointSizePointerOffset, GLenum type, GLsizei stride,  GLuint offset)
+GL_ENTRY(void, glTexCoordPointerOffset, GLint size, GLenum type, GLsizei stride,  GLuint offset)
+
+GL_ENTRY(void, glVertexPointerData, GLint size, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+GL_ENTRY(void, glColorPointerData, GLint size, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+GL_ENTRY(void, glNormalPointerData, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+GL_ENTRY(void, glTexCoordPointerData, GLint unit, GLint size, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+GL_ENTRY(void, glPointSizePointerData, GLenum type, GLsizei stride,  void * data, GLuint datalen)
+
+GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset)
+GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen)
+GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats);
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl.types b/tools/emulator/opengl/system/GLESv1_enc/gl.types
new file mode 100644
index 0000000..89a95c1
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl.types
@@ -0,0 +1,17 @@
+GLbitfield 32 0x%08x
+GLboolean 8 %d
+GLclampf 32 %f
+GLclampx 32 0x%08x
+GLeglImageOES 32 0x%08x
+GLenum 32 0x%08x
+GLfixed 32 0x%08x
+GLfloat 32 %f
+GLint 32 %d
+GLintptr 32 0x%08x
+GLshort 16 %d
+GLsizei 32 %d
+GLsizeiptr 32 0x%08x
+GLubyte 8 0x%02x
+GLuint 32 %u
+GLvoid 0 %x
+GLchar 8 %d
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl_types.h b/tools/emulator/opengl/system/GLESv1_enc/gl_types.h
new file mode 100644
index 0000000..af7a70d
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_types.h
@@ -0,0 +1,40 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef __GL_TYPES__H
+#define __GL_TYPES__H
+
+#include <KHR/khrplatform.h>
+typedef void             GLvoid;
+typedef unsigned int     GLenum;
+typedef unsigned char    GLboolean;
+typedef unsigned int     GLbitfield;
+typedef khronos_int8_t   GLbyte;
+typedef short            GLshort;
+typedef int              GLint;
+typedef int              GLsizei;
+typedef khronos_uint8_t  GLubyte;
+typedef unsigned short   GLushort;
+typedef unsigned int     GLuint;
+typedef khronos_float_t  GLfloat;
+typedef khronos_float_t  GLclampf;
+typedef khronos_int32_t  GLfixed;
+typedef khronos_int32_t  GLclampx;
+typedef khronos_intptr_t GLintptr;
+typedef khronos_ssize_t  GLsizeiptr;
+/* JR XXX Treating this as an in handle - is this correct? */
+typedef void * GLeglImageOES;
+
+#endif