Merge "Fix build scripts for vbox_x86 target"
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
index 9f84be1..123e369 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java
@@ -66,7 +66,7 @@
     
     void invokeMethod(Method method, Object[] args) {
         try {
-            mStartForeground.invoke(this, mStartForegroundArgs);
+            method.invoke(this, args);
         } catch (InvocationTargetException e) {
             // Should not happen.
             Log.w("ApiDemos", "Unable to invoke method", e);
@@ -103,15 +103,7 @@
         // If we have the new stopForeground API, then use it.
         if (mStopForeground != null) {
             mStopForegroundArgs[0] = Boolean.TRUE;
-            try {
-                mStopForeground.invoke(this, mStopForegroundArgs);
-            } catch (InvocationTargetException e) {
-                // Should not happen.
-                Log.w("ApiDemos", "Unable to invoke stopForeground", e);
-            } catch (IllegalAccessException e) {
-                // Should not happen.
-                Log.w("ApiDemos", "Unable to invoke stopForeground", e);
-            }
+            invokeMethod(mStopForeground, mStopForegroundArgs);
             return;
         }
         
@@ -130,10 +122,10 @@
                     mStartForegroundSignature);
             mStopForeground = getClass().getMethod("stopForeground",
                     mStopForegroundSignature);
+            return;
         } catch (NoSuchMethodException e) {
             // Running on an older platform.
             mStartForeground = mStopForeground = null;
-            return;
         }
         try {
             mSetForeground = getClass().getMethod("setForeground",
diff --git a/samples/WeatherListWidget/res/xml/widgetinfo.xml b/samples/WeatherListWidget/res/xml/widgetinfo.xml
index a093208..af64106 100644
--- a/samples/WeatherListWidget/res/xml/widgetinfo.xml
+++ b/samples/WeatherListWidget/res/xml/widgetinfo.xml
@@ -19,5 +19,6 @@
   android:minHeight="222dip"
   android:updatePeriodMillis="1800000"
   android:initialLayout="@layout/widget_layout"
+  android:resizeMode="vertical"
   android:previewImage="@drawable/preview">
-</appwidget-provider>
\ No newline at end of file
+</appwidget-provider>
diff --git a/tools/emulator/opengl/host/libs/GLESv1_dec/Android.mk b/tools/emulator/opengl/host/libs/GLESv1_dec/Android.mk
new file mode 100644
index 0000000..c251e4a
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/GLESv1_dec/Android.mk
@@ -0,0 +1,44 @@
+
+LOCAL_PATH := $(call my-dir)
+
+### GLESv1 Decoder ###########################################
+include $(CLEAR_VARS)
+
+emulatorOpengl := $(LOCAL_PATH)/../../..
+EMUGEN := $(HOST_OUT_EXECUTABLES)/emugen
+
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libGLESv1_dec
+
+intermediates := $(local-intermediates-dir)
+
+LOCAL_SRC_FILES := \
+        GLDecoder.cpp
+
+LOCAL_C_INCLUDES += \
+    $(emulatorOpengl)/system/OpenglCodecCommon \
+    $(emulatorOpengl)/system/GLESv1_enc
+
+LOCAL_STATIC_LIBRARIES := \
+        libOpenglCodecCommon \
+        liblog
+
+# XXX - uncomment for debug
+#LOCAL_CFLAGS := -DDEBUG_PRINTOUT -O0 -g
+LOCAL_LDLIBS := -ldl
+
+
+GEN := $(intermediates)/gl_dec.cpp $(intermediates)/gl_dec.h
+
+$(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
+$(GEN) : PRIVATE_CUSTOM_TOOL := $(EMUGEN) -D $(intermediates) -i $(emulatorOpengl)/system/GLESv1_enc gl
+$(GEN) : $(EMUGEN) \
+        $(emulatorOpengl)/system/GLESv1_enc/gl.attrib \
+        $(emulatorOpengl)/system/GLESv1_enc/gl.in \
+        $(emulatorOpengl)/system/GLESv1_enc/gl.types
+	$(transform-generated-source)
+
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/tools/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp b/tools/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp
new file mode 100644
index 0000000..dfa14c9
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp
@@ -0,0 +1,195 @@
+/*
+* 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 "GLDecoder.h"
+#include <string.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+GLDecoder::GLDecoder()
+{
+    m_contextData = NULL;
+    m_glesDso = NULL;
+}
+
+GLDecoder::~GLDecoder()
+{
+    if (m_glesDso != NULL) {
+        dlclose(m_glesDso);
+    }
+}
+
+
+int GLDecoder::initGL(get_proc_func_t getProcFunc, void *getProcFuncData)
+{
+    if (getProcFunc == NULL) {
+        char *libname = GLES_LIBNAME;
+        if (getenv(GLES_LIBNAME_VAR) != NULL) {
+            libname = getenv(GLES_LIBNAME_VAR);
+        }
+
+        m_glesDso = dlopen(libname, RTLD_NOW);
+        if (m_glesDso == NULL) {
+            fprintf(stderr, "Couldn't find %s \n", GLES_LIBNAME);
+            return -1;
+        }
+
+        this->initDispatchByName(s_getProc, this);
+    } else {
+        this->initDispatchByName(getProcFunc, getProcFuncData);
+    }
+
+    set_glGetCompressedTextureFormats(s_glGetCompressedTextureFormats);
+    set_glVertexPointerOffset(s_glVertexPointerOffset);
+    set_glColorPointerOffset(s_glColorPointerOffset);
+    set_glNormalPointerOffset(s_glNormalPointerOffset);
+    set_glTexCoordPointerOffset(s_glTexCoordPointerOffset);
+    set_glPointSizePointerOffset(s_glPointSizePointerOffset);
+
+    set_glVertexPointerData(s_glVertexPointerData);
+    set_glColorPointerData(s_glColorPointerData);
+    set_glNormalPointerData(s_glNormalPointerData);
+    set_glTexCoordPointerData(s_glTexCoordPointerData);
+    set_glPointSizePointerData(s_glPointSizePointerData);
+
+    set_glDrawElementsOffset(s_glDrawElementsOffset);
+    set_glDrawElementsData(s_glDrawElementsData);
+
+    return 0;
+}
+
+void GLDecoder::s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+    ctx->glVertexPointer(size, type, stride, (void *)offset);
+}
+
+void GLDecoder::s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+    ctx->glColorPointer(size, type, stride, (void *)offset);
+}
+
+void GLDecoder::s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+    ctx->glTexCoordPointer(size, type, stride, (void *) offset);
+}
+
+void GLDecoder::s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+    ctx->glNormalPointer(type, stride, (void *)offset);
+}
+
+void GLDecoder::s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+    ctx->glPointSizePointerOES(type, stride, (void *)offset);
+}
+
+#define STORE_POINTER_DATA_OR_ABORT(location)    \
+    if (ctx->m_contextData != NULL) {   \
+        ctx->m_contextData->storePointerData((location), data, datalen); \
+    } else { \
+        return; \
+    }
+
+void GLDecoder::s_glVertexPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+
+    STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::VERTEX_LOCATION);
+
+    ctx->glVertexPointer(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::VERTEX_LOCATION));
+}
+
+void GLDecoder::s_glColorPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+
+    STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::COLOR_LOCATION);
+
+    ctx->glColorPointer(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::COLOR_LOCATION));
+}
+
+void GLDecoder::s_glTexCoordPointerData(void *self, GLint unit, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+    STORE_POINTER_DATA_OR_ABORT((GLDecoderContextData::PointerDataLocation)
+                                (GLDecoderContextData::TEXCOORD0_LOCATION + unit));
+
+    ctx->glTexCoordPointer(size, type, 0,
+                           ctx->m_contextData->pointerData((GLDecoderContextData::PointerDataLocation)
+                                                           (GLDecoderContextData::TEXCOORD0_LOCATION + unit)));
+}
+
+void GLDecoder::s_glNormalPointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+
+    STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::NORMAL_LOCATION);
+
+    ctx->glNormalPointer(type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::NORMAL_LOCATION));
+}
+
+void GLDecoder::s_glPointSizePointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+
+    STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::POINTSIZE_LOCATION);
+
+    ctx->glPointSizePointerOES(type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::POINTSIZE_LOCATION));
+}
+
+void GLDecoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+    ctx->glDrawElements(mode, count, type, (void *)offset);
+}
+
+void GLDecoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen)
+{
+    GLDecoder *ctx = (GLDecoder *)self;
+    ctx->glDrawElements(mode, count, type, data);
+}
+
+void GLDecoder::s_glGetCompressedTextureFormats(void *self, GLint count, GLint *data)
+{
+    GLDecoder *ctx = (GLDecoder *) self;
+    ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, data);
+}
+
+void *GLDecoder::s_getProc(const char *name, void *userData)
+{
+    GLDecoder *ctx = (GLDecoder *)userData;
+
+    if (ctx == NULL || ctx->m_glesDso == NULL) {
+        return NULL;
+    }
+
+    void *func = NULL;
+#ifdef USE_EGL_GETPROCADDRESS
+    func = (void *) eglGetProcAddress(name);
+#endif
+    if (func == NULL) {
+        func = dlsym(ctx->m_glesDso, name);
+    }
+    return func;
+}
diff --git a/tools/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.h b/tools/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.h
new file mode 100644
index 0000000..10e4968
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.h
@@ -0,0 +1,62 @@
+/*
+* 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_DECODER_H_
+#define _GL_DECODER_H_
+
+#include "gl_dec.h"
+#include "FixedBuffer.h"
+#include "GLDecoderContextData.h"
+
+#define GLES_LIBNAME_VAR "ANDROID_GLESv1_LIB"
+#define GLES_LIBNAME "libGLES_CM.so"
+
+class GLDecoder : public gl_decoder_context_t
+{
+public:
+    typedef void *(*get_proc_func_t)(const char *name, void *userData);
+
+    GLDecoder();
+    ~GLDecoder();
+    int initGL(get_proc_func_t getProcFunc = NULL, void *getProcFuncData = NULL);
+    void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; }
+
+private:
+    static void s_glGetCompressedTextureFormats(void * self, GLint cont, GLint *data);
+    static void s_glVertexPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen);
+    static void s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset);
+
+    static void s_glColorPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen);
+    static void s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset);
+
+    static void s_glTexCoordPointerData(void *self, GLint unit, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen);
+    static void s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset);
+
+    static void s_glNormalPointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen);
+    static void s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset);
+
+    static void s_glPointSizePointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen);
+    static void s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset);
+
+    static void s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset);
+    static void s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen);
+
+    static void * s_getProc(const char *name, void *userData);
+
+    GLDecoderContextData *m_contextData;
+    void *m_glesDso;
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/Android.mk b/tools/emulator/opengl/system/Android.mk
new file mode 100644
index 0000000..7125f0a
--- /dev/null
+++ b/tools/emulator/opengl/system/Android.mk
@@ -0,0 +1,77 @@
+
+LOCAL_PATH := $(call my-dir)
+
+### OpenglCodecCommon ##############################################
+
+include $(CLEAR_VARS)
+
+OpenglCodecCommon := \
+        OpenglCodecCommon/GLClientState.cpp \
+        OpenglCodecCommon/glUtils.cpp \
+        OpenglCodecCommon/TcpStream.cpp
+
+LOCAL_SRC_FILES :=  $(OpenglCodecCommon)
+
+LOCAL_CFLAGS += -DLOG_TAG=\"eglCodecCommon\"
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libOpenglCodecCommon
+
+include $(BUILD_STATIC_LIBRARY)
+
+### OpenglCodecCommon  host ##############################################
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES :=  $(OpenglCodecCommon)
+
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libOpenglCodecCommon
+LOCAL_PRELINK_MODULE := false
+
+# XXX - enable the next line for host debugging - JR
+# 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
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/ErrorLog.h b/tools/emulator/opengl/system/OpenglCodecCommon/ErrorLog.h
new file mode 100644
index 0000000..35002ab
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/ErrorLog.h
@@ -0,0 +1,14 @@
+#ifndef _ERROR_LOG_H_
+#define _ERROR_LOG_H_
+
+#if (HAVE_ANDROID_OS == 1)
+#    include <cutils/log.h>
+#    define ERR(...)    LOGE(__VA_ARGS__)
+#    define DBG(...)    LOGD(__VA_ARGS__)
+#else
+#     include <stdio.h>
+#    define ERR(...)    fprintf(stderr, __VA_ARGS__)
+#    define DBG(...)    fprintf(stderr, __VA_ARGS__)
+#endif
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/FixedBuffer.h b/tools/emulator/opengl/system/OpenglCodecCommon/FixedBuffer.h
new file mode 100644
index 0000000..78fa244
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/FixedBuffer.h
@@ -0,0 +1,52 @@
+/*
+* 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 _FIXED_BUFFER_H
+#define _FIXED_BUFFER_H
+
+class FixedBuffer {
+public:
+    FixedBuffer(size_t initialSize = 0) {
+        m_buffer = NULL;
+        m_bufferLen = 0;
+        alloc(m_bufferLen);
+    }
+
+    ~FixedBuffer() {
+        if (m_buffer != NULL) {
+            delete m_buffer;
+            m_bufferLen = 0;
+        }
+    }
+
+    void * alloc(size_t size) {
+        if (m_bufferLen >= size) return (void *)(m_buffer);
+
+        if (m_buffer != NULL) delete m_buffer;
+
+        m_bufferLen = size;
+        m_buffer = new unsigned char[m_bufferLen];
+        if (m_buffer == NULL) m_bufferLen = 0;
+
+        return m_buffer;
+    }
+    void *ptr() { return m_buffer; }
+    size_t len() { return m_bufferLen; }
+private:
+    unsigned char *m_buffer;
+    size_t m_bufferLen;
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/GLClientState.cpp b/tools/emulator/opengl/system/OpenglCodecCommon/GLClientState.cpp
new file mode 100644
index 0000000..7fc5068
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/GLClientState.cpp
@@ -0,0 +1,231 @@
+/*
+* 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 "GLClientState.h"
+#include "ErrorLog.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "glUtils.h"
+#include <cutils/log.h>
+
+GLClientState::GLClientState(int nLocations)
+{
+    if (nLocations < LAST_LOCATION) {
+        nLocations = LAST_LOCATION;
+    }
+    m_nLocations = nLocations;
+    m_states = new VertexAttribState[m_nLocations];
+    for (int i = 0; i < m_nLocations; i++) {
+        m_states[i].enabled = 0;
+        m_states[i].enableDirty = false;
+    }
+    m_currentArrayVbo = 0;
+    m_currentIndexVbo = 0;
+    // init gl constans;
+    m_states[VERTEX_LOCATION].glConst = GL_VERTEX_ARRAY;
+    m_states[NORMAL_LOCATION].glConst = GL_NORMAL_ARRAY;
+    m_states[COLOR_LOCATION].glConst = GL_COLOR_ARRAY;
+    m_states[POINTSIZE_LOCATION].glConst = GL_POINT_SIZE_ARRAY_OES;
+    m_states[TEXCOORD0_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY;
+    m_states[TEXCOORD1_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY;
+    m_states[TEXCOORD2_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY;
+    m_states[TEXCOORD3_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY;
+    m_states[TEXCOORD4_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY;
+    m_states[TEXCOORD5_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY;
+    m_states[TEXCOORD6_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY;
+    m_states[TEXCOORD7_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY;
+    m_activeTexture = 0;
+
+    m_pixelStore.unpack_alignment = 4;
+    m_pixelStore.pack_alignment = 4;
+}
+
+GLClientState::~GLClientState()
+{
+    delete m_states;
+}
+
+void GLClientState::enable(int location, int state)
+{
+    if (!validLocation(location)) {
+        return;
+    }
+
+    m_states[location].enableDirty |= (state != m_states[location].enabled);
+    m_states[location].enabled = state;
+}
+
+void GLClientState::setState(int location, int size, GLenum type, GLsizei stride, void *data)
+{
+    if (!validLocation(location)) {
+        return;
+    }
+    m_states[location].size = size;
+    m_states[location].type = type;
+    m_states[location].stride = stride;
+    m_states[location].data = data;
+    m_states[location].bufferObject = m_currentArrayVbo;
+    m_states[location].elementSize = glSizeof(type) * size;
+}
+
+void GLClientState::setBufferObject(int location, GLuint id)
+{
+    if (!validLocation(location)) {
+        return;
+    }
+
+    m_states[location].bufferObject = id;
+}
+
+const GLClientState::VertexAttribState * GLClientState::getState(int location)
+{
+    if (!validLocation(location)) {
+        return NULL;
+    }
+    return & m_states[location];
+}
+
+const GLClientState::VertexAttribState * GLClientState::getStateAndEnableDirty(int location, bool *enableChanged)
+{
+    if (!validLocation(location)) {
+        return NULL;
+    }
+
+    if (enableChanged) {
+        *enableChanged = m_states[location].enableDirty;
+    }
+
+    m_states[location].enableDirty = false;
+    return & m_states[location];
+}
+
+int GLClientState::getLocation(GLenum loc)
+{
+    int retval;
+
+    switch(loc) {
+    case GL_VERTEX_ARRAY:
+        retval = int(VERTEX_LOCATION);
+        break;
+    case GL_NORMAL_ARRAY:
+        retval = int(NORMAL_LOCATION);
+        break;
+    case GL_COLOR_ARRAY:
+        retval = int(COLOR_LOCATION);
+        break;
+    case GL_POINT_SIZE_ARRAY_OES:
+        retval = int(POINTSIZE_LOCATION);
+        break;
+    case GL_TEXTURE_COORD_ARRAY:
+        retval = int (TEXCOORD0_LOCATION + m_activeTexture);
+        break;
+    default:
+        retval = loc;
+    }
+    return retval;
+}
+
+int GLClientState::setPixelStore(GLenum param, GLint value)
+{
+    int retval = 0;
+    switch(param) {
+    case GL_UNPACK_ALIGNMENT:
+        if (value == 1 || value == 2 || value == 4 || value == 8) {
+            m_pixelStore.unpack_alignment = value;
+        } else {
+            retval =  GL_INVALID_VALUE;
+        }
+        break;
+    case GL_PACK_ALIGNMENT:
+        if (value == 1 || value == 2 || value == 4 || value == 8) {
+            m_pixelStore.pack_alignment = value;
+        } else {
+            retval =  GL_INVALID_VALUE;
+        }
+        break;
+        default:
+            retval = GL_INVALID_ENUM;
+    }
+    return retval;
+}
+
+
+size_t GLClientState::pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack)
+{
+
+    int components = 0;
+    int componentsize = 0;
+    int pixelsize = 0;
+    switch(type) {
+    case GL_UNSIGNED_BYTE:
+        componentsize = 1;
+        break;
+    case GL_UNSIGNED_SHORT_5_6_5:
+    case GL_UNSIGNED_SHORT_4_4_4_4:
+    case GL_UNSIGNED_SHORT_5_5_5_1:
+        pixelsize = 2;
+        break;
+    default:
+        ERR("pixelDataSize: unknown pixel type - assuming pixel data 0\n");
+        componentsize = 0;
+    }
+
+    if (pixelsize == 0) {
+        switch(format) {
+#if 0
+        case GL_RED:
+        case GL_GREEN:
+        case GL_BLUE:
+#endif
+        case GL_ALPHA:
+        case GL_LUMINANCE:
+            components = 1;
+            break;
+        case GL_LUMINANCE_ALPHA:
+            components = 2;
+            break;
+        case GL_RGB:
+#if 0
+        case GL_BGR:
+#endif
+            components = 3;
+            break;
+        case GL_RGBA:
+#if 0
+        case GL_BGRA:
+#endif
+            components = 4;
+            break;
+        default:
+            ERR("pixelDataSize: unknown pixel format...\n");
+            components = 0;
+        }
+        pixelsize = components * componentsize;
+    }
+
+    int alignment = pack ? m_pixelStore.pack_alignment : m_pixelStore.unpack_alignment;
+
+    if (pixelsize == 0 ) {
+        ERR("unknown pixel size: width: %d height: %d format: %d type: %d pack: %d align: %d\n",
+             width, height, format, type, pack, alignment);
+    }
+    size_t linesize = pixelsize * width;
+    size_t aligned_linesize = int(linesize / alignment) * alignment;
+    if (aligned_linesize < linesize) {
+        aligned_linesize += alignment;
+    }
+    return aligned_linesize * height;
+}
+
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/GLClientState.h b/tools/emulator/opengl/system/OpenglCodecCommon/GLClientState.h
new file mode 100644
index 0000000..be625d5
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/GLClientState.h
@@ -0,0 +1,109 @@
+/*
+* 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_CLIENT_STATE_H_
+#define _GL_CLIENT_STATE_H_
+
+#define GL_API
+#ifndef ANDROID
+#define GL_APIENTRY
+#define GL_APIENTRYP
+#endif
+
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+class GLClientState {
+public:
+    typedef enum {
+        VERTEX_LOCATION = 0,
+        NORMAL_LOCATION = 1,
+        COLOR_LOCATION = 2,
+        POINTSIZE_LOCATION = 3,
+        TEXCOORD0_LOCATION = 4,
+        TEXCOORD1_LOCATION = 5,
+        TEXCOORD2_LOCATION = 6,
+        TEXCOORD3_LOCATION = 7,
+        TEXCOORD4_LOCATION = 8,
+        TEXCOORD5_LOCATION = 9,
+        TEXCOORD6_LOCATION = 10,
+        TEXCOORD7_LOCATION = 11,
+        LAST_LOCATION = 12
+    } StateLocation;
+
+    typedef struct {
+        GLint enabled;
+        GLint size;
+        GLenum type;
+        GLsizei stride;
+        void *data;
+        GLuint bufferObject;
+        GLenum glConst;
+        unsigned int elementSize;
+        bool enableDirty;  // true if any enable state has changed since last draw
+    } VertexAttribState;
+
+    typedef struct {
+        int unpack_alignment;
+        int pack_alignment;
+    } PixelStoreState;
+
+public:
+    GLClientState(int nLocations = 32);
+    ~GLClientState();
+    const PixelStoreState *pixelStoreState() { return &m_pixelStore; }
+    int setPixelStore(GLenum param, GLint value);
+    GLuint currentArrayVbo() { return m_currentArrayVbo; }
+    GLuint currentIndexVbo() { return m_currentIndexVbo; }
+    void enable(int location, int state);
+    void setState(int  location, int size, GLenum type, GLsizei stride, void *data);
+    void setBufferObject(int location, GLuint id);
+    const VertexAttribState  *getState(int location);
+    const VertexAttribState  *getStateAndEnableDirty(int location, bool *enableChanged);
+    int getLocation(GLenum loc);
+    void setActiveTexture(int texUnit) {m_activeTexture = texUnit; };
+    int getActiveTexture() const { return m_activeTexture; }
+    int bindBuffer(GLenum target, GLuint id)
+    {
+        int err = 0;
+        switch(target) {
+        case GL_ARRAY_BUFFER:
+            m_currentArrayVbo = id;
+            break;
+        case GL_ELEMENT_ARRAY_BUFFER:
+            m_currentIndexVbo = id;
+            break;
+        default:
+            err = -1;
+        }
+        return err;
+    }
+    size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack);
+
+private:
+    PixelStoreState m_pixelStore;
+    VertexAttribState *m_states;
+    int m_nLocations;
+    GLuint m_currentArrayVbo;
+    GLuint m_currentIndexVbo;
+    int m_activeTexture;
+
+
+    bool validLocation(int location) { return (location >= 0 && location < m_nLocations); }
+
+};
+#endif
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/GLDecoderContextData.h b/tools/emulator/opengl/system/OpenglCodecCommon/GLDecoderContextData.h
new file mode 100644
index 0000000..faf6ad6
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/GLDecoderContextData.h
@@ -0,0 +1,40 @@
+#ifndef _GL_DECODER_CONTEXT_DATA_H_
+#define _GL_DECODER_CONTEXT_DATA_H_
+
+#include <assert.h>
+#include <string.h>
+#include "FixedBuffer.h"
+
+class  GLDecoderContextData {
+public:
+    typedef enum  {
+        VERTEX_LOCATION = 0,
+        NORMAL_LOCATION = 1,
+        COLOR_LOCATION = 2,
+        POINTSIZE_LOCATION = 3,
+        TEXCOORD0_LOCATION = 4,
+        TEXCOORD1_LOCATION = 5,
+        TEXCOORD2_LOCATION = 6,
+        TEXCOORD3_LOCATION = 7,
+        TEXCOORD4_LOCATION = 8,
+        TEXCOORD5_LOCATION = 9,
+        TEXCOORD6_LOCATION = 10,
+        TEXCOORD7_LOCATION = 11,
+        LAST_LOCATION = 12
+    } PointerDataLocation;
+
+    void storePointerData(PointerDataLocation loc, void *data, size_t len) {
+        assert(loc < LAST_LOCATION);
+
+        m_pointerData[loc].alloc(len);
+        memcpy(m_pointerData[loc].ptr(), data, len);
+    }
+    void *pointerData(PointerDataLocation loc) {
+        assert(loc < LAST_LOCATION);
+        return m_pointerData[loc].ptr();
+    }
+private:
+    FixedBuffer m_pointerData[LAST_LOCATION];
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/IOStream.h b/tools/emulator/opengl/system/OpenglCodecCommon/IOStream.h
new file mode 100644
index 0000000..7cfccc3
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/IOStream.h
@@ -0,0 +1,90 @@
+/*
+* 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 __IO_STREAM_H__
+#define __IO_STREAM_H__
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "ErrorLog.h"
+
+class IOStream {
+public:
+
+    IOStream(size_t bufSize) {
+        m_buf = NULL;
+        m_bufsize = bufSize;
+        m_free = 0;
+    }
+
+    virtual void *allocBuffer(size_t minSize) = 0;
+    virtual int commitBuffer(size_t size) = 0;
+    virtual const unsigned char *readFully( void *buf, size_t len) = 0;
+
+    virtual ~IOStream() {
+
+        // NOTE: m_buf is 'owned' by the child class thus we expect it to be released by it
+    }
+
+    unsigned char *alloc(size_t len) {
+
+        if (m_buf && len > m_free) {
+            if (flush() < 0) {
+                ERR("Failed to flush in alloc\n");
+                return NULL; // we failed to flush so something is wrong
+            }
+        }
+
+        if (!m_buf || len > m_bufsize) {
+            int allocLen = m_bufsize < len ? len : m_bufsize;
+            m_buf = (unsigned char *)allocBuffer(allocLen);
+            if (!m_buf) {
+                ERR("Alloc (%u bytes) failed\n", allocLen);
+                return NULL;
+            }
+            m_bufsize = m_free = allocLen;
+        }
+
+        unsigned char *ptr;
+
+        ptr = m_buf + (m_bufsize - m_free);
+        m_free -= len;
+
+        return ptr;
+    }
+
+    int flush() {
+
+        if (!m_buf || m_free == m_bufsize) return 0;
+
+        int stat = commitBuffer(m_bufsize - m_free);
+        m_buf = NULL;
+        m_free = 0;
+        return stat;
+    }
+
+    const unsigned char *readback(void *buf, size_t len) {
+        flush();
+        return readFully(buf, len);
+    }
+
+private:
+    unsigned char *m_buf;
+    size_t m_bufsize;
+    size_t m_free;
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/Makefile b/tools/emulator/opengl/system/OpenglCodecCommon/Makefile
new file mode 100644
index 0000000..e8bf431
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/Makefile
@@ -0,0 +1,13 @@
+
+ROOT=../..
+
+include $(ROOT)/make/commondefs
+
+CXXFILES = TcpStream.cpp GLClientState.cpp glUtils.cpp
+CXXINCS += -I$(ROOT)/libs/GLESv1 -I$(ROOT)/include
+
+LIBRARY_NAME = libcodecCommon.a
+
+include $(COMMONRULES)
+
+
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/TcpStream.cpp b/tools/emulator/opengl/system/OpenglCodecCommon/TcpStream.cpp
new file mode 100644
index 0000000..86202d0
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/TcpStream.cpp
@@ -0,0 +1,231 @@
+/*
+* 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 "TcpStream.h"
+
+#ifdef ANDROID
+#include <netinet/in.h>
+#endif
+
+#include <errno.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+TcpStream::TcpStream(size_t bufSize) :  IOStream(bufSize)
+{
+    m_sock = socket(AF_INET, SOCK_STREAM, 0);
+    m_bufsize = bufSize;
+    m_buf = NULL;
+}
+
+TcpStream::TcpStream(int sock, size_t bufSize) :
+    IOStream(bufSize),
+    m_sock(sock),
+    m_bufsize(bufSize),
+    m_buf(NULL)
+{
+
+}
+
+TcpStream::~TcpStream()
+{
+    if (m_sock >= 0) {
+        ::close(m_sock);
+    }
+    if (m_buf != NULL) {
+        free(m_buf);
+    }
+}
+
+
+int TcpStream::listen(unsigned short port, bool localhost_only, bool reuse_address)
+{
+    if (!valid()) return int(ERR_INVALID_SOCKET);
+
+    // NOTE: This is a potential security issue. However, since we accept connection
+    // from local host only, this should be reasonably OK.
+
+    if (reuse_address) {
+        int one = 1;
+        if (setsockopt(m_sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0) {
+            perror("setsockopt resuseaddr");
+        }
+    }
+
+    struct sockaddr_in addr;
+    memset(&addr, 0, sizeof(addr));
+
+    addr.sin_family = AF_INET;
+    addr.sin_port = htons(port);
+    if (localhost_only) {
+        addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+    } else {
+        addr.sin_addr.s_addr = INADDR_ANY;
+    }
+
+    if (::bind(m_sock, (const sockaddr *) &addr, sizeof(addr)) < 0) {
+        perror("bind");
+        return -1;
+    }
+    if (::listen(m_sock, 5) < 0) {
+        perror("listen");
+        return -1;
+    }
+    return 0;
+}
+
+TcpStream * TcpStream::accept()
+{
+    int clientSock = -1;
+
+    while (true) {
+        struct sockaddr_in addr;
+        socklen_t len = sizeof(addr);
+        clientSock = ::accept(m_sock, (sockaddr *)&addr, &len);
+
+        if (clientSock < 0 && errno == EINTR) {
+            continue;
+        }
+        break;
+    }
+
+    TcpStream *clientStream = NULL;
+
+    if (clientSock >= 0) {
+        clientStream =  new TcpStream(clientSock, m_bufsize);
+    }
+    return clientStream;
+}
+
+
+int TcpStream::connect(const char *hostname, unsigned short port)
+{
+    struct addrinfo *ai;
+    char portstr[10];
+    snprintf(portstr, sizeof(portstr), "%d", port);
+
+    if (getaddrinfo(hostname, portstr, NULL, &ai) != 0) {
+        return -1;
+    }
+
+    struct addrinfo *i;
+    i = ai;
+    while (i != NULL) {
+        if (::connect(m_sock, i->ai_addr, i->ai_addrlen) >= 0) {
+            break;
+        } else {
+            if (errno != EINTR) {
+                i = i->ai_next;
+            }
+        }
+    }
+
+    freeaddrinfo(ai);
+    if (i == NULL) return -1;
+
+    return 0;
+}
+
+void *TcpStream::allocBuffer(size_t minSize)
+{
+    size_t allocSize = (m_bufsize < minSize ? minSize : m_bufsize);
+    if (!m_buf) {
+        m_buf = (unsigned char *)malloc(allocSize);
+    }
+    else if (m_bufsize < allocSize) {
+        unsigned char *p = (unsigned char *)realloc(m_buf, allocSize);
+        if (p != NULL) {
+            m_buf = p;
+            m_bufsize = allocSize;
+        } else {
+            ERR("realloc (%d) failed\n", allocSize);
+            free(m_buf);
+            m_buf = NULL;
+            m_bufsize = 0;
+        }
+    }
+
+    return m_buf;
+};
+
+int TcpStream::commitBuffer(size_t size)
+{
+    return writeFully(m_buf, size);
+}
+
+int TcpStream::writeFully(const void *buf, size_t len)
+{
+    if (!valid()) return -1;
+
+    size_t res = len;
+    int retval = 0;
+
+    while (res > 0) {
+        ssize_t stat = ::send(m_sock, (unsigned char *)(buf) + (len - res), res, 0);
+        if (stat < 0) {
+            if (errno != EINTR) {
+                retval =  stat;
+                break;
+            }
+        } else {
+            res -= stat;
+        }
+    }
+    return retval;
+}
+
+const unsigned char *TcpStream::readFully(void *buf, size_t len)
+{
+    if (!valid()) return NULL;
+    if (!buf) return NULL;  // do not allow NULL buf in that implementation
+    size_t res = len;
+    while (res > 0) {
+        ssize_t stat = ::recv(m_sock, (unsigned char *)(buf) + len - res, len, MSG_WAITALL);
+        if (stat == 0) {
+            // client shutdown;
+            return NULL;
+        } else if (stat < 0) {
+            if (errno == EINTR) {
+                continue;
+            } else {
+                return NULL;
+            }
+        } else {
+            res -= stat;
+        }
+    }
+    return (const unsigned char *)buf;
+}
+
+int TcpStream::recv(void *buf, size_t len)
+{
+    if (!valid()) return int(ERR_INVALID_SOCKET);
+    int res = 0;
+    while(true) {
+        res = ::recv(m_sock, buf, len, 0);
+        if (res < 0) {
+            if (errno == EINTR) {
+                continue;
+            }
+        }
+        break;
+    }
+    return res;
+}
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/TcpStream.h b/tools/emulator/opengl/system/OpenglCodecCommon/TcpStream.h
new file mode 100644
index 0000000..aa65b7e
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/TcpStream.h
@@ -0,0 +1,50 @@
+/*
+* 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 __TCP_STREAM_H
+#define __TCP_STREAM_H
+
+#include <stdlib.h>
+#include "IOStream.h"
+
+
+class TcpStream : public IOStream {
+public:
+    typedef enum { ERR_INVALID_SOCKET = -1000 } TcpStreamError;
+
+    explicit TcpStream(size_t bufsize = 10000);
+    ~TcpStream();
+    int listen(unsigned short port, bool localhost_only = true, bool reuse_address = true);
+    TcpStream *accept();
+    int connect(const char *hostname, unsigned short port);
+
+    virtual void *allocBuffer(size_t minSize);
+    virtual int commitBuffer(size_t size);
+    virtual const unsigned char *readFully( void *buf, size_t len);
+
+    bool valid() { return m_sock >= 0; }
+    int recv(void *buf, size_t len);
+
+private:
+    int writeFully(const void *buf, size_t len);
+
+private:
+    int m_sock;
+    size_t m_bufsize;
+    unsigned char *m_buf;
+    TcpStream(int sock, size_t bufSize);
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/codec_defs.h b/tools/emulator/opengl/system/OpenglCodecCommon/codec_defs.h
new file mode 100644
index 0000000..968ea3f
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/codec_defs.h
@@ -0,0 +1,21 @@
+/*
+* 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 _CODEC_DEFS_H
+#define _CODEC_DEFS_H
+
+#define CODEC_SERVER_PORT 22468
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/glUtils.cpp b/tools/emulator/opengl/system/OpenglCodecCommon/glUtils.cpp
new file mode 100644
index 0000000..ad4888a
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/glUtils.cpp
@@ -0,0 +1,147 @@
+/*
+* 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 "glUtils.h"
+#include <string.h>
+#include "ErrorLog.h"
+
+size_t glSizeof(GLenum type)
+{
+    size_t retval = 0;
+    switch(type) {
+    case GL_BYTE:
+    case GL_UNSIGNED_BYTE:
+        retval = 1;
+        break;
+    case GL_SHORT:
+    case GL_UNSIGNED_SHORT:
+        retval = 2;
+        break;
+    case GL_FLOAT:
+    case GL_FIXED:
+        retval =  4;
+        break;
+#ifdef GL_DOUBLE
+    case GL_DOUBLE:
+        retval = 8;
+        break;
+#endif
+    }
+    return retval;
+
+}
+
+size_t glUtilsParamSize(GLenum param)
+{
+    size_t s = 0;
+
+    switch(param)
+    {
+    case GL_MAX_TEXTURE_SIZE:
+    case GL_TEXTURE_GEN_MODE_OES:
+    case GL_TEXTURE_ENV_MODE:
+    case GL_FOG_MODE:
+    case GL_FOG_DENSITY:
+    case GL_FOG_START:
+    case GL_FOG_END:
+    case GL_SPOT_EXPONENT:
+    case GL_CONSTANT_ATTENUATION:
+    case GL_LINEAR_ATTENUATION:
+    case GL_QUADRATIC_ATTENUATION:
+    case GL_SHININESS:
+    case GL_LIGHT_MODEL_TWO_SIDE:
+    case GL_POINT_SIZE:
+    case GL_POINT_SIZE_MIN:
+    case GL_POINT_SIZE_MAX:
+    case GL_POINT_FADE_THRESHOLD_SIZE:
+    case GL_CULL_FACE_MODE:
+    case GL_FRONT_FACE:
+    case GL_SHADE_MODEL:
+    case GL_DEPTH_WRITEMASK:
+    case GL_DEPTH_CLEAR_VALUE:
+    case GL_STENCIL_FAIL:
+    case GL_STENCIL_PASS_DEPTH_FAIL:
+    case GL_STENCIL_PASS_DEPTH_PASS:
+    case GL_STENCIL_REF:
+    case GL_STENCIL_WRITEMASK:
+    case GL_MATRIX_MODE:
+    case GL_MODELVIEW_STACK_DEPTH:
+    case GL_PROJECTION_STACK_DEPTH:
+    case GL_TEXTURE_STACK_DEPTH:
+    case GL_ALPHA_TEST_FUNC:
+    case GL_ALPHA_TEST_REF:
+    case GL_BLEND_DST:
+    case GL_BLEND_SRC:
+    case GL_LOGIC_OP_MODE:
+    case GL_SCISSOR_TEST:
+    case GL_MAX_TEXTURE_UNITS:
+        s = 1;
+        break;
+    case GL_ALIASED_LINE_WIDTH_RANGE:
+    case GL_ALIASED_POINT_SIZE_RANGE:
+    case GL_DEPTH_RANGE:
+    case GL_MAX_VIEWPORT_DIMS:
+    case GL_SMOOTH_POINT_SIZE_RANGE:
+    case GL_SMOOTH_LINE_WIDTH_RANGE:
+        s= 2;
+        break;
+    case GL_SPOT_DIRECTION:
+    case GL_POINT_DISTANCE_ATTENUATION:
+    case GL_CURRENT_NORMAL:
+        s =  3;
+        break;
+    case GL_CURRENT_TEXTURE_COORDS:
+    case GL_CURRENT_COLOR:
+    case GL_FOG_COLOR:
+    case GL_AMBIENT:
+    case GL_DIFFUSE:
+    case GL_SPECULAR:
+    case GL_EMISSION:
+    case GL_POSITION:
+    case GL_LIGHT_MODEL_AMBIENT:
+    case GL_TEXTURE_ENV_COLOR:
+    case GL_SCISSOR_BOX:
+    case GL_VIEWPORT:
+    case GL_TEXTURE_CROP_RECT_OES:
+        s =  4;
+        break;
+    case GL_MODELVIEW_MATRIX:
+    case GL_PROJECTION_MATRIX:
+    case GL_TEXTURE_MATRIX:
+        s = 16;
+    default:
+        ERR("glUtilsParamSize: unknow param 0x%08x\n", param);
+        s = 1; // assume 1
+    }
+    return s;
+}
+
+void glUtilsPackPointerData(unsigned char *dst, unsigned char *src,
+                     int size, GLenum type, unsigned int stride,
+                     unsigned int datalen)
+{
+    unsigned int  vsize = size * glSizeof(type);
+    if (stride == 0) stride = vsize;
+
+    if (stride == vsize) {
+        memcpy(dst, src, datalen);
+    } else {
+        for (unsigned int i = 0; i < datalen; i += vsize) {
+            memcpy(dst, src, vsize);
+            dst += vsize;
+            src += stride;
+        }
+    }
+}
diff --git a/tools/emulator/opengl/system/OpenglCodecCommon/glUtils.h b/tools/emulator/opengl/system/OpenglCodecCommon/glUtils.h
new file mode 100644
index 0000000..96b29d6
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglCodecCommon/glUtils.h
@@ -0,0 +1,56 @@
+/*
+* 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_UTILS_H__
+#define __GL_UTILS_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef GL_API
+    #undef GL_API
+#endif
+#define GL_API
+
+#ifdef GL_APIENTRY
+    #undef GL_APIENTRY
+#endif
+
+#ifdef GL_APIENTRYP
+    #undef GL_APIENTRYP
+#endif
+#define GL_APIENTRYP
+
+#ifndef ANDROID
+#define GL_APIENTRY
+#endif
+
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    size_t glSizeof(GLenum type);
+    size_t glUtilsParamSize(GLenum param);
+    void   glUtilsPackPointerData(unsigned char *dst, unsigned char *str,
+                           int size, GLenum type, unsigned int stride,
+                           unsigned int datalen);
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/tools/emulator/opengl/tests/EGL_host_wrapper/Android.mk b/tools/emulator/opengl/tests/EGL_host_wrapper/Android.mk
new file mode 100644
index 0000000..d22be81
--- /dev/null
+++ b/tools/emulator/opengl/tests/EGL_host_wrapper/Android.mk
@@ -0,0 +1,20 @@
+ifeq ($(HOST_OS),linux)
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES :=  \
+        egl.cpp \
+        egl_dispatch.cpp
+
+LOCAL_MODULE := libEGL_host_wrapper
+LOCAL_MODULE_TAGS := debug
+
+OS_LDLIBS := -ldl -lpthread
+
+LOCAL_LDLIBS := $(OS_LDLIBS)
+
+include $(BUILD_HOST_SHARED_LIBRARY) 
+
+endif # HOST_OS == linux
\ No newline at end of file
diff --git a/tools/emulator/opengl/tests/EGL_host_wrapper/egl.cpp b/tools/emulator/opengl/tests/EGL_host_wrapper/egl.cpp
new file mode 100644
index 0000000..6fa27ac
--- /dev/null
+++ b/tools/emulator/opengl/tests/EGL_host_wrapper/egl.cpp
@@ -0,0 +1,277 @@
+/*
+* 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 <string.h>
+#include "egl_dispatch.h"
+#include "egl_ftable.h"
+#include <pthread.h>
+
+#define EGL_LIB "ANDROID_EGL_LIB"
+
+static struct egl_dispatch *s_dispatch = NULL;
+static pthread_once_t eglDispatchInitialized = PTHREAD_ONCE_INIT;
+
+void initEglDispatch()
+{
+    //
+    // Load back-end EGL implementation library
+    //
+    char *eglLib = (char *) "libEGL.so";
+    if (getenv(EGL_LIB) != NULL) {
+        eglLib = getenv(EGL_LIB);
+    }
+
+    s_dispatch = loadEGL(eglLib);
+    if (!s_dispatch) {
+        fprintf(stderr,"FATAL ERROR: Could not load EGL lib [%s]\n", eglLib);
+        exit(-1);
+    }
+}
+
+static struct egl_dispatch *getDispatch()
+{
+    pthread_once(&eglDispatchInitialized, initEglDispatch);
+    return s_dispatch;
+}
+
+__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
+{
+     for (int i=0; i<egl_num_funcs; i++) {
+         if (!strcmp(egl_funcs_by_name[i].name, procname)) {
+             return (__eglMustCastToProperFunctionPointerType)egl_funcs_by_name[i].proc;
+         }
+     }
+
+     return getDispatch()->eglGetProcAddress(procname);
+}
+
+////////////////  Path through functions //////////
+
+EGLint eglGetError()
+{
+     return getDispatch()->eglGetError();
+}
+
+EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
+{
+    return getDispatch()->eglGetDisplay(display_id);
+}
+
+EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+     return getDispatch()->eglInitialize(dpy, major, minor);
+}
+
+EGLBoolean eglTerminate(EGLDisplay dpy)
+{
+     return getDispatch()->eglTerminate(dpy);
+}
+
+const char* eglQueryString(EGLDisplay dpy, EGLint name)
+{
+     return getDispatch()->eglQueryString(dpy, name);
+}
+
+EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+     return getDispatch()->eglGetConfigs(dpy, configs, config_size, num_config);
+}
+
+EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+     return getDispatch()->eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
+}
+
+EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+{
+     return getDispatch()->eglGetConfigAttrib(dpy, config, attribute, value);
+}
+
+EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
+{
+     return getDispatch()->eglCreateWindowSurface(dpy, config, win, attrib_list);
+}
+
+EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+{
+     return getDispatch()->eglCreatePbufferSurface(dpy, config, attrib_list);
+}
+
+EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
+{
+     return getDispatch()->eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
+}
+
+EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+{
+     return getDispatch()->eglDestroySurface(dpy, surface);
+}
+
+EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
+{
+     return getDispatch()->eglQuerySurface(dpy, surface, attribute, value);
+}
+
+EGLBoolean eglBindAPI(EGLenum api)
+{
+     return getDispatch()->eglBindAPI(api);
+}
+
+EGLenum eglQueryAPI()
+{
+     return getDispatch()->eglQueryAPI();
+}
+
+EGLBoolean eglWaitClient()
+{
+     return getDispatch()->eglWaitClient();
+}
+
+EGLBoolean eglReleaseThread()
+{
+     return getDispatch()->eglReleaseThread();
+}
+
+EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+{
+     return getDispatch()->eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
+}
+
+EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+{
+     return getDispatch()->eglSurfaceAttrib(dpy, surface, attribute, value);
+}
+
+EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+     return getDispatch()->eglBindTexImage(dpy, surface, buffer);
+}
+
+EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+     return getDispatch()->eglReleaseTexImage(dpy, surface, buffer);
+}
+
+EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
+{
+     return getDispatch()->eglSwapInterval(dpy, interval);
+}
+
+EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
+{
+     return getDispatch()->eglCreateContext(dpy, config, share_context, attrib_list);
+}
+
+EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+     return getDispatch()->eglDestroyContext(dpy, ctx);
+}
+
+EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+     return getDispatch()->eglMakeCurrent(dpy, draw, read, ctx);
+}
+
+EGLContext eglGetCurrentContext()
+{
+     return getDispatch()->eglGetCurrentContext();
+}
+
+EGLSurface eglGetCurrentSurface(EGLint readdraw)
+{
+     return getDispatch()->eglGetCurrentSurface(readdraw);
+}
+
+EGLDisplay eglGetCurrentDisplay()
+{
+     return getDispatch()->eglGetCurrentDisplay();
+}
+
+EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+{
+     return getDispatch()->eglQueryContext(dpy, ctx, attribute, value);
+}
+
+EGLBoolean eglWaitGL()
+{
+     return getDispatch()->eglWaitGL();
+}
+
+EGLBoolean eglWaitNative(EGLint engine)
+{
+     return getDispatch()->eglWaitNative(engine);
+}
+
+EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
+{
+     return getDispatch()->eglSwapBuffers(dpy, surface);
+}
+
+EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+{
+     return getDispatch()->eglCopyBuffers(dpy, surface, target);
+}
+
+EGLBoolean eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
+{
+     return getDispatch()->eglLockSurfaceKHR(display, surface, attrib_list);
+}
+
+EGLBoolean eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
+{
+     return getDispatch()->eglUnlockSurfaceKHR(display, surface);
+}
+
+EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+     return getDispatch()->eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
+}
+
+EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
+{
+     return getDispatch()->eglDestroyImageKHR(dpy, image);
+}
+
+EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
+{
+     return getDispatch()->eglCreateSyncKHR(dpy, type, attrib_list);
+}
+
+EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
+{
+     return getDispatch()->eglDestroySyncKHR(dpy, sync);
+}
+
+EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
+{
+     return getDispatch()->eglClientWaitSyncKHR(dpy, sync, flags, timeout);
+}
+
+EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
+{
+     return getDispatch()->eglSignalSyncKHR(dpy, sync, mode);
+}
+
+EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
+{
+     return getDispatch()->eglGetSyncAttribKHR(dpy, sync, attribute, value);
+}
+
+EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height)
+{
+     return getDispatch()->eglSetSwapRectangleANDROID(dpy, draw, left, top, width, height);
+}
diff --git a/tools/emulator/opengl/tests/EGL_host_wrapper/egl_dispatch.cpp b/tools/emulator/opengl/tests/EGL_host_wrapper/egl_dispatch.cpp
new file mode 100644
index 0000000..a9b8214
--- /dev/null
+++ b/tools/emulator/opengl/tests/EGL_host_wrapper/egl_dispatch.cpp
@@ -0,0 +1,77 @@
+/*
+* 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 <dlfcn.h>
+#include "egl_dispatch.h"
+
+
+egl_dispatch *loadEGL(const char *p_eglPath)
+{
+    void *libEGL = dlopen(p_eglPath, RTLD_NOW);
+    if (!libEGL) {
+        return NULL;
+    }
+
+    egl_dispatch *disp = new egl_dispatch;
+
+    void *ptr;
+    ptr = dlsym(libEGL,"eglGetError"); disp->set_eglGetError((eglGetError_t)ptr);
+    ptr = dlsym(libEGL,"eglGetDisplay"); disp->set_eglGetDisplay((eglGetDisplay_t)ptr);
+    ptr = dlsym(libEGL,"eglInitialize"); disp->set_eglInitialize((eglInitialize_t)ptr);
+    ptr = dlsym(libEGL,"eglTerminate"); disp->set_eglTerminate((eglTerminate_t)ptr);
+    ptr = dlsym(libEGL,"eglQueryString"); disp->set_eglQueryString((eglQueryString_t)ptr);
+    ptr = dlsym(libEGL,"eglGetConfigs"); disp->set_eglGetConfigs((eglGetConfigs_t)ptr);
+    ptr = dlsym(libEGL,"eglChooseConfig"); disp->set_eglChooseConfig((eglChooseConfig_t)ptr);
+    ptr = dlsym(libEGL,"eglGetConfigAttrib"); disp->set_eglGetConfigAttrib((eglGetConfigAttrib_t)ptr);
+    ptr = dlsym(libEGL,"eglCreateWindowSurface"); disp->set_eglCreateWindowSurface((eglCreateWindowSurface_t)ptr);
+    ptr = dlsym(libEGL,"eglCreatePbufferSurface"); disp->set_eglCreatePbufferSurface((eglCreatePbufferSurface_t)ptr);
+    ptr = dlsym(libEGL,"eglCreatePixmapSurface"); disp->set_eglCreatePixmapSurface((eglCreatePixmapSurface_t)ptr);
+    ptr = dlsym(libEGL,"eglDestroySurface"); disp->set_eglDestroySurface((eglDestroySurface_t)ptr);
+    ptr = dlsym(libEGL,"eglQuerySurface"); disp->set_eglQuerySurface((eglQuerySurface_t)ptr);
+    ptr = dlsym(libEGL,"eglBindAPI"); disp->set_eglBindAPI((eglBindAPI_t)ptr);
+    ptr = dlsym(libEGL,"eglQueryAPI"); disp->set_eglQueryAPI((eglQueryAPI_t)ptr);
+    ptr = dlsym(libEGL,"eglWaitClient"); disp->set_eglWaitClient((eglWaitClient_t)ptr);
+    ptr = dlsym(libEGL,"eglReleaseThread"); disp->set_eglReleaseThread((eglReleaseThread_t)ptr);
+    ptr = dlsym(libEGL,"eglCreatePbufferFromClientBuffer"); disp->set_eglCreatePbufferFromClientBuffer((eglCreatePbufferFromClientBuffer_t)ptr);
+    ptr = dlsym(libEGL,"eglSurfaceAttrib"); disp->set_eglSurfaceAttrib((eglSurfaceAttrib_t)ptr);
+    ptr = dlsym(libEGL,"eglBindTexImage"); disp->set_eglBindTexImage((eglBindTexImage_t)ptr);
+    ptr = dlsym(libEGL,"eglReleaseTexImage"); disp->set_eglReleaseTexImage((eglReleaseTexImage_t)ptr);
+    ptr = dlsym(libEGL,"eglSwapInterval"); disp->set_eglSwapInterval((eglSwapInterval_t)ptr);
+    ptr = dlsym(libEGL,"eglCreateContext"); disp->set_eglCreateContext((eglCreateContext_t)ptr);
+    ptr = dlsym(libEGL,"eglDestroyContext"); disp->set_eglDestroyContext((eglDestroyContext_t)ptr);
+    ptr = dlsym(libEGL,"eglMakeCurrent"); disp->set_eglMakeCurrent((eglMakeCurrent_t)ptr);
+    ptr = dlsym(libEGL,"eglGetCurrentContext"); disp->set_eglGetCurrentContext((eglGetCurrentContext_t)ptr);
+    ptr = dlsym(libEGL,"eglGetCurrentSurface"); disp->set_eglGetCurrentSurface((eglGetCurrentSurface_t)ptr);
+    ptr = dlsym(libEGL,"eglGetCurrentDisplay"); disp->set_eglGetCurrentDisplay((eglGetCurrentDisplay_t)ptr);
+    ptr = dlsym(libEGL,"eglQueryContext"); disp->set_eglQueryContext((eglQueryContext_t)ptr);
+    ptr = dlsym(libEGL,"eglWaitGL"); disp->set_eglWaitGL((eglWaitGL_t)ptr);
+    ptr = dlsym(libEGL,"eglWaitNative"); disp->set_eglWaitNative((eglWaitNative_t)ptr);
+    ptr = dlsym(libEGL,"eglSwapBuffers"); disp->set_eglSwapBuffers((eglSwapBuffers_t)ptr);
+    ptr = dlsym(libEGL,"eglCopyBuffers"); disp->set_eglCopyBuffers((eglCopyBuffers_t)ptr);
+    ptr = dlsym(libEGL,"eglGetProcAddress"); disp->set_eglGetProcAddress((eglGetProcAddress_t)ptr);
+    ptr = dlsym(libEGL,"eglLockSurfaceKHR"); disp->set_eglLockSurfaceKHR((eglLockSurfaceKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglUnlockSurfaceKHR"); disp->set_eglUnlockSurfaceKHR((eglUnlockSurfaceKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglCreateImageKHR"); disp->set_eglCreateImageKHR((eglCreateImageKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglDestroyImageKHR"); disp->set_eglDestroyImageKHR((eglDestroyImageKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglCreateSyncKHR"); disp->set_eglCreateSyncKHR((eglCreateSyncKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglDestroySyncKHR"); disp->set_eglDestroySyncKHR((eglDestroySyncKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglClientWaitSyncKHR"); disp->set_eglClientWaitSyncKHR((eglClientWaitSyncKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglSignalSyncKHR"); disp->set_eglSignalSyncKHR((eglSignalSyncKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglGetSyncAttribKHR"); disp->set_eglGetSyncAttribKHR((eglGetSyncAttribKHR_t)ptr);
+    ptr = dlsym(libEGL,"eglSetSwapRectangleANDROID"); disp->set_eglSetSwapRectangleANDROID((eglSetSwapRectangleANDROID_t)ptr);
+
+    return disp;
+}
diff --git a/tools/emulator/opengl/tests/EGL_host_wrapper/egl_dispatch.h b/tools/emulator/opengl/tests/EGL_host_wrapper/egl_dispatch.h
new file mode 100644
index 0000000..e5f67c9
--- /dev/null
+++ b/tools/emulator/opengl/tests/EGL_host_wrapper/egl_dispatch.h
@@ -0,0 +1,115 @@
+/*
+* 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 _EGL_DISPATCH_H
+#define _EGL_DISPATCH_H
+
+#include "egl_proc.h"
+
+struct egl_dispatch {
+    eglGetError_t eglGetError;
+    eglGetDisplay_t eglGetDisplay;
+    eglInitialize_t eglInitialize;
+    eglTerminate_t eglTerminate;
+    eglQueryString_t eglQueryString;
+    eglGetConfigs_t eglGetConfigs;
+    eglChooseConfig_t eglChooseConfig;
+    eglGetConfigAttrib_t eglGetConfigAttrib;
+    eglCreateWindowSurface_t eglCreateWindowSurface;
+    eglCreatePbufferSurface_t eglCreatePbufferSurface;
+    eglCreatePixmapSurface_t eglCreatePixmapSurface;
+    eglDestroySurface_t eglDestroySurface;
+    eglQuerySurface_t eglQuerySurface;
+    eglBindAPI_t eglBindAPI;
+    eglQueryAPI_t eglQueryAPI;
+    eglWaitClient_t eglWaitClient;
+    eglReleaseThread_t eglReleaseThread;
+    eglCreatePbufferFromClientBuffer_t eglCreatePbufferFromClientBuffer;
+    eglSurfaceAttrib_t eglSurfaceAttrib;
+    eglBindTexImage_t eglBindTexImage;
+    eglReleaseTexImage_t eglReleaseTexImage;
+    eglSwapInterval_t eglSwapInterval;
+    eglCreateContext_t eglCreateContext;
+    eglDestroyContext_t eglDestroyContext;
+    eglMakeCurrent_t eglMakeCurrent;
+    eglGetCurrentContext_t eglGetCurrentContext;
+    eglGetCurrentSurface_t eglGetCurrentSurface;
+    eglGetCurrentDisplay_t eglGetCurrentDisplay;
+    eglQueryContext_t eglQueryContext;
+    eglWaitGL_t eglWaitGL;
+    eglWaitNative_t eglWaitNative;
+    eglSwapBuffers_t eglSwapBuffers;
+    eglCopyBuffers_t eglCopyBuffers;
+    eglGetProcAddress_t eglGetProcAddress;
+    eglLockSurfaceKHR_t eglLockSurfaceKHR;
+    eglUnlockSurfaceKHR_t eglUnlockSurfaceKHR;
+    eglCreateImageKHR_t eglCreateImageKHR;
+    eglDestroyImageKHR_t eglDestroyImageKHR;
+    eglCreateSyncKHR_t eglCreateSyncKHR;
+    eglDestroySyncKHR_t eglDestroySyncKHR;
+    eglClientWaitSyncKHR_t eglClientWaitSyncKHR;
+    eglSignalSyncKHR_t eglSignalSyncKHR;
+    eglGetSyncAttribKHR_t eglGetSyncAttribKHR;
+    eglSetSwapRectangleANDROID_t eglSetSwapRectangleANDROID;
+    //Accessors
+    eglGetError_t set_eglGetError(eglGetError_t f) { eglGetError_t retval = eglGetError; eglGetError = f; return retval;}
+    eglGetDisplay_t set_eglGetDisplay(eglGetDisplay_t f) { eglGetDisplay_t retval = eglGetDisplay; eglGetDisplay = f; return retval;}
+    eglInitialize_t set_eglInitialize(eglInitialize_t f) { eglInitialize_t retval = eglInitialize; eglInitialize = f; return retval;}
+    eglTerminate_t set_eglTerminate(eglTerminate_t f) { eglTerminate_t retval = eglTerminate; eglTerminate = f; return retval;}
+    eglQueryString_t set_eglQueryString(eglQueryString_t f) { eglQueryString_t retval = eglQueryString; eglQueryString = f; return retval;}
+    eglGetConfigs_t set_eglGetConfigs(eglGetConfigs_t f) { eglGetConfigs_t retval = eglGetConfigs; eglGetConfigs = f; return retval;}
+    eglChooseConfig_t set_eglChooseConfig(eglChooseConfig_t f) { eglChooseConfig_t retval = eglChooseConfig; eglChooseConfig = f; return retval;}
+    eglGetConfigAttrib_t set_eglGetConfigAttrib(eglGetConfigAttrib_t f) { eglGetConfigAttrib_t retval = eglGetConfigAttrib; eglGetConfigAttrib = f; return retval;}
+    eglCreateWindowSurface_t set_eglCreateWindowSurface(eglCreateWindowSurface_t f) { eglCreateWindowSurface_t retval = eglCreateWindowSurface; eglCreateWindowSurface = f; return retval;}
+    eglCreatePbufferSurface_t set_eglCreatePbufferSurface(eglCreatePbufferSurface_t f) { eglCreatePbufferSurface_t retval = eglCreatePbufferSurface; eglCreatePbufferSurface = f; return retval;}
+    eglCreatePixmapSurface_t set_eglCreatePixmapSurface(eglCreatePixmapSurface_t f) { eglCreatePixmapSurface_t retval = eglCreatePixmapSurface; eglCreatePixmapSurface = f; return retval;}
+    eglDestroySurface_t set_eglDestroySurface(eglDestroySurface_t f) { eglDestroySurface_t retval = eglDestroySurface; eglDestroySurface = f; return retval;}
+    eglQuerySurface_t set_eglQuerySurface(eglQuerySurface_t f) { eglQuerySurface_t retval = eglQuerySurface; eglQuerySurface = f; return retval;}
+    eglBindAPI_t set_eglBindAPI(eglBindAPI_t f) { eglBindAPI_t retval = eglBindAPI; eglBindAPI = f; return retval;}
+    eglQueryAPI_t set_eglQueryAPI(eglQueryAPI_t f) { eglQueryAPI_t retval = eglQueryAPI; eglQueryAPI = f; return retval;}
+    eglWaitClient_t set_eglWaitClient(eglWaitClient_t f) { eglWaitClient_t retval = eglWaitClient; eglWaitClient = f; return retval;}
+    eglReleaseThread_t set_eglReleaseThread(eglReleaseThread_t f) { eglReleaseThread_t retval = eglReleaseThread; eglReleaseThread = f; return retval;}
+    eglCreatePbufferFromClientBuffer_t set_eglCreatePbufferFromClientBuffer(eglCreatePbufferFromClientBuffer_t f) { eglCreatePbufferFromClientBuffer_t retval = eglCreatePbufferFromClientBuffer; eglCreatePbufferFromClientBuffer = f; return retval;}
+    eglSurfaceAttrib_t set_eglSurfaceAttrib(eglSurfaceAttrib_t f) { eglSurfaceAttrib_t retval = eglSurfaceAttrib; eglSurfaceAttrib = f; return retval;}
+    eglBindTexImage_t set_eglBindTexImage(eglBindTexImage_t f) { eglBindTexImage_t retval = eglBindTexImage; eglBindTexImage = f; return retval;}
+    eglReleaseTexImage_t set_eglReleaseTexImage(eglReleaseTexImage_t f) { eglReleaseTexImage_t retval = eglReleaseTexImage; eglReleaseTexImage = f; return retval;}
+    eglSwapInterval_t set_eglSwapInterval(eglSwapInterval_t f) { eglSwapInterval_t retval = eglSwapInterval; eglSwapInterval = f; return retval;}
+    eglCreateContext_t set_eglCreateContext(eglCreateContext_t f) { eglCreateContext_t retval = eglCreateContext; eglCreateContext = f; return retval;}
+    eglDestroyContext_t set_eglDestroyContext(eglDestroyContext_t f) { eglDestroyContext_t retval = eglDestroyContext; eglDestroyContext = f; return retval;}
+    eglMakeCurrent_t set_eglMakeCurrent(eglMakeCurrent_t f) { eglMakeCurrent_t retval = eglMakeCurrent; eglMakeCurrent = f; return retval;}
+    eglGetCurrentContext_t set_eglGetCurrentContext(eglGetCurrentContext_t f) { eglGetCurrentContext_t retval = eglGetCurrentContext; eglGetCurrentContext = f; return retval;}
+    eglGetCurrentSurface_t set_eglGetCurrentSurface(eglGetCurrentSurface_t f) { eglGetCurrentSurface_t retval = eglGetCurrentSurface; eglGetCurrentSurface = f; return retval;}
+    eglGetCurrentDisplay_t set_eglGetCurrentDisplay(eglGetCurrentDisplay_t f) { eglGetCurrentDisplay_t retval = eglGetCurrentDisplay; eglGetCurrentDisplay = f; return retval;}
+    eglQueryContext_t set_eglQueryContext(eglQueryContext_t f) { eglQueryContext_t retval = eglQueryContext; eglQueryContext = f; return retval;}
+    eglWaitGL_t set_eglWaitGL(eglWaitGL_t f) { eglWaitGL_t retval = eglWaitGL; eglWaitGL = f; return retval;}
+    eglWaitNative_t set_eglWaitNative(eglWaitNative_t f) { eglWaitNative_t retval = eglWaitNative; eglWaitNative = f; return retval;}
+    eglSwapBuffers_t set_eglSwapBuffers(eglSwapBuffers_t f) { eglSwapBuffers_t retval = eglSwapBuffers; eglSwapBuffers = f; return retval;}
+    eglCopyBuffers_t set_eglCopyBuffers(eglCopyBuffers_t f) { eglCopyBuffers_t retval = eglCopyBuffers; eglCopyBuffers = f; return retval;}
+    eglGetProcAddress_t set_eglGetProcAddress(eglGetProcAddress_t f) { eglGetProcAddress_t retval = eglGetProcAddress; eglGetProcAddress = f; return retval;}
+    eglLockSurfaceKHR_t set_eglLockSurfaceKHR(eglLockSurfaceKHR_t f) { eglLockSurfaceKHR_t retval = eglLockSurfaceKHR; eglLockSurfaceKHR = f; return retval;}
+    eglUnlockSurfaceKHR_t set_eglUnlockSurfaceKHR(eglUnlockSurfaceKHR_t f) { eglUnlockSurfaceKHR_t retval = eglUnlockSurfaceKHR; eglUnlockSurfaceKHR = f; return retval;}
+    eglCreateImageKHR_t set_eglCreateImageKHR(eglCreateImageKHR_t f) { eglCreateImageKHR_t retval = eglCreateImageKHR; eglCreateImageKHR = f; return retval;}
+    eglDestroyImageKHR_t set_eglDestroyImageKHR(eglDestroyImageKHR_t f) { eglDestroyImageKHR_t retval = eglDestroyImageKHR; eglDestroyImageKHR = f; return retval;}
+    eglCreateSyncKHR_t set_eglCreateSyncKHR(eglCreateSyncKHR_t f) { eglCreateSyncKHR_t retval = eglCreateSyncKHR; eglCreateSyncKHR = f; return retval;}
+    eglDestroySyncKHR_t set_eglDestroySyncKHR(eglDestroySyncKHR_t f) { eglDestroySyncKHR_t retval = eglDestroySyncKHR; eglDestroySyncKHR = f; return retval;}
+    eglClientWaitSyncKHR_t set_eglClientWaitSyncKHR(eglClientWaitSyncKHR_t f) { eglClientWaitSyncKHR_t retval = eglClientWaitSyncKHR; eglClientWaitSyncKHR = f; return retval;}
+    eglSignalSyncKHR_t set_eglSignalSyncKHR(eglSignalSyncKHR_t f) { eglSignalSyncKHR_t retval = eglSignalSyncKHR; eglSignalSyncKHR = f; return retval;}
+    eglGetSyncAttribKHR_t set_eglGetSyncAttribKHR(eglGetSyncAttribKHR_t f) { eglGetSyncAttribKHR_t retval = eglGetSyncAttribKHR; eglGetSyncAttribKHR = f; return retval;}
+    eglSetSwapRectangleANDROID_t set_eglSetSwapRectangleANDROID(eglSetSwapRectangleANDROID_t f) { eglSetSwapRectangleANDROID_t retval = eglSetSwapRectangleANDROID; eglSetSwapRectangleANDROID = f; return retval;}
+};
+
+egl_dispatch *loadEGL(const char *p_eglPath);
+
+#endif
diff --git a/tools/emulator/opengl/tests/EGL_host_wrapper/egl_ftable.h b/tools/emulator/opengl/tests/EGL_host_wrapper/egl_ftable.h
new file mode 100644
index 0000000..ee40585
--- /dev/null
+++ b/tools/emulator/opengl/tests/EGL_host_wrapper/egl_ftable.h
@@ -0,0 +1,66 @@
+/*
+* 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.
+*/
+static struct _egl_funcs_by_name {
+    const char *name;
+    void *proc;
+} egl_funcs_by_name[] = {
+    {"eglGetError", (void *)eglGetError},
+    {"eglGetDisplay", (void *)eglGetDisplay},
+    {"eglInitialize", (void *)eglInitialize},
+    {"eglTerminate", (void *)eglTerminate},
+    {"eglQueryString", (void *)eglQueryString},
+    {"eglGetConfigs", (void *)eglGetConfigs},
+    {"eglChooseConfig", (void *)eglChooseConfig},
+    {"eglGetConfigAttrib", (void *)eglGetConfigAttrib},
+    {"eglCreateWindowSurface", (void *)eglCreateWindowSurface},
+    {"eglCreatePbufferSurface", (void *)eglCreatePbufferSurface},
+    {"eglCreatePixmapSurface", (void *)eglCreatePixmapSurface},
+    {"eglDestroySurface", (void *)eglDestroySurface},
+    {"eglQuerySurface", (void *)eglQuerySurface},
+    {"eglBindAPI", (void *)eglBindAPI},
+    {"eglQueryAPI", (void *)eglQueryAPI},
+    {"eglWaitClient", (void *)eglWaitClient},
+    {"eglReleaseThread", (void *)eglReleaseThread},
+    {"eglCreatePbufferFromClientBuffer", (void *)eglCreatePbufferFromClientBuffer},
+    {"eglSurfaceAttrib", (void *)eglSurfaceAttrib},
+    {"eglBindTexImage", (void *)eglBindTexImage},
+    {"eglReleaseTexImage", (void *)eglReleaseTexImage},
+    {"eglSwapInterval", (void *)eglSwapInterval},
+    {"eglCreateContext", (void *)eglCreateContext},
+    {"eglDestroyContext", (void *)eglDestroyContext},
+    {"eglMakeCurrent", (void *)eglMakeCurrent},
+    {"eglGetCurrentContext", (void *)eglGetCurrentContext},
+    {"eglGetCurrentSurface", (void *)eglGetCurrentSurface},
+    {"eglGetCurrentDisplay", (void *)eglGetCurrentDisplay},
+    {"eglQueryContext", (void *)eglQueryContext},
+    {"eglWaitGL", (void *)eglWaitGL},
+    {"eglWaitNative", (void *)eglWaitNative},
+    {"eglSwapBuffers", (void *)eglSwapBuffers},
+    {"eglCopyBuffers", (void *)eglCopyBuffers},
+    {"eglGetProcAddress", (void *)eglGetProcAddress},
+    {"eglLockSurfaceKHR", (void *)eglLockSurfaceKHR},
+    {"eglUnlockSurfaceKHR", (void *)eglUnlockSurfaceKHR},
+    {"eglCreateImageKHR", (void *)eglCreateImageKHR},
+    {"eglDestroyImageKHR", (void *)eglDestroyImageKHR},
+    {"eglCreateSyncKHR", (void *)eglCreateSyncKHR},
+    {"eglDestroySyncKHR", (void *)eglDestroySyncKHR},
+    {"eglClientWaitSyncKHR", (void *)eglClientWaitSyncKHR},
+    {"eglSignalSyncKHR", (void *)eglSignalSyncKHR},
+    {"eglGetSyncAttribKHR", (void *)eglGetSyncAttribKHR},
+    {"eglSetSwapRectangleANDROID", (void *)eglSetSwapRectangleANDROID}
+};
+
+static int egl_num_funcs = sizeof(egl_funcs_by_name) / sizeof(struct _egl_funcs_by_name);
diff --git a/tools/emulator/opengl/tests/EGL_host_wrapper/egl_proc.h b/tools/emulator/opengl/tests/EGL_host_wrapper/egl_proc.h
new file mode 100644
index 0000000..140c030
--- /dev/null
+++ b/tools/emulator/opengl/tests/EGL_host_wrapper/egl_proc.h
@@ -0,0 +1,68 @@
+/*
+* 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 _EGL_PROC_H
+#define _EGL_PROC_H
+
+#include <EGL/egl.h>
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/eglext.h>
+
+typedef EGLint (* eglGetError_t) ();
+typedef EGLDisplay (* eglGetDisplay_t) (EGLNativeDisplayType);
+typedef EGLBoolean (* eglInitialize_t) (EGLDisplay, EGLint*, EGLint*);
+typedef EGLBoolean (* eglTerminate_t) (EGLDisplay);
+typedef char* (* eglQueryString_t) (EGLDisplay, EGLint);
+typedef EGLBoolean (* eglGetConfigs_t) (EGLDisplay, EGLConfig*, EGLint, EGLint*);
+typedef EGLBoolean (* eglChooseConfig_t) (EGLDisplay, const EGLint*, EGLConfig*, EGLint, EGLint*);
+typedef EGLBoolean (* eglGetConfigAttrib_t) (EGLDisplay, EGLConfig, EGLint, EGLint*);
+typedef EGLSurface (* eglCreateWindowSurface_t) (EGLDisplay, EGLConfig, EGLNativeWindowType, const EGLint*);
+typedef EGLSurface (* eglCreatePbufferSurface_t) (EGLDisplay, EGLConfig, const EGLint*);
+typedef EGLSurface (* eglCreatePixmapSurface_t) (EGLDisplay, EGLConfig, EGLNativePixmapType, const EGLint*);
+typedef EGLBoolean (* eglDestroySurface_t) (EGLDisplay, EGLSurface);
+typedef EGLBoolean (* eglQuerySurface_t) (EGLDisplay, EGLSurface, EGLint, EGLint*);
+typedef EGLBoolean (* eglBindAPI_t) (EGLenum);
+typedef EGLenum (* eglQueryAPI_t) ();
+typedef EGLBoolean (* eglWaitClient_t) ();
+typedef EGLBoolean (* eglReleaseThread_t) ();
+typedef EGLSurface (* eglCreatePbufferFromClientBuffer_t) (EGLDisplay, EGLenum, EGLClientBuffer, EGLConfig, const EGLint*);
+typedef EGLBoolean (* eglSurfaceAttrib_t) (EGLDisplay, EGLSurface, EGLint, EGLint);
+typedef EGLBoolean (* eglBindTexImage_t) (EGLDisplay, EGLSurface, EGLint);
+typedef EGLBoolean (* eglReleaseTexImage_t) (EGLDisplay, EGLSurface, EGLint);
+typedef EGLBoolean (* eglSwapInterval_t) (EGLDisplay, EGLint);
+typedef EGLContext (* eglCreateContext_t) (EGLDisplay, EGLConfig, EGLContext, const EGLint*);
+typedef EGLBoolean (* eglDestroyContext_t) (EGLDisplay, EGLContext);
+typedef EGLBoolean (* eglMakeCurrent_t) (EGLDisplay, EGLSurface, EGLSurface, EGLContext);
+typedef EGLContext (* eglGetCurrentContext_t) ();
+typedef EGLSurface (* eglGetCurrentSurface_t) (EGLint);
+typedef EGLDisplay (* eglGetCurrentDisplay_t) ();
+typedef EGLBoolean (* eglQueryContext_t) (EGLDisplay, EGLContext, EGLint, EGLint*);
+typedef EGLBoolean (* eglWaitGL_t) ();
+typedef EGLBoolean (* eglWaitNative_t) (EGLint);
+typedef EGLBoolean (* eglSwapBuffers_t) (EGLDisplay, EGLSurface);
+typedef EGLBoolean (* eglCopyBuffers_t) (EGLDisplay, EGLSurface, EGLNativePixmapType);
+typedef __eglMustCastToProperFunctionPointerType (* eglGetProcAddress_t) (const char*);
+typedef EGLBoolean (* eglLockSurfaceKHR_t) (EGLDisplay, EGLSurface, const EGLint*);
+typedef EGLBoolean (* eglUnlockSurfaceKHR_t) (EGLDisplay, EGLSurface);
+typedef EGLImageKHR (* eglCreateImageKHR_t) (EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*);
+typedef EGLBoolean (* eglDestroyImageKHR_t) (EGLDisplay, EGLImageKHR image);
+typedef EGLSyncKHR (* eglCreateSyncKHR_t) (EGLDisplay, EGLenum, const EGLint*);
+typedef EGLBoolean (* eglDestroySyncKHR_t) (EGLDisplay, EGLSyncKHR sync);
+typedef EGLint (* eglClientWaitSyncKHR_t) (EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR timeout);
+typedef EGLBoolean (* eglSignalSyncKHR_t) (EGLDisplay, EGLSyncKHR, EGLenum);
+typedef EGLBoolean (* eglGetSyncAttribKHR_t) (EGLDisplay, EGLSyncKHR, EGLint, EGLint*);
+typedef EGLBoolean (* eglSetSwapRectangleANDROID_t) (EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint);
+
+#endif // of  _EGL_PROC_H
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk b/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
new file mode 100644
index 0000000..ade82a4
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
@@ -0,0 +1,75 @@
+LOCAL_PATH := $(call my-dir)
+
+##### libGLES_emul.so ###########
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES :=  \
+        egl.cpp \
+        egl_dispatch.cpp \
+        gles.cpp \
+        gles_dispatch.cpp \
+        ServerConnection.cpp \
+        ThreadInfo.cpp
+
+# add additional depencies to ensure that the generated code that we depend on
+# is generated
+LOCAL_ADDITIONAL_DEPENDENCIES := \
+	$(TARGET_OUT_SHARED_LIBRARIES)/libut_rendercontrol_enc$(TARGET_SHLIB_SUFFIX) \
+	$(TARGET_OUT_SHARED_LIBRARIES)/libGLESv1_enc$(TARGET_SHLIB_SUFFIX)
+
+
+emulatorOpengl := $(LOCAL_PATH)/../..
+
+LOCAL_C_INCLUDES := $(emulatorOpengl)/system/OpenglCodecCommon \
+		$(call intermediates-dir-for, SHARED_LIBRARIES, libut_rendercontrol_enc) \
+		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv1_enc) \
+        $(emulatorOpengl)/system/GLESv1_enc \
+        $(emulatorOpengl)/tests/ut_rendercontrol_enc 
+
+
+LOCAL_CFLAGS := -DLOG_TAG=\"eglWrapper\"
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
+LOCAL_MODULE := libGLES_emul
+LOCAL_MODULE_TAGS := debug
+LOCAL_PRELINK_MODULE := false
+
+#LOCAL_LDLIBS := -lpthread -ldl
+LOCAL_SHARED_LIBRARIES := libdl libcutils libGLESv1_enc libut_rendercontrol_enc
+LOCAL_STATIC_LIBRARIES := libOpenglCodecCommon
+
+include $(BUILD_SHARED_LIBRARY)
+
+#### egl.cfg ####
+
+# Ensure that this file is only copied to emulator-specific builds.
+# Other builds are device-specific and will provide their own
+# version of this file to point to the appropriate HW EGL libraries.
+#
+ifneq (,$(filter full full_x86 sdk sdk_x86,$(TARGET_PRODUCT)))
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := egl.cfg
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/egl
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_CLASS := ETC
+
+include $(BUILD_PREBUILT)
+endif # TARGET_PRODUCT in 'full sdk full_x86 sdk_x86'
+
+#### gles_emul.cfg ####
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := gles_emul.cfg
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT)/etc
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_CLASS := ETC
+
+include $(BUILD_PREBUILT)
+
+
+
+
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.cpp
new file mode 100644
index 0000000..2a82bfa
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.cpp
@@ -0,0 +1,91 @@
+/*
+* 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 "ServerConnection.h"
+#include <cutils/log.h>
+#include "ThreadInfo.h"
+
+gl_client_context_t *ServerConnection::s_getGlContext()
+{
+    EGLThreadInfo *ti = getEGLThreadInfo();
+    if (ti->serverConn) {
+        return ti->serverConn->m_glEnc;
+    }
+    return NULL;
+}
+
+ServerConnection *ServerConnection::s_getServerConnection()
+{
+    EGLThreadInfo *ti = getEGLThreadInfo();
+    if (!ti->serverConn)
+    {
+        ti->serverConn = new ServerConnection();
+        if (ti->serverConn->create() < 0) {
+            delete ti->serverConn;
+            ti->serverConn = NULL;
+        }
+    }
+
+    return ti->serverConn;
+}
+
+
+ServerConnection::ServerConnection() :
+    m_stream(NULL),
+    m_glEnc(NULL),
+    m_ut_enc(NULL)
+{
+}
+
+ServerConnection::~ServerConnection()
+{
+    delete m_ut_enc;
+    delete m_glEnc;
+    delete m_stream;
+}
+
+
+
+int ServerConnection::create(size_t bufsize,
+                             const char *defaultServer)
+{
+    if (m_stream != NULL) delete(m_stream);
+    m_stream = new TcpStream(bufsize);
+
+    char *s = getenv(ENV_RGL_SERVER);
+    char *hostname;
+    if (s == NULL) {
+        hostname = strdup(defaultServer);
+    } else {
+        hostname = strdup(s);
+    }
+
+    if (m_stream->connect(hostname, CODEC_SERVER_PORT) < 0) {
+        LOGE("couldn't connect to %s\n", hostname);
+        free(hostname);
+        return -1;
+    }
+    LOGI("connecting to server %s\n", hostname);
+    free(hostname);
+
+    m_glEnc = new GLEncoder(m_stream);
+    m_glEnc->setContextAccessor(s_getGlContext);
+
+    m_ut_enc = new ut_rendercontrol_encoder_context_t(m_stream);
+    return 0;
+}
+
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.h b/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.h
new file mode 100644
index 0000000..6eae859
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.h
@@ -0,0 +1,51 @@
+/*
+* 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 _SERVER_CONNECTION_H
+#define _SERVER_CONNECTION_H
+
+#include "GLEncoder.h"
+#include "TcpStream.h"
+#include "codec_defs.h"
+#include "ut_rendercontrol_enc.h"
+#include <pthread.h>
+
+#define ENV_RGL_SERVER "RGL_SERVER"
+#define RGL_DEFAULT_SERVER "10.0.2.2"
+
+class ServerConnection {
+public:
+    ~ServerConnection();
+    int create(size_t buf_size = 4 * 1024 * 1024, const char *defaultServer = RGL_DEFAULT_SERVER);
+    static gl_client_context_t *s_getGlContext();
+    static ServerConnection *s_getServerConnection();
+    GLEncoder *glEncoder() { return m_glEnc; }
+    ut_rendercontrol_encoder_context_t * utEnc() { return m_ut_enc; }
+
+private:
+    ServerConnection();
+
+private:
+    static pthread_key_t s_glKey;
+    static pthread_key_t s_connectionKey;
+    static void s_initKeys();
+    TcpStream *m_stream;
+    GLEncoder *m_glEnc;
+    ut_rendercontrol_encoder_context_t *m_ut_enc;
+
+};
+
+
+#endif
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/ThreadInfo.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/ThreadInfo.cpp
new file mode 100644
index 0000000..5bf6a7d
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ThreadInfo.cpp
@@ -0,0 +1,39 @@
+/*
+* 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 "ThreadInfo.h"
+#include "cutils/threads.h"
+
+thread_store_t s_tls = THREAD_STORE_INITIALIZER;
+
+static void tlsDestruct(void *ptr)
+{
+    if (ptr) {
+        EGLThreadInfo *ti = (EGLThreadInfo *)ptr;
+        delete ti->serverConn;
+        delete ti;
+    }
+}
+
+EGLThreadInfo *getEGLThreadInfo()
+{
+    EGLThreadInfo *ti = (EGLThreadInfo *)thread_store_get(&s_tls);
+    if (ti) return ti;
+
+    ti = new EGLThreadInfo();
+    thread_store_set(&s_tls, ti, tlsDestruct);
+
+    return ti;
+}
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/ThreadInfo.h b/tools/emulator/opengl/tests/gles_android_wrapper/ThreadInfo.h
new file mode 100644
index 0000000..f980195
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ThreadInfo.h
@@ -0,0 +1,47 @@
+/*
+* 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 _THREAD_INFO_H
+#define _THREAD_INFO_H
+
+#include "ServerConnection.h"
+#include <EGL/egl.h>
+
+struct EGLWrapperContext
+{
+    EGLWrapperContext(EGLContext p_aglContext) {
+        aglContext = p_aglContext;
+        clientState = NULL;
+    }
+
+    ~EGLWrapperContext() {
+        delete clientState;
+    }
+
+    EGLContext aglContext;
+    GLClientState *clientState;
+};
+
+struct EGLThreadInfo
+{
+    EGLThreadInfo() : currentContext(NULL), serverConn(NULL) {}
+
+    EGLWrapperContext *currentContext;
+    ServerConnection *serverConn;
+};
+
+
+EGLThreadInfo *getEGLThreadInfo();
+#endif
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/egl.cfg b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cfg
new file mode 100644
index 0000000..891b07d
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cfg
@@ -0,0 +1 @@
+0 0 emul
\ No newline at end of file
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp
new file mode 100644
index 0000000..ea78bbb
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp
@@ -0,0 +1,513 @@
+/*
+* 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.
+*/
+
+//
+// WARNING -------------------------- WARNING
+// This code meant to be used for testing purposes only. It is not production
+// level quality.
+// Use on your own risk !!
+//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include "egl_dispatch.h"
+#include "egl_ftable.h"
+#include <cutils/process_name.h>
+#include <cutils/log.h>
+#include "ServerConnection.h"
+#include "ThreadInfo.h"
+#include <pthread.h>
+
+
+#define GLES_EMUL_TARGETS_FILE "/system/etc/gles_emul.cfg"
+
+static struct egl_dispatch *s_dispatch = NULL;
+pthread_once_t dispatchTablesInitialized = PTHREAD_ONCE_INIT;
+
+static bool s_needEncode = false;
+
+extern void init_gles(void *gles_android);
+extern __eglMustCastToProperFunctionPointerType gles_getProcAddress(const char *procname);
+
+
+const char *getProcName()
+{
+    static const char *procname = NULL;
+
+    if (procname == NULL) {
+        const char *str = get_process_name();
+        if (strcmp(str, "unknown") != 0) {
+            procname = str;
+        } else {
+            // we need to obtain our process name from the command line;
+            FILE *fp = fopen("/proc/self/cmdline", "rt");
+            if (fp == NULL) {
+                LOGE("couldn't open /proc/self/cmdline\n");
+                return NULL;
+            }
+
+            char line[1000];
+            if (fgets(line, sizeof(line), fp) == NULL) {
+                LOGE("couldn't read the self cmdline from \n");
+                fclose(fp);
+                return NULL;
+            }
+            fclose(fp);
+
+            if (line[0] == '\0') {
+                LOGE("cmdline is empty\n");
+                return NULL;
+            }
+
+            //obtain the basename;
+            line[sizeof(line) - 1] = '\0';
+            char *p = line;
+            while (*p != '\0' &&
+                   *p != '\t' &&
+                   *p != ' ' &&
+                   *p != '\n') {
+                p++;
+            }
+
+            *p = '\0'; p--;
+            while (p > line && *p != '/') p--;
+            if (*p == '/') p++;
+            procname = strdup(p);
+        }
+    }
+    LOGD("getProcessName: %s\n", procname == NULL ? "NULL": procname);
+
+    return procname;
+}
+
+
+
+bool isNeedEncode()
+{
+    const char *procname = getProcName();
+    if (procname == NULL) return false;
+    LOGD("isNeedEncode? for %s\n", procname);
+    // check on our whitelist
+    FILE *fp = fopen(GLES_EMUL_TARGETS_FILE, "rt");
+    if (fp == NULL) {
+        LOGE("couldn't open %s\n", GLES_EMUL_TARGETS_FILE);
+        return false;
+    }
+
+    char line[100];
+    bool found = false;
+    size_t  procnameLen = strlen(procname);
+
+    while (fgets(line, sizeof(line), fp) != NULL) {
+        if (strlen(line) >= procnameLen &&
+            !strncmp(procname, line, procnameLen)) {
+            char c = line[procnameLen];
+            if (c == '\0' || c == ' ' || c == '\t' || c == '\n') {
+                found = true;
+                LOGD("should use encoder for %s\n", procname);
+                break;
+            }
+        }
+    }
+    fclose(fp);
+    return found;
+}
+
+void initDispatchTables()
+{
+    //
+    // Load our back-end implementation of EGL/GLES
+    //
+    LOGD("Loading egl dispatch for %s\n", getProcName());
+
+    void *gles_android = dlopen("/system/lib/egl/libGLES_android.so", RTLD_NOW | RTLD_LOCAL);
+    if (!gles_android) {
+        fprintf(stderr,"FATAL ERROR: Could not load libGLES_android lib\n");
+        exit(-1);
+    }
+
+    //
+    // Load back-end EGL implementation library
+    //
+    s_dispatch = create_egl_dispatch( gles_android );
+    if (!s_dispatch) {
+        fprintf(stderr,"FATAL ERROR: Could not create egl dispatch\n");
+        exit(-1);
+    }
+
+    //
+    // initialize gles
+    //
+    s_needEncode = isNeedEncode();
+    void *gles_encoder = NULL;
+    if (s_needEncode) {
+        ServerConnection * connection = ServerConnection::s_getServerConnection();
+        if (connection == NULL) {
+            LOGE("couldn't create server connection\n");
+            s_needEncode = false;
+        } else {
+            LOGD("Created server connection for %s\n", getProcName());
+            gles_encoder = dlopen("/system/lib/libGLESv1_enc.so", RTLD_NOW);
+            if (gles_encoder == NULL) {
+                LOGE("couldn't open libGLESv1_enc.so... aborting connection");
+                delete connection;
+                s_needEncode = false;
+            }
+        }
+    }
+
+    if (s_needEncode && gles_encoder) {
+        init_gles(gles_encoder);
+    } else {
+        LOGD("Initializing native opengl for %s\n", getProcName());
+        init_gles(gles_android);
+    }
+}
+
+static struct egl_dispatch *getDispatch()
+{
+    pthread_once(&dispatchTablesInitialized, initDispatchTables);
+    return s_dispatch;
+}
+
+__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
+{
+
+    // search in EGL function table
+    for (int i=0; i<egl_num_funcs; i++) {
+        if (!strcmp(egl_funcs_by_name[i].name, procname)) {
+            return (__eglMustCastToProperFunctionPointerType)egl_funcs_by_name[i].proc;
+        }
+    }
+
+    // search in GLES function table
+    __eglMustCastToProperFunctionPointerType f = gles_getProcAddress(procname);
+    if (f != NULL) {
+        return f;
+    }
+
+    // should probably fail - search in back-end anyway.
+    return getDispatch()->eglGetProcAddress(procname);
+}
+
+////////////////  Path through functions //////////
+
+EGLint eglGetError()
+{
+    return getDispatch()->eglGetError();
+}
+
+EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
+{
+    return getDispatch()->eglGetDisplay(display_id);
+}
+
+EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+    return getDispatch()->eglInitialize(dpy, major, minor);
+}
+
+EGLBoolean eglTerminate(EGLDisplay dpy)
+{
+    return getDispatch()->eglTerminate(dpy);
+}
+
+const char* eglQueryString(EGLDisplay dpy, EGLint name)
+{
+    return getDispatch()->eglQueryString(dpy, name);
+}
+
+EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+    return getDispatch()->eglGetConfigs(dpy, configs, config_size, num_config);
+}
+
+EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+    return getDispatch()->eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
+}
+
+EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+{
+    return getDispatch()->eglGetConfigAttrib(dpy, config, attribute, value);
+}
+
+EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
+{
+    EGLSurface surface =  getDispatch()->eglCreateWindowSurface(dpy, config, win, attrib_list);
+    if (surface != EGL_NO_SURFACE) {
+        ServerConnection *server;
+        if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) {
+            server->utEnc()->createSurface(server->utEnc(), getpid(), (uint32_t)surface);
+        }
+    }
+    return surface;
+}
+
+EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+{
+    EGLSurface surface =  getDispatch()->eglCreatePbufferSurface(dpy, config, attrib_list);
+    if (surface != EGL_NO_SURFACE) {
+        ServerConnection *server;
+        if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) {
+            server->utEnc()->createSurface(server->utEnc(), getpid(), (uint32_t)surface);
+        }
+    }
+    return surface;
+}
+
+EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
+{
+    EGLSurface surface =  getDispatch()->eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
+    if (surface != EGL_NO_SURFACE) {
+        ServerConnection *server;
+        if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) {
+            server->utEnc()->createSurface(server->utEnc(), getpid(), (uint32_t)surface);
+        }
+    }
+    return surface;
+}
+
+EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+{
+    EGLBoolean res =  getDispatch()->eglDestroySurface(dpy, surface);
+    if (res && surface != EGL_NO_SURFACE) {
+        ServerConnection *server;
+        if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) {
+            server->utEnc()->destroySurface(server->utEnc(), getpid(), (uint32_t)surface);
+        }
+    }
+    return res;
+}
+
+EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
+{
+    return getDispatch()->eglQuerySurface(dpy, surface, attribute, value);
+}
+
+EGLBoolean eglBindAPI(EGLenum api)
+{
+    return getDispatch()->eglBindAPI(api);
+}
+
+EGLenum eglQueryAPI()
+{
+    return getDispatch()->eglQueryAPI();
+}
+
+EGLBoolean eglWaitClient()
+{
+    return getDispatch()->eglWaitClient();
+}
+
+EGLBoolean eglReleaseThread()
+{
+    return getDispatch()->eglReleaseThread();
+}
+
+EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+{
+    return getDispatch()->eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
+}
+
+EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+{
+    return getDispatch()->eglSurfaceAttrib(dpy, surface, attribute, value);
+}
+
+EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+    return getDispatch()->eglBindTexImage(dpy, surface, buffer);
+}
+
+EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+    return getDispatch()->eglReleaseTexImage(dpy, surface, buffer);
+}
+
+EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
+{
+    return getDispatch()->eglSwapInterval(dpy, interval);
+}
+
+EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
+{
+    EGLContext share = share_context;
+    if (share) share = ((EGLWrapperContext *)share_context)->aglContext;
+
+    EGLContext ctx =  getDispatch()->eglCreateContext(dpy, config, share, attrib_list);
+    EGLWrapperContext *wctx = new EGLWrapperContext(ctx);
+    if (ctx != EGL_NO_CONTEXT) {
+        ServerConnection *server;
+        if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) {
+            wctx->clientState = new GLClientState();
+            server->utEnc()->createContext(server->utEnc(), getpid(),
+                                           (uint32_t)wctx,
+                                           (uint32_t)(share_context == EGL_NO_CONTEXT ? 0 : share_context));
+        }
+    }
+    return (EGLContext)wctx;
+}
+
+EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+    EGLWrapperContext *wctx = (EGLWrapperContext *)ctx;
+    EGLBoolean res = EGL_FALSE;
+
+    if (ctx && ctx != EGL_NO_CONTEXT) {
+        res = getDispatch()->eglDestroyContext(dpy, wctx->aglContext);
+        if (res) {
+            EGLThreadInfo *ti = getEGLThreadInfo();
+            if (s_needEncode && ti->serverConn) {
+                ti->serverConn->utEnc()->destroyContext(ti->serverConn->utEnc(), getpid(), (uint32_t)ctx);
+            }
+            if (ti->currentContext == wctx) ti->currentContext = NULL;
+            delete wctx;
+        }
+    }
+
+    return res;
+}
+
+EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+    EGLWrapperContext *wctx = (EGLWrapperContext *)ctx;
+    EGLContext aglContext = (ctx == EGL_NO_CONTEXT ? EGL_NO_CONTEXT : wctx->aglContext);
+    EGLThreadInfo *ti = getEGLThreadInfo();
+    EGLBoolean res = getDispatch()->eglMakeCurrent(dpy, draw, read, aglContext);
+    if (res ) {
+        ServerConnection *server;
+        if (s_needEncode && ti->serverConn) {
+            ti->serverConn->utEnc()->makeCurrentContext(ti->serverConn->utEnc(), getpid(),
+                                                (uint32_t) (draw == EGL_NO_SURFACE ? 0 : draw),
+                                                (uint32_t) (read == EGL_NO_SURFACE ? 0 : read),
+                                                (uint32_t) (ctx == EGL_NO_CONTEXT ? 0 : ctx));
+            ti->serverConn->glEncoder()->setClientState( wctx ? wctx->clientState : NULL );
+        }
+
+        // set current context in our thread info
+        ti->currentContext = wctx;
+    }
+    return res;
+
+}
+
+EGLContext eglGetCurrentContext()
+{
+    EGLThreadInfo *ti = getEGLThreadInfo();
+    return (ti->currentContext ? ti->currentContext : EGL_NO_CONTEXT);
+}
+
+EGLSurface eglGetCurrentSurface(EGLint readdraw)
+{
+    return getDispatch()->eglGetCurrentSurface(readdraw);
+}
+
+EGLDisplay eglGetCurrentDisplay()
+{
+    return getDispatch()->eglGetCurrentDisplay();
+}
+
+EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+{
+    EGLWrapperContext *wctx = (EGLWrapperContext *)ctx;
+    if (wctx) {
+        return getDispatch()->eglQueryContext(dpy, wctx->aglContext, attribute, value);
+    }
+    else {
+        return EGL_BAD_CONTEXT;
+    }
+}
+
+EGLBoolean eglWaitGL()
+{
+    return getDispatch()->eglWaitGL();
+}
+
+EGLBoolean eglWaitNative(EGLint engine)
+{
+    return getDispatch()->eglWaitNative(engine);
+}
+
+EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
+{
+    ServerConnection *server;
+    if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) {
+        server->utEnc()->swapBuffers(server->utEnc(), getpid(), (uint32_t)surface);
+        server->glEncoder()->flush();
+        return 1;
+    }
+    return getDispatch()->eglSwapBuffers(dpy, surface);
+}
+
+EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+{
+    return getDispatch()->eglCopyBuffers(dpy, surface, target);
+}
+
+EGLBoolean eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
+{
+    return getDispatch()->eglLockSurfaceKHR(display, surface, attrib_list);
+}
+
+EGLBoolean eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
+{
+    return getDispatch()->eglUnlockSurfaceKHR(display, surface);
+}
+
+EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+    EGLWrapperContext *wctx = (EGLWrapperContext *)ctx;
+    EGLContext aglContext = (wctx ? wctx->aglContext : EGL_NO_CONTEXT);
+    return getDispatch()->eglCreateImageKHR(dpy, aglContext, target, buffer, attrib_list);
+}
+
+EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
+{
+    return getDispatch()->eglDestroyImageKHR(dpy, image);
+}
+
+EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
+{
+    return getDispatch()->eglCreateSyncKHR(dpy, type, attrib_list);
+}
+
+EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
+{
+    return getDispatch()->eglDestroySyncKHR(dpy, sync);
+}
+
+EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
+{
+    return getDispatch()->eglClientWaitSyncKHR(dpy, sync, flags, timeout);
+}
+
+EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
+{
+    return getDispatch()->eglSignalSyncKHR(dpy, sync, mode);
+}
+
+EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
+{
+    return getDispatch()->eglGetSyncAttribKHR(dpy, sync, attribute, value);
+}
+
+EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height)
+{
+    return getDispatch()->eglSetSwapRectangleANDROID(dpy, draw, left, top, width, height);
+}
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/egl_dispatch.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/egl_dispatch.cpp
new file mode 100644
index 0000000..f69ca61
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl_dispatch.cpp
@@ -0,0 +1,71 @@
+/*
+* 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 "egl_dispatch.h"
+#include <dlfcn.h>
+
+egl_dispatch *create_egl_dispatch(void *gles_android)
+{
+        egl_dispatch *disp = new egl_dispatch;
+
+    void *ptr;
+    ptr = dlsym(gles_android,"eglGetError"); disp->set_eglGetError((eglGetError_t)ptr);
+    ptr = dlsym(gles_android,"eglGetDisplay"); disp->set_eglGetDisplay((eglGetDisplay_t)ptr);
+    ptr = dlsym(gles_android,"eglInitialize"); disp->set_eglInitialize((eglInitialize_t)ptr);
+    ptr = dlsym(gles_android,"eglTerminate"); disp->set_eglTerminate((eglTerminate_t)ptr);
+    ptr = dlsym(gles_android,"eglQueryString"); disp->set_eglQueryString((eglQueryString_t)ptr);
+    ptr = dlsym(gles_android,"eglGetConfigs"); disp->set_eglGetConfigs((eglGetConfigs_t)ptr);
+    ptr = dlsym(gles_android,"eglChooseConfig"); disp->set_eglChooseConfig((eglChooseConfig_t)ptr);
+    ptr = dlsym(gles_android,"eglGetConfigAttrib"); disp->set_eglGetConfigAttrib((eglGetConfigAttrib_t)ptr);
+    ptr = dlsym(gles_android,"eglCreateWindowSurface"); disp->set_eglCreateWindowSurface((eglCreateWindowSurface_t)ptr);
+    ptr = dlsym(gles_android,"eglCreatePbufferSurface"); disp->set_eglCreatePbufferSurface((eglCreatePbufferSurface_t)ptr);
+    ptr = dlsym(gles_android,"eglCreatePixmapSurface"); disp->set_eglCreatePixmapSurface((eglCreatePixmapSurface_t)ptr);
+    ptr = dlsym(gles_android,"eglDestroySurface"); disp->set_eglDestroySurface((eglDestroySurface_t)ptr);
+    ptr = dlsym(gles_android,"eglQuerySurface"); disp->set_eglQuerySurface((eglQuerySurface_t)ptr);
+    ptr = dlsym(gles_android,"eglBindAPI"); disp->set_eglBindAPI((eglBindAPI_t)ptr);
+    ptr = dlsym(gles_android,"eglQueryAPI"); disp->set_eglQueryAPI((eglQueryAPI_t)ptr);
+    ptr = dlsym(gles_android,"eglWaitClient"); disp->set_eglWaitClient((eglWaitClient_t)ptr);
+    ptr = dlsym(gles_android,"eglReleaseThread"); disp->set_eglReleaseThread((eglReleaseThread_t)ptr);
+    ptr = dlsym(gles_android,"eglCreatePbufferFromClientBuffer"); disp->set_eglCreatePbufferFromClientBuffer((eglCreatePbufferFromClientBuffer_t)ptr);
+    ptr = dlsym(gles_android,"eglSurfaceAttrib"); disp->set_eglSurfaceAttrib((eglSurfaceAttrib_t)ptr);
+    ptr = dlsym(gles_android,"eglBindTexImage"); disp->set_eglBindTexImage((eglBindTexImage_t)ptr);
+    ptr = dlsym(gles_android,"eglReleaseTexImage"); disp->set_eglReleaseTexImage((eglReleaseTexImage_t)ptr);
+    ptr = dlsym(gles_android,"eglSwapInterval"); disp->set_eglSwapInterval((eglSwapInterval_t)ptr);
+    ptr = dlsym(gles_android,"eglCreateContext"); disp->set_eglCreateContext((eglCreateContext_t)ptr);
+    ptr = dlsym(gles_android,"eglDestroyContext"); disp->set_eglDestroyContext((eglDestroyContext_t)ptr);
+    ptr = dlsym(gles_android,"eglMakeCurrent"); disp->set_eglMakeCurrent((eglMakeCurrent_t)ptr);
+    ptr = dlsym(gles_android,"eglGetCurrentContext"); disp->set_eglGetCurrentContext((eglGetCurrentContext_t)ptr);
+    ptr = dlsym(gles_android,"eglGetCurrentSurface"); disp->set_eglGetCurrentSurface((eglGetCurrentSurface_t)ptr);
+    ptr = dlsym(gles_android,"eglGetCurrentDisplay"); disp->set_eglGetCurrentDisplay((eglGetCurrentDisplay_t)ptr);
+    ptr = dlsym(gles_android,"eglQueryContext"); disp->set_eglQueryContext((eglQueryContext_t)ptr);
+    ptr = dlsym(gles_android,"eglWaitGL"); disp->set_eglWaitGL((eglWaitGL_t)ptr);
+    ptr = dlsym(gles_android,"eglWaitNative"); disp->set_eglWaitNative((eglWaitNative_t)ptr);
+    ptr = dlsym(gles_android,"eglSwapBuffers"); disp->set_eglSwapBuffers((eglSwapBuffers_t)ptr);
+    ptr = dlsym(gles_android,"eglCopyBuffers"); disp->set_eglCopyBuffers((eglCopyBuffers_t)ptr);
+    ptr = dlsym(gles_android,"eglGetProcAddress"); disp->set_eglGetProcAddress((eglGetProcAddress_t)ptr);
+    ptr = dlsym(gles_android,"eglLockSurfaceKHR"); disp->set_eglLockSurfaceKHR((eglLockSurfaceKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglUnlockSurfaceKHR"); disp->set_eglUnlockSurfaceKHR((eglUnlockSurfaceKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglCreateImageKHR"); disp->set_eglCreateImageKHR((eglCreateImageKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglDestroyImageKHR"); disp->set_eglDestroyImageKHR((eglDestroyImageKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglCreateSyncKHR"); disp->set_eglCreateSyncKHR((eglCreateSyncKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglDestroySyncKHR"); disp->set_eglDestroySyncKHR((eglDestroySyncKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglClientWaitSyncKHR"); disp->set_eglClientWaitSyncKHR((eglClientWaitSyncKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglSignalSyncKHR"); disp->set_eglSignalSyncKHR((eglSignalSyncKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglGetSyncAttribKHR"); disp->set_eglGetSyncAttribKHR((eglGetSyncAttribKHR_t)ptr);
+    ptr = dlsym(gles_android,"eglSetSwapRectangleANDROID"); disp->set_eglSetSwapRectangleANDROID((eglSetSwapRectangleANDROID_t)ptr);
+
+        return disp;
+}
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/egl_dispatch.h b/tools/emulator/opengl/tests/gles_android_wrapper/egl_dispatch.h
new file mode 100644
index 0000000..1b8de0d
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl_dispatch.h
@@ -0,0 +1,115 @@
+/*
+* 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 _EGL_DISPATCH_H
+#define _EGL_DISPATCH_H
+
+#include "egl_proc.h"
+
+struct egl_dispatch {
+    eglGetError_t eglGetError;
+    eglGetDisplay_t eglGetDisplay;
+    eglInitialize_t eglInitialize;
+    eglTerminate_t eglTerminate;
+    eglQueryString_t eglQueryString;
+    eglGetConfigs_t eglGetConfigs;
+    eglChooseConfig_t eglChooseConfig;
+    eglGetConfigAttrib_t eglGetConfigAttrib;
+    eglCreateWindowSurface_t eglCreateWindowSurface;
+    eglCreatePbufferSurface_t eglCreatePbufferSurface;
+    eglCreatePixmapSurface_t eglCreatePixmapSurface;
+    eglDestroySurface_t eglDestroySurface;
+    eglQuerySurface_t eglQuerySurface;
+    eglBindAPI_t eglBindAPI;
+    eglQueryAPI_t eglQueryAPI;
+    eglWaitClient_t eglWaitClient;
+    eglReleaseThread_t eglReleaseThread;
+    eglCreatePbufferFromClientBuffer_t eglCreatePbufferFromClientBuffer;
+    eglSurfaceAttrib_t eglSurfaceAttrib;
+    eglBindTexImage_t eglBindTexImage;
+    eglReleaseTexImage_t eglReleaseTexImage;
+    eglSwapInterval_t eglSwapInterval;
+    eglCreateContext_t eglCreateContext;
+    eglDestroyContext_t eglDestroyContext;
+    eglMakeCurrent_t eglMakeCurrent;
+    eglGetCurrentContext_t eglGetCurrentContext;
+    eglGetCurrentSurface_t eglGetCurrentSurface;
+    eglGetCurrentDisplay_t eglGetCurrentDisplay;
+    eglQueryContext_t eglQueryContext;
+    eglWaitGL_t eglWaitGL;
+    eglWaitNative_t eglWaitNative;
+    eglSwapBuffers_t eglSwapBuffers;
+    eglCopyBuffers_t eglCopyBuffers;
+    eglGetProcAddress_t eglGetProcAddress;
+    eglLockSurfaceKHR_t eglLockSurfaceKHR;
+    eglUnlockSurfaceKHR_t eglUnlockSurfaceKHR;
+    eglCreateImageKHR_t eglCreateImageKHR;
+    eglDestroyImageKHR_t eglDestroyImageKHR;
+    eglCreateSyncKHR_t eglCreateSyncKHR;
+    eglDestroySyncKHR_t eglDestroySyncKHR;
+    eglClientWaitSyncKHR_t eglClientWaitSyncKHR;
+    eglSignalSyncKHR_t eglSignalSyncKHR;
+    eglGetSyncAttribKHR_t eglGetSyncAttribKHR;
+    eglSetSwapRectangleANDROID_t eglSetSwapRectangleANDROID;
+    //Accessors
+    eglGetError_t set_eglGetError(eglGetError_t f) { eglGetError_t retval = eglGetError; eglGetError = f; return retval;}
+    eglGetDisplay_t set_eglGetDisplay(eglGetDisplay_t f) { eglGetDisplay_t retval = eglGetDisplay; eglGetDisplay = f; return retval;}
+    eglInitialize_t set_eglInitialize(eglInitialize_t f) { eglInitialize_t retval = eglInitialize; eglInitialize = f; return retval;}
+    eglTerminate_t set_eglTerminate(eglTerminate_t f) { eglTerminate_t retval = eglTerminate; eglTerminate = f; return retval;}
+    eglQueryString_t set_eglQueryString(eglQueryString_t f) { eglQueryString_t retval = eglQueryString; eglQueryString = f; return retval;}
+    eglGetConfigs_t set_eglGetConfigs(eglGetConfigs_t f) { eglGetConfigs_t retval = eglGetConfigs; eglGetConfigs = f; return retval;}
+    eglChooseConfig_t set_eglChooseConfig(eglChooseConfig_t f) { eglChooseConfig_t retval = eglChooseConfig; eglChooseConfig = f; return retval;}
+    eglGetConfigAttrib_t set_eglGetConfigAttrib(eglGetConfigAttrib_t f) { eglGetConfigAttrib_t retval = eglGetConfigAttrib; eglGetConfigAttrib = f; return retval;}
+    eglCreateWindowSurface_t set_eglCreateWindowSurface(eglCreateWindowSurface_t f) { eglCreateWindowSurface_t retval = eglCreateWindowSurface; eglCreateWindowSurface = f; return retval;}
+    eglCreatePbufferSurface_t set_eglCreatePbufferSurface(eglCreatePbufferSurface_t f) { eglCreatePbufferSurface_t retval = eglCreatePbufferSurface; eglCreatePbufferSurface = f; return retval;}
+    eglCreatePixmapSurface_t set_eglCreatePixmapSurface(eglCreatePixmapSurface_t f) { eglCreatePixmapSurface_t retval = eglCreatePixmapSurface; eglCreatePixmapSurface = f; return retval;}
+    eglDestroySurface_t set_eglDestroySurface(eglDestroySurface_t f) { eglDestroySurface_t retval = eglDestroySurface; eglDestroySurface = f; return retval;}
+    eglQuerySurface_t set_eglQuerySurface(eglQuerySurface_t f) { eglQuerySurface_t retval = eglQuerySurface; eglQuerySurface = f; return retval;}
+    eglBindAPI_t set_eglBindAPI(eglBindAPI_t f) { eglBindAPI_t retval = eglBindAPI; eglBindAPI = f; return retval;}
+    eglQueryAPI_t set_eglQueryAPI(eglQueryAPI_t f) { eglQueryAPI_t retval = eglQueryAPI; eglQueryAPI = f; return retval;}
+    eglWaitClient_t set_eglWaitClient(eglWaitClient_t f) { eglWaitClient_t retval = eglWaitClient; eglWaitClient = f; return retval;}
+    eglReleaseThread_t set_eglReleaseThread(eglReleaseThread_t f) { eglReleaseThread_t retval = eglReleaseThread; eglReleaseThread = f; return retval;}
+    eglCreatePbufferFromClientBuffer_t set_eglCreatePbufferFromClientBuffer(eglCreatePbufferFromClientBuffer_t f) { eglCreatePbufferFromClientBuffer_t retval = eglCreatePbufferFromClientBuffer; eglCreatePbufferFromClientBuffer = f; return retval;}
+    eglSurfaceAttrib_t set_eglSurfaceAttrib(eglSurfaceAttrib_t f) { eglSurfaceAttrib_t retval = eglSurfaceAttrib; eglSurfaceAttrib = f; return retval;}
+    eglBindTexImage_t set_eglBindTexImage(eglBindTexImage_t f) { eglBindTexImage_t retval = eglBindTexImage; eglBindTexImage = f; return retval;}
+    eglReleaseTexImage_t set_eglReleaseTexImage(eglReleaseTexImage_t f) { eglReleaseTexImage_t retval = eglReleaseTexImage; eglReleaseTexImage = f; return retval;}
+    eglSwapInterval_t set_eglSwapInterval(eglSwapInterval_t f) { eglSwapInterval_t retval = eglSwapInterval; eglSwapInterval = f; return retval;}
+    eglCreateContext_t set_eglCreateContext(eglCreateContext_t f) { eglCreateContext_t retval = eglCreateContext; eglCreateContext = f; return retval;}
+    eglDestroyContext_t set_eglDestroyContext(eglDestroyContext_t f) { eglDestroyContext_t retval = eglDestroyContext; eglDestroyContext = f; return retval;}
+    eglMakeCurrent_t set_eglMakeCurrent(eglMakeCurrent_t f) { eglMakeCurrent_t retval = eglMakeCurrent; eglMakeCurrent = f; return retval;}
+    eglGetCurrentContext_t set_eglGetCurrentContext(eglGetCurrentContext_t f) { eglGetCurrentContext_t retval = eglGetCurrentContext; eglGetCurrentContext = f; return retval;}
+    eglGetCurrentSurface_t set_eglGetCurrentSurface(eglGetCurrentSurface_t f) { eglGetCurrentSurface_t retval = eglGetCurrentSurface; eglGetCurrentSurface = f; return retval;}
+    eglGetCurrentDisplay_t set_eglGetCurrentDisplay(eglGetCurrentDisplay_t f) { eglGetCurrentDisplay_t retval = eglGetCurrentDisplay; eglGetCurrentDisplay = f; return retval;}
+    eglQueryContext_t set_eglQueryContext(eglQueryContext_t f) { eglQueryContext_t retval = eglQueryContext; eglQueryContext = f; return retval;}
+    eglWaitGL_t set_eglWaitGL(eglWaitGL_t f) { eglWaitGL_t retval = eglWaitGL; eglWaitGL = f; return retval;}
+    eglWaitNative_t set_eglWaitNative(eglWaitNative_t f) { eglWaitNative_t retval = eglWaitNative; eglWaitNative = f; return retval;}
+    eglSwapBuffers_t set_eglSwapBuffers(eglSwapBuffers_t f) { eglSwapBuffers_t retval = eglSwapBuffers; eglSwapBuffers = f; return retval;}
+    eglCopyBuffers_t set_eglCopyBuffers(eglCopyBuffers_t f) { eglCopyBuffers_t retval = eglCopyBuffers; eglCopyBuffers = f; return retval;}
+    eglGetProcAddress_t set_eglGetProcAddress(eglGetProcAddress_t f) { eglGetProcAddress_t retval = eglGetProcAddress; eglGetProcAddress = f; return retval;}
+    eglLockSurfaceKHR_t set_eglLockSurfaceKHR(eglLockSurfaceKHR_t f) { eglLockSurfaceKHR_t retval = eglLockSurfaceKHR; eglLockSurfaceKHR = f; return retval;}
+    eglUnlockSurfaceKHR_t set_eglUnlockSurfaceKHR(eglUnlockSurfaceKHR_t f) { eglUnlockSurfaceKHR_t retval = eglUnlockSurfaceKHR; eglUnlockSurfaceKHR = f; return retval;}
+    eglCreateImageKHR_t set_eglCreateImageKHR(eglCreateImageKHR_t f) { eglCreateImageKHR_t retval = eglCreateImageKHR; eglCreateImageKHR = f; return retval;}
+    eglDestroyImageKHR_t set_eglDestroyImageKHR(eglDestroyImageKHR_t f) { eglDestroyImageKHR_t retval = eglDestroyImageKHR; eglDestroyImageKHR = f; return retval;}
+    eglCreateSyncKHR_t set_eglCreateSyncKHR(eglCreateSyncKHR_t f) { eglCreateSyncKHR_t retval = eglCreateSyncKHR; eglCreateSyncKHR = f; return retval;}
+    eglDestroySyncKHR_t set_eglDestroySyncKHR(eglDestroySyncKHR_t f) { eglDestroySyncKHR_t retval = eglDestroySyncKHR; eglDestroySyncKHR = f; return retval;}
+    eglClientWaitSyncKHR_t set_eglClientWaitSyncKHR(eglClientWaitSyncKHR_t f) { eglClientWaitSyncKHR_t retval = eglClientWaitSyncKHR; eglClientWaitSyncKHR = f; return retval;}
+    eglSignalSyncKHR_t set_eglSignalSyncKHR(eglSignalSyncKHR_t f) { eglSignalSyncKHR_t retval = eglSignalSyncKHR; eglSignalSyncKHR = f; return retval;}
+    eglGetSyncAttribKHR_t set_eglGetSyncAttribKHR(eglGetSyncAttribKHR_t f) { eglGetSyncAttribKHR_t retval = eglGetSyncAttribKHR; eglGetSyncAttribKHR = f; return retval;}
+    eglSetSwapRectangleANDROID_t set_eglSetSwapRectangleANDROID(eglSetSwapRectangleANDROID_t f) { eglSetSwapRectangleANDROID_t retval = eglSetSwapRectangleANDROID; eglSetSwapRectangleANDROID = f; return retval;}
+};
+
+egl_dispatch *create_egl_dispatch(void *gles_andorid);
+
+#endif
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/egl_ftable.h b/tools/emulator/opengl/tests/gles_android_wrapper/egl_ftable.h
new file mode 100644
index 0000000..ee40585
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl_ftable.h
@@ -0,0 +1,66 @@
+/*
+* 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.
+*/
+static struct _egl_funcs_by_name {
+    const char *name;
+    void *proc;
+} egl_funcs_by_name[] = {
+    {"eglGetError", (void *)eglGetError},
+    {"eglGetDisplay", (void *)eglGetDisplay},
+    {"eglInitialize", (void *)eglInitialize},
+    {"eglTerminate", (void *)eglTerminate},
+    {"eglQueryString", (void *)eglQueryString},
+    {"eglGetConfigs", (void *)eglGetConfigs},
+    {"eglChooseConfig", (void *)eglChooseConfig},
+    {"eglGetConfigAttrib", (void *)eglGetConfigAttrib},
+    {"eglCreateWindowSurface", (void *)eglCreateWindowSurface},
+    {"eglCreatePbufferSurface", (void *)eglCreatePbufferSurface},
+    {"eglCreatePixmapSurface", (void *)eglCreatePixmapSurface},
+    {"eglDestroySurface", (void *)eglDestroySurface},
+    {"eglQuerySurface", (void *)eglQuerySurface},
+    {"eglBindAPI", (void *)eglBindAPI},
+    {"eglQueryAPI", (void *)eglQueryAPI},
+    {"eglWaitClient", (void *)eglWaitClient},
+    {"eglReleaseThread", (void *)eglReleaseThread},
+    {"eglCreatePbufferFromClientBuffer", (void *)eglCreatePbufferFromClientBuffer},
+    {"eglSurfaceAttrib", (void *)eglSurfaceAttrib},
+    {"eglBindTexImage", (void *)eglBindTexImage},
+    {"eglReleaseTexImage", (void *)eglReleaseTexImage},
+    {"eglSwapInterval", (void *)eglSwapInterval},
+    {"eglCreateContext", (void *)eglCreateContext},
+    {"eglDestroyContext", (void *)eglDestroyContext},
+    {"eglMakeCurrent", (void *)eglMakeCurrent},
+    {"eglGetCurrentContext", (void *)eglGetCurrentContext},
+    {"eglGetCurrentSurface", (void *)eglGetCurrentSurface},
+    {"eglGetCurrentDisplay", (void *)eglGetCurrentDisplay},
+    {"eglQueryContext", (void *)eglQueryContext},
+    {"eglWaitGL", (void *)eglWaitGL},
+    {"eglWaitNative", (void *)eglWaitNative},
+    {"eglSwapBuffers", (void *)eglSwapBuffers},
+    {"eglCopyBuffers", (void *)eglCopyBuffers},
+    {"eglGetProcAddress", (void *)eglGetProcAddress},
+    {"eglLockSurfaceKHR", (void *)eglLockSurfaceKHR},
+    {"eglUnlockSurfaceKHR", (void *)eglUnlockSurfaceKHR},
+    {"eglCreateImageKHR", (void *)eglCreateImageKHR},
+    {"eglDestroyImageKHR", (void *)eglDestroyImageKHR},
+    {"eglCreateSyncKHR", (void *)eglCreateSyncKHR},
+    {"eglDestroySyncKHR", (void *)eglDestroySyncKHR},
+    {"eglClientWaitSyncKHR", (void *)eglClientWaitSyncKHR},
+    {"eglSignalSyncKHR", (void *)eglSignalSyncKHR},
+    {"eglGetSyncAttribKHR", (void *)eglGetSyncAttribKHR},
+    {"eglSetSwapRectangleANDROID", (void *)eglSetSwapRectangleANDROID}
+};
+
+static int egl_num_funcs = sizeof(egl_funcs_by_name) / sizeof(struct _egl_funcs_by_name);
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/egl_proc.h b/tools/emulator/opengl/tests/gles_android_wrapper/egl_proc.h
new file mode 100644
index 0000000..140c030
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl_proc.h
@@ -0,0 +1,68 @@
+/*
+* 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 _EGL_PROC_H
+#define _EGL_PROC_H
+
+#include <EGL/egl.h>
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/eglext.h>
+
+typedef EGLint (* eglGetError_t) ();
+typedef EGLDisplay (* eglGetDisplay_t) (EGLNativeDisplayType);
+typedef EGLBoolean (* eglInitialize_t) (EGLDisplay, EGLint*, EGLint*);
+typedef EGLBoolean (* eglTerminate_t) (EGLDisplay);
+typedef char* (* eglQueryString_t) (EGLDisplay, EGLint);
+typedef EGLBoolean (* eglGetConfigs_t) (EGLDisplay, EGLConfig*, EGLint, EGLint*);
+typedef EGLBoolean (* eglChooseConfig_t) (EGLDisplay, const EGLint*, EGLConfig*, EGLint, EGLint*);
+typedef EGLBoolean (* eglGetConfigAttrib_t) (EGLDisplay, EGLConfig, EGLint, EGLint*);
+typedef EGLSurface (* eglCreateWindowSurface_t) (EGLDisplay, EGLConfig, EGLNativeWindowType, const EGLint*);
+typedef EGLSurface (* eglCreatePbufferSurface_t) (EGLDisplay, EGLConfig, const EGLint*);
+typedef EGLSurface (* eglCreatePixmapSurface_t) (EGLDisplay, EGLConfig, EGLNativePixmapType, const EGLint*);
+typedef EGLBoolean (* eglDestroySurface_t) (EGLDisplay, EGLSurface);
+typedef EGLBoolean (* eglQuerySurface_t) (EGLDisplay, EGLSurface, EGLint, EGLint*);
+typedef EGLBoolean (* eglBindAPI_t) (EGLenum);
+typedef EGLenum (* eglQueryAPI_t) ();
+typedef EGLBoolean (* eglWaitClient_t) ();
+typedef EGLBoolean (* eglReleaseThread_t) ();
+typedef EGLSurface (* eglCreatePbufferFromClientBuffer_t) (EGLDisplay, EGLenum, EGLClientBuffer, EGLConfig, const EGLint*);
+typedef EGLBoolean (* eglSurfaceAttrib_t) (EGLDisplay, EGLSurface, EGLint, EGLint);
+typedef EGLBoolean (* eglBindTexImage_t) (EGLDisplay, EGLSurface, EGLint);
+typedef EGLBoolean (* eglReleaseTexImage_t) (EGLDisplay, EGLSurface, EGLint);
+typedef EGLBoolean (* eglSwapInterval_t) (EGLDisplay, EGLint);
+typedef EGLContext (* eglCreateContext_t) (EGLDisplay, EGLConfig, EGLContext, const EGLint*);
+typedef EGLBoolean (* eglDestroyContext_t) (EGLDisplay, EGLContext);
+typedef EGLBoolean (* eglMakeCurrent_t) (EGLDisplay, EGLSurface, EGLSurface, EGLContext);
+typedef EGLContext (* eglGetCurrentContext_t) ();
+typedef EGLSurface (* eglGetCurrentSurface_t) (EGLint);
+typedef EGLDisplay (* eglGetCurrentDisplay_t) ();
+typedef EGLBoolean (* eglQueryContext_t) (EGLDisplay, EGLContext, EGLint, EGLint*);
+typedef EGLBoolean (* eglWaitGL_t) ();
+typedef EGLBoolean (* eglWaitNative_t) (EGLint);
+typedef EGLBoolean (* eglSwapBuffers_t) (EGLDisplay, EGLSurface);
+typedef EGLBoolean (* eglCopyBuffers_t) (EGLDisplay, EGLSurface, EGLNativePixmapType);
+typedef __eglMustCastToProperFunctionPointerType (* eglGetProcAddress_t) (const char*);
+typedef EGLBoolean (* eglLockSurfaceKHR_t) (EGLDisplay, EGLSurface, const EGLint*);
+typedef EGLBoolean (* eglUnlockSurfaceKHR_t) (EGLDisplay, EGLSurface);
+typedef EGLImageKHR (* eglCreateImageKHR_t) (EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*);
+typedef EGLBoolean (* eglDestroyImageKHR_t) (EGLDisplay, EGLImageKHR image);
+typedef EGLSyncKHR (* eglCreateSyncKHR_t) (EGLDisplay, EGLenum, const EGLint*);
+typedef EGLBoolean (* eglDestroySyncKHR_t) (EGLDisplay, EGLSyncKHR sync);
+typedef EGLint (* eglClientWaitSyncKHR_t) (EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR timeout);
+typedef EGLBoolean (* eglSignalSyncKHR_t) (EGLDisplay, EGLSyncKHR, EGLenum);
+typedef EGLBoolean (* eglGetSyncAttribKHR_t) (EGLDisplay, EGLSyncKHR, EGLint, EGLint*);
+typedef EGLBoolean (* eglSetSwapRectangleANDROID_t) (EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint);
+
+#endif // of  _EGL_PROC_H
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/gles.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/gles.cpp
new file mode 100644
index 0000000..4987237
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/gles.cpp
@@ -0,0 +1,1410 @@
+/*
+* 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 <string.h>
+#include "gles_dispatch.h"
+#include "gles_ftable.h"
+#include <EGL/egl.h>
+#include <cutils/log.h>
+
+static struct gles_dispatch *s_dispatch = NULL;
+
+void init_gles(void *gles_android)
+{
+    s_dispatch = create_gles_dispatch(gles_android);
+    if (s_dispatch == NULL) {
+        LOGE("failed to create gles dispatch\n");
+    }
+}
+
+static struct gles_dispatch *getDispatch()
+{
+    if (!s_dispatch) {
+        fprintf(stderr,"FATAL ERROR: GLES has not been initialized\n");
+        exit(-1);
+    }
+
+    return s_dispatch;
+}
+
+__eglMustCastToProperFunctionPointerType gles_getProcAddress(const char *procname)
+{
+     for (int i=0; i<gles_num_funcs; i++) {
+         if (!strcmp(gles_funcs_by_name[i].name, procname)) {
+             return (__eglMustCastToProperFunctionPointerType)gles_funcs_by_name[i].proc;
+         }
+     }
+
+     return NULL;
+}
+
+///////////// Path-through functions ///////////////
+void glAlphaFunc(GLenum func, GLclampf ref)
+{
+     getDispatch()->glAlphaFunc(func, ref);
+}
+
+void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+     getDispatch()->glClearColor(red, green, blue, alpha);
+}
+
+void glClearDepthf(GLclampf depth)
+{
+     getDispatch()->glClearDepthf(depth);
+}
+
+void glClipPlanef(GLenum plane, const GLfloat *equation)
+{
+     getDispatch()->glClipPlanef(plane, equation);
+}
+
+void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+     getDispatch()->glColor4f(red, green, blue, alpha);
+}
+
+void glDepthRangef(GLclampf zNear, GLclampf zFar)
+{
+     getDispatch()->glDepthRangef(zNear, zFar);
+}
+
+void glFogf(GLenum pname, GLfloat param)
+{
+     getDispatch()->glFogf(pname, param);
+}
+
+void glFogfv(GLenum pname, const GLfloat *params)
+{
+     getDispatch()->glFogfv(pname, params);
+}
+
+void glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+     getDispatch()->glFrustumf(left, right, bottom, top, zNear, zFar);
+}
+
+void glGetClipPlanef(GLenum pname, GLfloat eqn[4])
+{
+     getDispatch()->glGetClipPlanef(pname, eqn[4]);
+}
+
+void glGetFloatv(GLenum pname, GLfloat *params)
+{
+     getDispatch()->glGetFloatv(pname, params);
+}
+
+void glGetLightfv(GLenum light, GLenum pname, GLfloat *params)
+{
+     getDispatch()->glGetLightfv(light, pname, params);
+}
+
+void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
+{
+     getDispatch()->glGetMaterialfv(face, pname, params);
+}
+
+void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params)
+{
+     getDispatch()->glGetTexEnvfv(env, pname, params);
+}
+
+void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+     getDispatch()->glGetTexParameterfv(target, pname, params);
+}
+
+void glLightModelf(GLenum pname, GLfloat param)
+{
+     getDispatch()->glLightModelf(pname, param);
+}
+
+void glLightModelfv(GLenum pname, const GLfloat *params)
+{
+     getDispatch()->glLightModelfv(pname, params);
+}
+
+void glLightf(GLenum light, GLenum pname, GLfloat param)
+{
+     getDispatch()->glLightf(light, pname, param);
+}
+
+void glLightfv(GLenum light, GLenum pname, const GLfloat *params)
+{
+     getDispatch()->glLightfv(light, pname, params);
+}
+
+void glLineWidth(GLfloat width)
+{
+     getDispatch()->glLineWidth(width);
+}
+
+void glLoadMatrixf(const GLfloat *m)
+{
+     getDispatch()->glLoadMatrixf(m);
+}
+
+void glMaterialf(GLenum face, GLenum pname, GLfloat param)
+{
+     getDispatch()->glMaterialf(face, pname, param);
+}
+
+void glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
+{
+     getDispatch()->glMaterialfv(face, pname, params);
+}
+
+void glMultMatrixf(const GLfloat *m)
+{
+     getDispatch()->glMultMatrixf(m);
+}
+
+void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+     getDispatch()->glMultiTexCoord4f(target, s, t, r, q);
+}
+
+void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
+{
+     getDispatch()->glNormal3f(nx, ny, nz);
+}
+
+void glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+     getDispatch()->glOrthof(left, right, bottom, top, zNear, zFar);
+}
+
+void glPointParameterf(GLenum pname, GLfloat param)
+{
+     getDispatch()->glPointParameterf(pname, param);
+}
+
+void glPointParameterfv(GLenum pname, const GLfloat *params)
+{
+     getDispatch()->glPointParameterfv(pname, params);
+}
+
+void glPointSize(GLfloat size)
+{
+     getDispatch()->glPointSize(size);
+}
+
+void glPolygonOffset(GLfloat factor, GLfloat units)
+{
+     getDispatch()->glPolygonOffset(factor, units);
+}
+
+void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+{
+     getDispatch()->glRotatef(angle, x, y, z);
+}
+
+void glScalef(GLfloat x, GLfloat y, GLfloat z)
+{
+     getDispatch()->glScalef(x, y, z);
+}
+
+void glTexEnvf(GLenum target, GLenum pname, GLfloat param)
+{
+     getDispatch()->glTexEnvf(target, pname, param);
+}
+
+void glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
+{
+     getDispatch()->glTexEnvfv(target, pname, params);
+}
+
+void glTexParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+     getDispatch()->glTexParameterf(target, pname, param);
+}
+
+void glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
+{
+     getDispatch()->glTexParameterfv(target, pname, params);
+}
+
+void glTranslatef(GLfloat x, GLfloat y, GLfloat z)
+{
+     getDispatch()->glTranslatef(x, y, z);
+}
+
+void glActiveTexture(GLenum texture)
+{
+     getDispatch()->glActiveTexture(texture);
+}
+
+void glAlphaFuncx(GLenum func, GLclampx ref)
+{
+     getDispatch()->glAlphaFuncx(func, ref);
+}
+
+void glBindBuffer(GLenum target, GLuint buffer)
+{
+     getDispatch()->glBindBuffer(target, buffer);
+}
+
+void glBindTexture(GLenum target, GLuint texture)
+{
+     getDispatch()->glBindTexture(target, texture);
+}
+
+void glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+     getDispatch()->glBlendFunc(sfactor, dfactor);
+}
+
+void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
+{
+     getDispatch()->glBufferData(target, size, data, usage);
+}
+
+void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)
+{
+     getDispatch()->glBufferSubData(target, offset, size, data);
+}
+
+void glClear(GLbitfield mask)
+{
+     getDispatch()->glClear(mask);
+}
+
+void glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
+{
+     getDispatch()->glClearColorx(red, green, blue, alpha);
+}
+
+void glClearDepthx(GLclampx depth)
+{
+     getDispatch()->glClearDepthx(depth);
+}
+
+void glClearStencil(GLint s)
+{
+     getDispatch()->glClearStencil(s);
+}
+
+void glClientActiveTexture(GLenum texture)
+{
+     getDispatch()->glClientActiveTexture(texture);
+}
+
+void glClipPlanex(GLenum plane, const GLfixed *equation)
+{
+     getDispatch()->glClipPlanex(plane, equation);
+}
+
+void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
+{
+     getDispatch()->glColor4ub(red, green, blue, alpha);
+}
+
+void glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+{
+     getDispatch()->glColor4x(red, green, blue, alpha);
+}
+
+void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+     getDispatch()->glColorMask(red, green, blue, alpha);
+}
+
+void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+     getDispatch()->glColorPointer(size, type, stride, pointer);
+}
+
+void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data)
+{
+     getDispatch()->glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
+}
+
+void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data)
+{
+     getDispatch()->glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
+}
+
+void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+     getDispatch()->glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
+}
+
+void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+     getDispatch()->glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+}
+
+void glCullFace(GLenum mode)
+{
+     getDispatch()->glCullFace(mode);
+}
+
+void glDeleteBuffers(GLsizei n, const GLuint *buffers)
+{
+     getDispatch()->glDeleteBuffers(n, buffers);
+}
+
+void glDeleteTextures(GLsizei n, const GLuint *textures)
+{
+     getDispatch()->glDeleteTextures(n, textures);
+}
+
+void glDepthFunc(GLenum func)
+{
+     getDispatch()->glDepthFunc(func);
+}
+
+void glDepthMask(GLboolean flag)
+{
+     getDispatch()->glDepthMask(flag);
+}
+
+void glDepthRangex(GLclampx zNear, GLclampx zFar)
+{
+     getDispatch()->glDepthRangex(zNear, zFar);
+}
+
+void glDisable(GLenum cap)
+{
+     getDispatch()->glDisable(cap);
+}
+
+void glDisableClientState(GLenum array)
+{
+     getDispatch()->glDisableClientState(array);
+}
+
+void glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+     getDispatch()->glDrawArrays(mode, first, count);
+}
+
+void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
+{
+     getDispatch()->glDrawElements(mode, count, type, indices);
+}
+
+void glEnable(GLenum cap)
+{
+     getDispatch()->glEnable(cap);
+}
+
+void glEnableClientState(GLenum array)
+{
+     getDispatch()->glEnableClientState(array);
+}
+
+void glFinish()
+{
+     getDispatch()->glFinish();
+}
+
+void glFlush()
+{
+     getDispatch()->glFlush();
+}
+
+void glFogx(GLenum pname, GLfixed param)
+{
+     getDispatch()->glFogx(pname, param);
+}
+
+void glFogxv(GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glFogxv(pname, params);
+}
+
+void glFrontFace(GLenum mode)
+{
+     getDispatch()->glFrontFace(mode);
+}
+
+void glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+     getDispatch()->glFrustumx(left, right, bottom, top, zNear, zFar);
+}
+
+void glGetBooleanv(GLenum pname, GLboolean *params)
+{
+     getDispatch()->glGetBooleanv(pname, params);
+}
+
+void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+     getDispatch()->glGetBufferParameteriv(target, pname, params);
+}
+
+void glGetClipPlanex(GLenum pname, GLfixed eqn[4])
+{
+     getDispatch()->glGetClipPlanex(pname, eqn[4]);
+}
+
+void glGenBuffers(GLsizei n, GLuint *buffers)
+{
+     getDispatch()->glGenBuffers(n, buffers);
+}
+
+void glGenTextures(GLsizei n, GLuint *textures)
+{
+     getDispatch()->glGenTextures(n, textures);
+}
+
+GLenum glGetError()
+{
+     return getDispatch()->glGetError();
+}
+
+void glGetFixedv(GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetFixedv(pname, params);
+}
+
+void glGetIntegerv(GLenum pname, GLint *params)
+{
+     getDispatch()->glGetIntegerv(pname, params);
+}
+
+void glGetLightxv(GLenum light, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetLightxv(light, pname, params);
+}
+
+void glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetMaterialxv(face, pname, params);
+}
+
+void glGetPointerv(GLenum pname, GLvoid **params)
+{
+     getDispatch()->glGetPointerv(pname, *params);
+}
+
+const GLubyte* glGetString(GLenum name)
+{
+     return getDispatch()->glGetString(name);
+}
+
+void glGetTexEnviv(GLenum env, GLenum pname, GLint *params)
+{
+     getDispatch()->glGetTexEnviv(env, pname, params);
+}
+
+void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetTexEnvxv(env, pname, params);
+}
+
+void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+     getDispatch()->glGetTexParameteriv(target, pname, params);
+}
+
+void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetTexParameterxv(target, pname, params);
+}
+
+void glHint(GLenum target, GLenum mode)
+{
+     getDispatch()->glHint(target, mode);
+}
+
+GLboolean glIsBuffer(GLuint buffer)
+{
+     return getDispatch()->glIsBuffer(buffer);
+}
+
+GLboolean glIsEnabled(GLenum cap)
+{
+     return getDispatch()->glIsEnabled(cap);
+}
+
+GLboolean glIsTexture(GLuint texture)
+{
+     return getDispatch()->glIsTexture(texture);
+}
+
+void glLightModelx(GLenum pname, GLfixed param)
+{
+     getDispatch()->glLightModelx(pname, param);
+}
+
+void glLightModelxv(GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glLightModelxv(pname, params);
+}
+
+void glLightx(GLenum light, GLenum pname, GLfixed param)
+{
+     getDispatch()->glLightx(light, pname, param);
+}
+
+void glLightxv(GLenum light, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glLightxv(light, pname, params);
+}
+
+void glLineWidthx(GLfixed width)
+{
+     getDispatch()->glLineWidthx(width);
+}
+
+void glLoadIdentity()
+{
+     getDispatch()->glLoadIdentity();
+}
+
+void glLoadMatrixx(const GLfixed *m)
+{
+     getDispatch()->glLoadMatrixx(m);
+}
+
+void glLogicOp(GLenum opcode)
+{
+     getDispatch()->glLogicOp(opcode);
+}
+
+void glMaterialx(GLenum face, GLenum pname, GLfixed param)
+{
+     getDispatch()->glMaterialx(face, pname, param);
+}
+
+void glMaterialxv(GLenum face, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glMaterialxv(face, pname, params);
+}
+
+void glMatrixMode(GLenum mode)
+{
+     getDispatch()->glMatrixMode(mode);
+}
+
+void glMultMatrixx(const GLfixed *m)
+{
+     getDispatch()->glMultMatrixx(m);
+}
+
+void glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+{
+     getDispatch()->glMultiTexCoord4x(target, s, t, r, q);
+}
+
+void glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz)
+{
+     getDispatch()->glNormal3x(nx, ny, nz);
+}
+
+void glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+     getDispatch()->glNormalPointer(type, stride, pointer);
+}
+
+void glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+     getDispatch()->glOrthox(left, right, bottom, top, zNear, zFar);
+}
+
+void glPixelStorei(GLenum pname, GLint param)
+{
+     getDispatch()->glPixelStorei(pname, param);
+}
+
+void glPointParameterx(GLenum pname, GLfixed param)
+{
+     getDispatch()->glPointParameterx(pname, param);
+}
+
+void glPointParameterxv(GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glPointParameterxv(pname, params);
+}
+
+void glPointSizex(GLfixed size)
+{
+     getDispatch()->glPointSizex(size);
+}
+
+void glPolygonOffsetx(GLfixed factor, GLfixed units)
+{
+     getDispatch()->glPolygonOffsetx(factor, units);
+}
+
+void glPopMatrix()
+{
+     getDispatch()->glPopMatrix();
+}
+
+void glPushMatrix()
+{
+     getDispatch()->glPushMatrix();
+}
+
+void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+{
+     getDispatch()->glReadPixels(x, y, width, height, format, type, pixels);
+}
+
+void glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+{
+     getDispatch()->glRotatex(angle, x, y, z);
+}
+
+void glSampleCoverage(GLclampf value, GLboolean invert)
+{
+     getDispatch()->glSampleCoverage(value, invert);
+}
+
+void glSampleCoveragex(GLclampx value, GLboolean invert)
+{
+     getDispatch()->glSampleCoveragex(value, invert);
+}
+
+void glScalex(GLfixed x, GLfixed y, GLfixed z)
+{
+     getDispatch()->glScalex(x, y, z);
+}
+
+void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+     getDispatch()->glScissor(x, y, width, height);
+}
+
+void glShadeModel(GLenum mode)
+{
+     getDispatch()->glShadeModel(mode);
+}
+
+void glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+     getDispatch()->glStencilFunc(func, ref, mask);
+}
+
+void glStencilMask(GLuint mask)
+{
+     getDispatch()->glStencilMask(mask);
+}
+
+void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+     getDispatch()->glStencilOp(fail, zfail, zpass);
+}
+
+void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+     getDispatch()->glTexCoordPointer(size, type, stride, pointer);
+}
+
+void glTexEnvi(GLenum target, GLenum pname, GLint param)
+{
+     getDispatch()->glTexEnvi(target, pname, param);
+}
+
+void glTexEnvx(GLenum target, GLenum pname, GLfixed param)
+{
+     getDispatch()->glTexEnvx(target, pname, param);
+}
+
+void glTexEnviv(GLenum target, GLenum pname, const GLint *params)
+{
+     getDispatch()->glTexEnviv(target, pname, params);
+}
+
+void glTexEnvxv(GLenum target, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glTexEnvxv(target, pname, params);
+}
+
+void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
+{
+     getDispatch()->glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
+}
+
+void glTexParameteri(GLenum target, GLenum pname, GLint param)
+{
+     getDispatch()->glTexParameteri(target, pname, param);
+}
+
+void glTexParameterx(GLenum target, GLenum pname, GLfixed param)
+{
+     getDispatch()->glTexParameterx(target, pname, param);
+}
+
+void glTexParameteriv(GLenum target, GLenum pname, const GLint *params)
+{
+     getDispatch()->glTexParameteriv(target, pname, params);
+}
+
+void glTexParameterxv(GLenum target, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glTexParameterxv(target, pname, params);
+}
+
+void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+{
+     getDispatch()->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+}
+
+void glTranslatex(GLfixed x, GLfixed y, GLfixed z)
+{
+     getDispatch()->glTranslatex(x, y, z);
+}
+
+void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+     getDispatch()->glVertexPointer(size, type, stride, pointer);
+}
+
+void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+     getDispatch()->glViewport(x, y, width, height);
+}
+
+void glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+     getDispatch()->glPointSizePointerOES(type, stride, pointer);
+}
+
+void glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha)
+{
+     getDispatch()->glBlendEquationSeparateOES(modeRGB, modeAlpha);
+}
+
+void glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+     getDispatch()->glBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha);
+}
+
+void glBlendEquationOES(GLenum mode)
+{
+     getDispatch()->glBlendEquationOES(mode);
+}
+
+void glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
+{
+     getDispatch()->glDrawTexsOES(x, y, z, width, height);
+}
+
+void glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
+{
+     getDispatch()->glDrawTexiOES(x, y, z, width, height);
+}
+
+void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
+{
+     getDispatch()->glDrawTexxOES(x, y, z, width, height);
+}
+
+void glDrawTexsvOES(const GLshort *coords)
+{
+     getDispatch()->glDrawTexsvOES(coords);
+}
+
+void glDrawTexivOES(const GLint *coords)
+{
+     getDispatch()->glDrawTexivOES(coords);
+}
+
+void glDrawTexxvOES(const GLfixed *coords)
+{
+     getDispatch()->glDrawTexxvOES(coords);
+}
+
+void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
+{
+     getDispatch()->glDrawTexfOES(x, y, z, width, height);
+}
+
+void glDrawTexfvOES(const GLfloat *coords)
+{
+     getDispatch()->glDrawTexfvOES(coords);
+}
+
+void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+     getDispatch()->glEGLImageTargetTexture2DOES(target, image);
+}
+
+void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+     getDispatch()->glEGLImageTargetRenderbufferStorageOES(target, image);
+}
+
+void glAlphaFuncxOES(GLenum func, GLclampx ref)
+{
+     getDispatch()->glAlphaFuncxOES(func, ref);
+}
+
+void glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
+{
+     getDispatch()->glClearColorxOES(red, green, blue, alpha);
+}
+
+void glClearDepthxOES(GLclampx depth)
+{
+     getDispatch()->glClearDepthxOES(depth);
+}
+
+void glClipPlanexOES(GLenum plane, const GLfixed *equation)
+{
+     getDispatch()->glClipPlanexOES(plane, equation);
+}
+
+void glColor4xOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+{
+     getDispatch()->glColor4xOES(red, green, blue, alpha);
+}
+
+void glDepthRangexOES(GLclampx zNear, GLclampx zFar)
+{
+     getDispatch()->glDepthRangexOES(zNear, zFar);
+}
+
+void glFogxOES(GLenum pname, GLfixed param)
+{
+     getDispatch()->glFogxOES(pname, param);
+}
+
+void glFogxvOES(GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glFogxvOES(pname, params);
+}
+
+void glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+     getDispatch()->glFrustumxOES(left, right, bottom, top, zNear, zFar);
+}
+
+void glGetClipPlanexOES(GLenum pname, GLfixed eqn[4])
+{
+     getDispatch()->glGetClipPlanexOES(pname, eqn[4]);
+}
+
+void glGetFixedvOES(GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetFixedvOES(pname, params);
+}
+
+void glGetLightxvOES(GLenum light, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetLightxvOES(light, pname, params);
+}
+
+void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetMaterialxvOES(face, pname, params);
+}
+
+void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetTexEnvxvOES(env, pname, params);
+}
+
+void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetTexParameterxvOES(target, pname, params);
+}
+
+void glLightModelxOES(GLenum pname, GLfixed param)
+{
+     getDispatch()->glLightModelxOES(pname, param);
+}
+
+void glLightModelxvOES(GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glLightModelxvOES(pname, params);
+}
+
+void glLightxOES(GLenum light, GLenum pname, GLfixed param)
+{
+     getDispatch()->glLightxOES(light, pname, param);
+}
+
+void glLightxvOES(GLenum light, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glLightxvOES(light, pname, params);
+}
+
+void glLineWidthxOES(GLfixed width)
+{
+     getDispatch()->glLineWidthxOES(width);
+}
+
+void glLoadMatrixxOES(const GLfixed *m)
+{
+     getDispatch()->glLoadMatrixxOES(m);
+}
+
+void glMaterialxOES(GLenum face, GLenum pname, GLfixed param)
+{
+     getDispatch()->glMaterialxOES(face, pname, param);
+}
+
+void glMaterialxvOES(GLenum face, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glMaterialxvOES(face, pname, params);
+}
+
+void glMultMatrixxOES(const GLfixed *m)
+{
+     getDispatch()->glMultMatrixxOES(m);
+}
+
+void glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+{
+     getDispatch()->glMultiTexCoord4xOES(target, s, t, r, q);
+}
+
+void glNormal3xOES(GLfixed nx, GLfixed ny, GLfixed nz)
+{
+     getDispatch()->glNormal3xOES(nx, ny, nz);
+}
+
+void glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+     getDispatch()->glOrthoxOES(left, right, bottom, top, zNear, zFar);
+}
+
+void glPointParameterxOES(GLenum pname, GLfixed param)
+{
+     getDispatch()->glPointParameterxOES(pname, param);
+}
+
+void glPointParameterxvOES(GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glPointParameterxvOES(pname, params);
+}
+
+void glPointSizexOES(GLfixed size)
+{
+     getDispatch()->glPointSizexOES(size);
+}
+
+void glPolygonOffsetxOES(GLfixed factor, GLfixed units)
+{
+     getDispatch()->glPolygonOffsetxOES(factor, units);
+}
+
+void glRotatexOES(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+{
+     getDispatch()->glRotatexOES(angle, x, y, z);
+}
+
+void glSampleCoveragexOES(GLclampx value, GLboolean invert)
+{
+     getDispatch()->glSampleCoveragexOES(value, invert);
+}
+
+void glScalexOES(GLfixed x, GLfixed y, GLfixed z)
+{
+     getDispatch()->glScalexOES(x, y, z);
+}
+
+void glTexEnvxOES(GLenum target, GLenum pname, GLfixed param)
+{
+     getDispatch()->glTexEnvxOES(target, pname, param);
+}
+
+void glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glTexEnvxvOES(target, pname, params);
+}
+
+void glTexParameterxOES(GLenum target, GLenum pname, GLfixed param)
+{
+     getDispatch()->glTexParameterxOES(target, pname, param);
+}
+
+void glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glTexParameterxvOES(target, pname, params);
+}
+
+void glTranslatexOES(GLfixed x, GLfixed y, GLfixed z)
+{
+     getDispatch()->glTranslatexOES(x, y, z);
+}
+
+GLboolean glIsRenderbufferOES(GLuint renderbuffer)
+{
+     return getDispatch()->glIsRenderbufferOES(renderbuffer);
+}
+
+void glBindRenderbufferOES(GLenum target, GLuint renderbuffer)
+{
+     getDispatch()->glBindRenderbufferOES(target, renderbuffer);
+}
+
+void glDeleteRenderbuffersOES(GLsizei n, const GLuint *renderbuffers)
+{
+     getDispatch()->glDeleteRenderbuffersOES(n, renderbuffers);
+}
+
+void glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers)
+{
+     getDispatch()->glGenRenderbuffersOES(n, renderbuffers);
+}
+
+void glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+     getDispatch()->glRenderbufferStorageOES(target, internalformat, width, height);
+}
+
+void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint *params)
+{
+     getDispatch()->glGetRenderbufferParameterivOES(target, pname, params);
+}
+
+GLboolean glIsFramebufferOES(GLuint framebuffer)
+{
+     return getDispatch()->glIsFramebufferOES(framebuffer);
+}
+
+void glBindFramebufferOES(GLenum target, GLuint framebuffer)
+{
+     getDispatch()->glBindFramebufferOES(target, framebuffer);
+}
+
+void glDeleteFramebuffersOES(GLsizei n, const GLuint *framebuffers)
+{
+     getDispatch()->glDeleteFramebuffersOES(n, framebuffers);
+}
+
+void glGenFramebuffersOES(GLsizei n, GLuint *framebuffers)
+{
+     getDispatch()->glGenFramebuffersOES(n, framebuffers);
+}
+
+GLenum glCheckFramebufferStatusOES(GLenum target)
+{
+     return getDispatch()->glCheckFramebufferStatusOES(target);
+}
+
+void glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+     getDispatch()->glFramebufferRenderbufferOES(target, attachment, renderbuffertarget, renderbuffer);
+}
+
+void glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+     getDispatch()->glFramebufferTexture2DOES(target, attachment, textarget, texture, level);
+}
+
+void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params)
+{
+     getDispatch()->glGetFramebufferAttachmentParameterivOES(target, attachment, pname, params);
+}
+
+void glGenerateMipmapOES(GLenum target)
+{
+     getDispatch()->glGenerateMipmapOES(target);
+}
+
+void* glMapBufferOES(GLenum target, GLenum access)
+{
+     return getDispatch()->glMapBufferOES(target, access);
+}
+
+GLboolean glUnmapBufferOES(GLenum target)
+{
+     return getDispatch()->glUnmapBufferOES(target);
+}
+
+void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid **ptr)
+{
+     getDispatch()->glGetBufferPointervOES(target, pname, ptr);
+}
+
+void glCurrentPaletteMatrixOES(GLuint matrixpaletteindex)
+{
+     getDispatch()->glCurrentPaletteMatrixOES(matrixpaletteindex);
+}
+
+void glLoadPaletteFromModelViewMatrixOES()
+{
+     getDispatch()->glLoadPaletteFromModelViewMatrixOES();
+}
+
+void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+     getDispatch()->glMatrixIndexPointerOES(size, type, stride, pointer);
+}
+
+void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+     getDispatch()->glWeightPointerOES(size, type, stride, pointer);
+}
+
+GLbitfield glQueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16])
+{
+     return getDispatch()->glQueryMatrixxOES(mantissa[16], exponent[16]);
+}
+
+void glDepthRangefOES(GLclampf zNear, GLclampf zFar)
+{
+     getDispatch()->glDepthRangefOES(zNear, zFar);
+}
+
+void glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+     getDispatch()->glFrustumfOES(left, right, bottom, top, zNear, zFar);
+}
+
+void glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+     getDispatch()->glOrthofOES(left, right, bottom, top, zNear, zFar);
+}
+
+void glClipPlanefOES(GLenum plane, const GLfloat *equation)
+{
+     getDispatch()->glClipPlanefOES(plane, equation);
+}
+
+void glGetClipPlanefOES(GLenum pname, GLfloat eqn[4])
+{
+     getDispatch()->glGetClipPlanefOES(pname, eqn[4]);
+}
+
+void glClearDepthfOES(GLclampf depth)
+{
+     getDispatch()->glClearDepthfOES(depth);
+}
+
+void glTexGenfOES(GLenum coord, GLenum pname, GLfloat param)
+{
+     getDispatch()->glTexGenfOES(coord, pname, param);
+}
+
+void glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat *params)
+{
+     getDispatch()->glTexGenfvOES(coord, pname, params);
+}
+
+void glTexGeniOES(GLenum coord, GLenum pname, GLint param)
+{
+     getDispatch()->glTexGeniOES(coord, pname, param);
+}
+
+void glTexGenivOES(GLenum coord, GLenum pname, const GLint *params)
+{
+     getDispatch()->glTexGenivOES(coord, pname, params);
+}
+
+void glTexGenxOES(GLenum coord, GLenum pname, GLfixed param)
+{
+     getDispatch()->glTexGenxOES(coord, pname, param);
+}
+
+void glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed *params)
+{
+     getDispatch()->glTexGenxvOES(coord, pname, params);
+}
+
+void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params)
+{
+     getDispatch()->glGetTexGenfvOES(coord, pname, params);
+}
+
+void glGetTexGenivOES(GLenum coord, GLenum pname, GLint *params)
+{
+     getDispatch()->glGetTexGenivOES(coord, pname, params);
+}
+
+void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params)
+{
+     getDispatch()->glGetTexGenxvOES(coord, pname, params);
+}
+
+void glBindVertexArrayOES(GLuint array)
+{
+     getDispatch()->glBindVertexArrayOES(array);
+}
+
+void glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays)
+{
+     getDispatch()->glDeleteVertexArraysOES(n, arrays);
+}
+
+void glGenVertexArraysOES(GLsizei n, GLuint *arrays)
+{
+     getDispatch()->glGenVertexArraysOES(n, arrays);
+}
+
+GLboolean glIsVertexArrayOES(GLuint array)
+{
+     return getDispatch()->glIsVertexArrayOES(array);
+}
+
+void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments)
+{
+     getDispatch()->glDiscardFramebufferEXT(target, numAttachments, attachments);
+}
+
+void glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
+{
+     getDispatch()->glMultiDrawArraysEXT(mode, first, count, primcount);
+}
+
+void glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)
+{
+     getDispatch()->glMultiDrawElementsEXT(mode, count, type, indices, primcount);
+}
+
+void glClipPlanefIMG(GLenum p, const GLfloat *eqn)
+{
+     getDispatch()->glClipPlanefIMG(p, eqn);
+}
+
+void glClipPlanexIMG(GLenum p, const GLfixed *eqn)
+{
+     getDispatch()->glClipPlanexIMG(p, eqn);
+}
+
+void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+     getDispatch()->glRenderbufferStorageMultisampleIMG(target, samples, internalformat, width, height);
+}
+
+void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
+{
+     getDispatch()->glFramebufferTexture2DMultisampleIMG(target, attachment, textarget, texture, level, samples);
+}
+
+void glDeleteFencesNV(GLsizei n, const GLuint *fences)
+{
+     getDispatch()->glDeleteFencesNV(n, fences);
+}
+
+void glGenFencesNV(GLsizei n, GLuint *fences)
+{
+     getDispatch()->glGenFencesNV(n, fences);
+}
+
+GLboolean glIsFenceNV(GLuint fence)
+{
+     return getDispatch()->glIsFenceNV(fence);
+}
+
+GLboolean glTestFenceNV(GLuint fence)
+{
+     return getDispatch()->glTestFenceNV(fence);
+}
+
+void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
+{
+     getDispatch()->glGetFenceivNV(fence, pname, params);
+}
+
+void glFinishFenceNV(GLuint fence)
+{
+     getDispatch()->glFinishFenceNV(fence);
+}
+
+void glSetFenceNV(GLuint fence, GLenum condition)
+{
+     getDispatch()->glSetFenceNV(fence, condition);
+}
+
+void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls)
+{
+     getDispatch()->glGetDriverControlsQCOM(num, size, driverControls);
+}
+
+void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString)
+{
+     getDispatch()->glGetDriverControlStringQCOM(driverControl, bufSize, length, driverControlString);
+}
+
+void glEnableDriverControlQCOM(GLuint driverControl)
+{
+     getDispatch()->glEnableDriverControlQCOM(driverControl);
+}
+
+void glDisableDriverControlQCOM(GLuint driverControl)
+{
+     getDispatch()->glDisableDriverControlQCOM(driverControl);
+}
+
+void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures)
+{
+     getDispatch()->glExtGetTexturesQCOM(textures, maxTextures, numTextures);
+}
+
+void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers)
+{
+     getDispatch()->glExtGetBuffersQCOM(buffers, maxBuffers, numBuffers);
+}
+
+void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers)
+{
+     getDispatch()->glExtGetRenderbuffersQCOM(renderbuffers, maxRenderbuffers, numRenderbuffers);
+}
+
+void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers)
+{
+     getDispatch()->glExtGetFramebuffersQCOM(framebuffers, maxFramebuffers, numFramebuffers);
+}
+
+void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params)
+{
+     getDispatch()->glExtGetTexLevelParameterivQCOM(texture, face, level, pname, params);
+}
+
+void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param)
+{
+     getDispatch()->glExtTexObjectStateOverrideiQCOM(target, pname, param);
+}
+
+void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
+{
+     getDispatch()->glExtGetTexSubImageQCOM(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels);
+}
+
+void glExtGetBufferPointervQCOM(GLenum target, GLvoid **params)
+{
+     getDispatch()->glExtGetBufferPointervQCOM(target, *params);
+}
+
+void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders)
+{
+     getDispatch()->glExtGetShadersQCOM(shaders, maxShaders, numShaders);
+}
+
+void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms)
+{
+     getDispatch()->glExtGetProgramsQCOM(programs, maxPrograms, numPrograms);
+}
+
+GLboolean glExtIsProgramBinaryQCOM(GLuint program)
+{
+     return getDispatch()->glExtIsProgramBinaryQCOM(program);
+}
+
+void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length)
+{
+     getDispatch()->glExtGetProgramBinarySourceQCOM(program, shadertype, source, length);
+}
+
+void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
+{
+     getDispatch()->glStartTilingQCOM(x, y, width, height, preserveMask);
+}
+
+void glEndTilingQCOM(GLbitfield preserveMask)
+{
+     getDispatch()->glEndTilingQCOM(preserveMask);
+}
+
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/gles_dispatch.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/gles_dispatch.cpp
new file mode 100644
index 0000000..0a17624
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/gles_dispatch.cpp
@@ -0,0 +1,298 @@
+/*
+* 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 "gles_dispatch.h"
+#include <stdio.h>
+#include <dlfcn.h>
+
+gles_dispatch *create_gles_dispatch(void *gles_android)
+{
+        gles_dispatch *disp = new gles_dispatch;
+
+    void *ptr;
+    ptr = dlsym(gles_android,"glAlphaFunc"); disp->set_glAlphaFunc((glAlphaFunc_t)ptr);
+    ptr = dlsym(gles_android,"glClearColor"); disp->set_glClearColor((glClearColor_t)ptr);
+    ptr = dlsym(gles_android,"glClearDepthf"); disp->set_glClearDepthf((glClearDepthf_t)ptr);
+    ptr = dlsym(gles_android,"glClipPlanef"); disp->set_glClipPlanef((glClipPlanef_t)ptr);
+    ptr = dlsym(gles_android,"glColor4f"); disp->set_glColor4f((glColor4f_t)ptr);
+    ptr = dlsym(gles_android,"glDepthRangef"); disp->set_glDepthRangef((glDepthRangef_t)ptr);
+    ptr = dlsym(gles_android,"glFogf"); disp->set_glFogf((glFogf_t)ptr);
+    ptr = dlsym(gles_android,"glFogfv"); disp->set_glFogfv((glFogfv_t)ptr);
+    ptr = dlsym(gles_android,"glFrustumf"); disp->set_glFrustumf((glFrustumf_t)ptr);
+    ptr = dlsym(gles_android,"glGetClipPlanef"); disp->set_glGetClipPlanef((glGetClipPlanef_t)ptr);
+    ptr = dlsym(gles_android,"glGetFloatv"); disp->set_glGetFloatv((glGetFloatv_t)ptr);
+    ptr = dlsym(gles_android,"glGetLightfv"); disp->set_glGetLightfv((glGetLightfv_t)ptr);
+    ptr = dlsym(gles_android,"glGetMaterialfv"); disp->set_glGetMaterialfv((glGetMaterialfv_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexEnvfv"); disp->set_glGetTexEnvfv((glGetTexEnvfv_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexParameterfv"); disp->set_glGetTexParameterfv((glGetTexParameterfv_t)ptr);
+    ptr = dlsym(gles_android,"glLightModelf"); disp->set_glLightModelf((glLightModelf_t)ptr);
+    ptr = dlsym(gles_android,"glLightModelfv"); disp->set_glLightModelfv((glLightModelfv_t)ptr);
+    ptr = dlsym(gles_android,"glLightf"); disp->set_glLightf((glLightf_t)ptr);
+    ptr = dlsym(gles_android,"glLightfv"); disp->set_glLightfv((glLightfv_t)ptr);
+    ptr = dlsym(gles_android,"glLineWidth"); disp->set_glLineWidth((glLineWidth_t)ptr);
+    ptr = dlsym(gles_android,"glLoadMatrixf"); disp->set_glLoadMatrixf((glLoadMatrixf_t)ptr);
+    ptr = dlsym(gles_android,"glMaterialf"); disp->set_glMaterialf((glMaterialf_t)ptr);
+    ptr = dlsym(gles_android,"glMaterialfv"); disp->set_glMaterialfv((glMaterialfv_t)ptr);
+    ptr = dlsym(gles_android,"glMultMatrixf"); disp->set_glMultMatrixf((glMultMatrixf_t)ptr);
+    ptr = dlsym(gles_android,"glMultiTexCoord4f"); disp->set_glMultiTexCoord4f((glMultiTexCoord4f_t)ptr);
+    ptr = dlsym(gles_android,"glNormal3f"); disp->set_glNormal3f((glNormal3f_t)ptr);
+    ptr = dlsym(gles_android,"glOrthof"); disp->set_glOrthof((glOrthof_t)ptr);
+    ptr = dlsym(gles_android,"glPointParameterf"); disp->set_glPointParameterf((glPointParameterf_t)ptr);
+    ptr = dlsym(gles_android,"glPointParameterfv"); disp->set_glPointParameterfv((glPointParameterfv_t)ptr);
+    ptr = dlsym(gles_android,"glPointSize"); disp->set_glPointSize((glPointSize_t)ptr);
+    ptr = dlsym(gles_android,"glPolygonOffset"); disp->set_glPolygonOffset((glPolygonOffset_t)ptr);
+    ptr = dlsym(gles_android,"glRotatef"); disp->set_glRotatef((glRotatef_t)ptr);
+    ptr = dlsym(gles_android,"glScalef"); disp->set_glScalef((glScalef_t)ptr);
+    ptr = dlsym(gles_android,"glTexEnvf"); disp->set_glTexEnvf((glTexEnvf_t)ptr);
+    ptr = dlsym(gles_android,"glTexEnvfv"); disp->set_glTexEnvfv((glTexEnvfv_t)ptr);
+    ptr = dlsym(gles_android,"glTexParameterf"); disp->set_glTexParameterf((glTexParameterf_t)ptr);
+    ptr = dlsym(gles_android,"glTexParameterfv"); disp->set_glTexParameterfv((glTexParameterfv_t)ptr);
+    ptr = dlsym(gles_android,"glTranslatef"); disp->set_glTranslatef((glTranslatef_t)ptr);
+    ptr = dlsym(gles_android,"glActiveTexture"); disp->set_glActiveTexture((glActiveTexture_t)ptr);
+    ptr = dlsym(gles_android,"glAlphaFuncx"); disp->set_glAlphaFuncx((glAlphaFuncx_t)ptr);
+    ptr = dlsym(gles_android,"glBindBuffer"); disp->set_glBindBuffer((glBindBuffer_t)ptr);
+    ptr = dlsym(gles_android,"glBindTexture"); disp->set_glBindTexture((glBindTexture_t)ptr);
+    ptr = dlsym(gles_android,"glBlendFunc"); disp->set_glBlendFunc((glBlendFunc_t)ptr);
+    ptr = dlsym(gles_android,"glBufferData"); disp->set_glBufferData((glBufferData_t)ptr);
+    ptr = dlsym(gles_android,"glBufferSubData"); disp->set_glBufferSubData((glBufferSubData_t)ptr);
+    ptr = dlsym(gles_android,"glClear"); disp->set_glClear((glClear_t)ptr);
+    ptr = dlsym(gles_android,"glClearColorx"); disp->set_glClearColorx((glClearColorx_t)ptr);
+    ptr = dlsym(gles_android,"glClearDepthx"); disp->set_glClearDepthx((glClearDepthx_t)ptr);
+    ptr = dlsym(gles_android,"glClearStencil"); disp->set_glClearStencil((glClearStencil_t)ptr);
+    ptr = dlsym(gles_android,"glClientActiveTexture"); disp->set_glClientActiveTexture((glClientActiveTexture_t)ptr);
+    ptr = dlsym(gles_android,"glClipPlanex"); disp->set_glClipPlanex((glClipPlanex_t)ptr);
+    ptr = dlsym(gles_android,"glColor4ub"); disp->set_glColor4ub((glColor4ub_t)ptr);
+    ptr = dlsym(gles_android,"glColor4x"); disp->set_glColor4x((glColor4x_t)ptr);
+    ptr = dlsym(gles_android,"glColorMask"); disp->set_glColorMask((glColorMask_t)ptr);
+    ptr = dlsym(gles_android,"glColorPointer"); disp->set_glColorPointer((glColorPointer_t)ptr);
+    ptr = dlsym(gles_android,"glCompressedTexImage2D"); disp->set_glCompressedTexImage2D((glCompressedTexImage2D_t)ptr);
+    ptr = dlsym(gles_android,"glCompressedTexSubImage2D"); disp->set_glCompressedTexSubImage2D((glCompressedTexSubImage2D_t)ptr);
+    ptr = dlsym(gles_android,"glCopyTexImage2D"); disp->set_glCopyTexImage2D((glCopyTexImage2D_t)ptr);
+    ptr = dlsym(gles_android,"glCopyTexSubImage2D"); disp->set_glCopyTexSubImage2D((glCopyTexSubImage2D_t)ptr);
+    ptr = dlsym(gles_android,"glCullFace"); disp->set_glCullFace((glCullFace_t)ptr);
+    ptr = dlsym(gles_android,"glDeleteBuffers"); disp->set_glDeleteBuffers((glDeleteBuffers_t)ptr);
+    ptr = dlsym(gles_android,"glDeleteTextures"); disp->set_glDeleteTextures((glDeleteTextures_t)ptr);
+    ptr = dlsym(gles_android,"glDepthFunc"); disp->set_glDepthFunc((glDepthFunc_t)ptr);
+    ptr = dlsym(gles_android,"glDepthMask"); disp->set_glDepthMask((glDepthMask_t)ptr);
+    ptr = dlsym(gles_android,"glDepthRangex"); disp->set_glDepthRangex((glDepthRangex_t)ptr);
+    ptr = dlsym(gles_android,"glDisable"); disp->set_glDisable((glDisable_t)ptr);
+    ptr = dlsym(gles_android,"glDisableClientState"); disp->set_glDisableClientState((glDisableClientState_t)ptr);
+    ptr = dlsym(gles_android,"glDrawArrays"); disp->set_glDrawArrays((glDrawArrays_t)ptr);
+    ptr = dlsym(gles_android,"glDrawElements"); disp->set_glDrawElements((glDrawElements_t)ptr);
+    ptr = dlsym(gles_android,"glEnable"); disp->set_glEnable((glEnable_t)ptr);
+    ptr = dlsym(gles_android,"glEnableClientState"); disp->set_glEnableClientState((glEnableClientState_t)ptr);
+    ptr = dlsym(gles_android,"glFinish"); disp->set_glFinish((glFinish_t)ptr);
+    ptr = dlsym(gles_android,"glFlush"); disp->set_glFlush((glFlush_t)ptr);
+    ptr = dlsym(gles_android,"glFogx"); disp->set_glFogx((glFogx_t)ptr);
+    ptr = dlsym(gles_android,"glFogxv"); disp->set_glFogxv((glFogxv_t)ptr);
+    ptr = dlsym(gles_android,"glFrontFace"); disp->set_glFrontFace((glFrontFace_t)ptr);
+    ptr = dlsym(gles_android,"glFrustumx"); disp->set_glFrustumx((glFrustumx_t)ptr);
+    ptr = dlsym(gles_android,"glGetBooleanv"); disp->set_glGetBooleanv((glGetBooleanv_t)ptr);
+    ptr = dlsym(gles_android,"glGetBufferParameteriv"); disp->set_glGetBufferParameteriv((glGetBufferParameteriv_t)ptr);
+    ptr = dlsym(gles_android,"glGetClipPlanex"); disp->set_glGetClipPlanex((glGetClipPlanex_t)ptr);
+    ptr = dlsym(gles_android,"glGenBuffers"); disp->set_glGenBuffers((glGenBuffers_t)ptr);
+    ptr = dlsym(gles_android,"glGenTextures"); disp->set_glGenTextures((glGenTextures_t)ptr);
+    ptr = dlsym(gles_android,"glGetError"); disp->set_glGetError((glGetError_t)ptr);
+    ptr = dlsym(gles_android,"glGetFixedv"); disp->set_glGetFixedv((glGetFixedv_t)ptr);
+    ptr = dlsym(gles_android,"glGetIntegerv"); disp->set_glGetIntegerv((glGetIntegerv_t)ptr);
+    ptr = dlsym(gles_android,"glGetLightxv"); disp->set_glGetLightxv((glGetLightxv_t)ptr);
+    ptr = dlsym(gles_android,"glGetMaterialxv"); disp->set_glGetMaterialxv((glGetMaterialxv_t)ptr);
+    ptr = dlsym(gles_android,"glGetPointerv"); disp->set_glGetPointerv((glGetPointerv_t)ptr);
+    ptr = dlsym(gles_android,"glGetString"); disp->set_glGetString((glGetString_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexEnviv"); disp->set_glGetTexEnviv((glGetTexEnviv_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexEnvxv"); disp->set_glGetTexEnvxv((glGetTexEnvxv_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexParameteriv"); disp->set_glGetTexParameteriv((glGetTexParameteriv_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexParameterxv"); disp->set_glGetTexParameterxv((glGetTexParameterxv_t)ptr);
+    ptr = dlsym(gles_android,"glHint"); disp->set_glHint((glHint_t)ptr);
+    ptr = dlsym(gles_android,"glIsBuffer"); disp->set_glIsBuffer((glIsBuffer_t)ptr);
+    ptr = dlsym(gles_android,"glIsEnabled"); disp->set_glIsEnabled((glIsEnabled_t)ptr);
+    ptr = dlsym(gles_android,"glIsTexture"); disp->set_glIsTexture((glIsTexture_t)ptr);
+    ptr = dlsym(gles_android,"glLightModelx"); disp->set_glLightModelx((glLightModelx_t)ptr);
+    ptr = dlsym(gles_android,"glLightModelxv"); disp->set_glLightModelxv((glLightModelxv_t)ptr);
+    ptr = dlsym(gles_android,"glLightx"); disp->set_glLightx((glLightx_t)ptr);
+    ptr = dlsym(gles_android,"glLightxv"); disp->set_glLightxv((glLightxv_t)ptr);
+    ptr = dlsym(gles_android,"glLineWidthx"); disp->set_glLineWidthx((glLineWidthx_t)ptr);
+    ptr = dlsym(gles_android,"glLoadIdentity"); disp->set_glLoadIdentity((glLoadIdentity_t)ptr);
+    ptr = dlsym(gles_android,"glLoadMatrixx"); disp->set_glLoadMatrixx((glLoadMatrixx_t)ptr);
+    ptr = dlsym(gles_android,"glLogicOp"); disp->set_glLogicOp((glLogicOp_t)ptr);
+    ptr = dlsym(gles_android,"glMaterialx"); disp->set_glMaterialx((glMaterialx_t)ptr);
+    ptr = dlsym(gles_android,"glMaterialxv"); disp->set_glMaterialxv((glMaterialxv_t)ptr);
+    ptr = dlsym(gles_android,"glMatrixMode"); disp->set_glMatrixMode((glMatrixMode_t)ptr);
+    ptr = dlsym(gles_android,"glMultMatrixx"); disp->set_glMultMatrixx((glMultMatrixx_t)ptr);
+    ptr = dlsym(gles_android,"glMultiTexCoord4x"); disp->set_glMultiTexCoord4x((glMultiTexCoord4x_t)ptr);
+    ptr = dlsym(gles_android,"glNormal3x"); disp->set_glNormal3x((glNormal3x_t)ptr);
+    ptr = dlsym(gles_android,"glNormalPointer"); disp->set_glNormalPointer((glNormalPointer_t)ptr);
+    ptr = dlsym(gles_android,"glOrthox"); disp->set_glOrthox((glOrthox_t)ptr);
+    ptr = dlsym(gles_android,"glPixelStorei"); disp->set_glPixelStorei((glPixelStorei_t)ptr);
+    ptr = dlsym(gles_android,"glPointParameterx"); disp->set_glPointParameterx((glPointParameterx_t)ptr);
+    ptr = dlsym(gles_android,"glPointParameterxv"); disp->set_glPointParameterxv((glPointParameterxv_t)ptr);
+    ptr = dlsym(gles_android,"glPointSizex"); disp->set_glPointSizex((glPointSizex_t)ptr);
+    ptr = dlsym(gles_android,"glPolygonOffsetx"); disp->set_glPolygonOffsetx((glPolygonOffsetx_t)ptr);
+    ptr = dlsym(gles_android,"glPopMatrix"); disp->set_glPopMatrix((glPopMatrix_t)ptr);
+    ptr = dlsym(gles_android,"glPushMatrix"); disp->set_glPushMatrix((glPushMatrix_t)ptr);
+    ptr = dlsym(gles_android,"glReadPixels"); disp->set_glReadPixels((glReadPixels_t)ptr);
+    ptr = dlsym(gles_android,"glRotatex"); disp->set_glRotatex((glRotatex_t)ptr);
+    ptr = dlsym(gles_android,"glSampleCoverage"); disp->set_glSampleCoverage((glSampleCoverage_t)ptr);
+    ptr = dlsym(gles_android,"glSampleCoveragex"); disp->set_glSampleCoveragex((glSampleCoveragex_t)ptr);
+    ptr = dlsym(gles_android,"glScalex"); disp->set_glScalex((glScalex_t)ptr);
+    ptr = dlsym(gles_android,"glScissor"); disp->set_glScissor((glScissor_t)ptr);
+    ptr = dlsym(gles_android,"glShadeModel"); disp->set_glShadeModel((glShadeModel_t)ptr);
+    ptr = dlsym(gles_android,"glStencilFunc"); disp->set_glStencilFunc((glStencilFunc_t)ptr);
+    ptr = dlsym(gles_android,"glStencilMask"); disp->set_glStencilMask((glStencilMask_t)ptr);
+    ptr = dlsym(gles_android,"glStencilOp"); disp->set_glStencilOp((glStencilOp_t)ptr);
+    ptr = dlsym(gles_android,"glTexCoordPointer"); disp->set_glTexCoordPointer((glTexCoordPointer_t)ptr);
+    ptr = dlsym(gles_android,"glTexEnvi"); disp->set_glTexEnvi((glTexEnvi_t)ptr);
+    ptr = dlsym(gles_android,"glTexEnvx"); disp->set_glTexEnvx((glTexEnvx_t)ptr);
+    ptr = dlsym(gles_android,"glTexEnviv"); disp->set_glTexEnviv((glTexEnviv_t)ptr);
+    ptr = dlsym(gles_android,"glTexEnvxv"); disp->set_glTexEnvxv((glTexEnvxv_t)ptr);
+    ptr = dlsym(gles_android,"glTexImage2D"); disp->set_glTexImage2D((glTexImage2D_t)ptr);
+    ptr = dlsym(gles_android,"glTexParameteri"); disp->set_glTexParameteri((glTexParameteri_t)ptr);
+    ptr = dlsym(gles_android,"glTexParameterx"); disp->set_glTexParameterx((glTexParameterx_t)ptr);
+    ptr = dlsym(gles_android,"glTexParameteriv"); disp->set_glTexParameteriv((glTexParameteriv_t)ptr);
+    ptr = dlsym(gles_android,"glTexParameterxv"); disp->set_glTexParameterxv((glTexParameterxv_t)ptr);
+    ptr = dlsym(gles_android,"glTexSubImage2D"); disp->set_glTexSubImage2D((glTexSubImage2D_t)ptr);
+    ptr = dlsym(gles_android,"glTranslatex"); disp->set_glTranslatex((glTranslatex_t)ptr);
+    ptr = dlsym(gles_android,"glVertexPointer"); disp->set_glVertexPointer((glVertexPointer_t)ptr);
+    ptr = dlsym(gles_android,"glViewport"); disp->set_glViewport((glViewport_t)ptr);
+    ptr = dlsym(gles_android,"glPointSizePointerOES"); disp->set_glPointSizePointerOES((glPointSizePointerOES_t)ptr);
+    ptr = dlsym(gles_android,"glBlendEquationSeparateOES"); disp->set_glBlendEquationSeparateOES((glBlendEquationSeparateOES_t)ptr);
+    ptr = dlsym(gles_android,"glBlendFuncSeparateOES"); disp->set_glBlendFuncSeparateOES((glBlendFuncSeparateOES_t)ptr);
+    ptr = dlsym(gles_android,"glBlendEquationOES"); disp->set_glBlendEquationOES((glBlendEquationOES_t)ptr);
+    ptr = dlsym(gles_android,"glDrawTexsOES"); disp->set_glDrawTexsOES((glDrawTexsOES_t)ptr);
+    ptr = dlsym(gles_android,"glDrawTexiOES"); disp->set_glDrawTexiOES((glDrawTexiOES_t)ptr);
+    ptr = dlsym(gles_android,"glDrawTexxOES"); disp->set_glDrawTexxOES((glDrawTexxOES_t)ptr);
+    ptr = dlsym(gles_android,"glDrawTexsvOES"); disp->set_glDrawTexsvOES((glDrawTexsvOES_t)ptr);
+    ptr = dlsym(gles_android,"glDrawTexivOES"); disp->set_glDrawTexivOES((glDrawTexivOES_t)ptr);
+    ptr = dlsym(gles_android,"glDrawTexxvOES"); disp->set_glDrawTexxvOES((glDrawTexxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glDrawTexfOES"); disp->set_glDrawTexfOES((glDrawTexfOES_t)ptr);
+    ptr = dlsym(gles_android,"glDrawTexfvOES"); disp->set_glDrawTexfvOES((glDrawTexfvOES_t)ptr);
+    ptr = dlsym(gles_android,"glEGLImageTargetTexture2DOES"); disp->set_glEGLImageTargetTexture2DOES((glEGLImageTargetTexture2DOES_t)ptr);
+    ptr = dlsym(gles_android,"glEGLImageTargetRenderbufferStorageOES"); disp->set_glEGLImageTargetRenderbufferStorageOES((glEGLImageTargetRenderbufferStorageOES_t)ptr);
+    ptr = dlsym(gles_android,"glAlphaFuncxOES"); disp->set_glAlphaFuncxOES((glAlphaFuncxOES_t)ptr);
+    ptr = dlsym(gles_android,"glClearColorxOES"); disp->set_glClearColorxOES((glClearColorxOES_t)ptr);
+    ptr = dlsym(gles_android,"glClearDepthxOES"); disp->set_glClearDepthxOES((glClearDepthxOES_t)ptr);
+    ptr = dlsym(gles_android,"glClipPlanexOES"); disp->set_glClipPlanexOES((glClipPlanexOES_t)ptr);
+    ptr = dlsym(gles_android,"glColor4xOES"); disp->set_glColor4xOES((glColor4xOES_t)ptr);
+    ptr = dlsym(gles_android,"glDepthRangexOES"); disp->set_glDepthRangexOES((glDepthRangexOES_t)ptr);
+    ptr = dlsym(gles_android,"glFogxOES"); disp->set_glFogxOES((glFogxOES_t)ptr);
+    ptr = dlsym(gles_android,"glFogxvOES"); disp->set_glFogxvOES((glFogxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glFrustumxOES"); disp->set_glFrustumxOES((glFrustumxOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetClipPlanexOES"); disp->set_glGetClipPlanexOES((glGetClipPlanexOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetFixedvOES"); disp->set_glGetFixedvOES((glGetFixedvOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetLightxvOES"); disp->set_glGetLightxvOES((glGetLightxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetMaterialxvOES"); disp->set_glGetMaterialxvOES((glGetMaterialxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexEnvxvOES"); disp->set_glGetTexEnvxvOES((glGetTexEnvxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexParameterxvOES"); disp->set_glGetTexParameterxvOES((glGetTexParameterxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glLightModelxOES"); disp->set_glLightModelxOES((glLightModelxOES_t)ptr);
+    ptr = dlsym(gles_android,"glLightModelxvOES"); disp->set_glLightModelxvOES((glLightModelxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glLightxOES"); disp->set_glLightxOES((glLightxOES_t)ptr);
+    ptr = dlsym(gles_android,"glLightxvOES"); disp->set_glLightxvOES((glLightxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glLineWidthxOES"); disp->set_glLineWidthxOES((glLineWidthxOES_t)ptr);
+    ptr = dlsym(gles_android,"glLoadMatrixxOES"); disp->set_glLoadMatrixxOES((glLoadMatrixxOES_t)ptr);
+    ptr = dlsym(gles_android,"glMaterialxOES"); disp->set_glMaterialxOES((glMaterialxOES_t)ptr);
+    ptr = dlsym(gles_android,"glMaterialxvOES"); disp->set_glMaterialxvOES((glMaterialxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glMultMatrixxOES"); disp->set_glMultMatrixxOES((glMultMatrixxOES_t)ptr);
+    ptr = dlsym(gles_android,"glMultiTexCoord4xOES"); disp->set_glMultiTexCoord4xOES((glMultiTexCoord4xOES_t)ptr);
+    ptr = dlsym(gles_android,"glNormal3xOES"); disp->set_glNormal3xOES((glNormal3xOES_t)ptr);
+    ptr = dlsym(gles_android,"glOrthoxOES"); disp->set_glOrthoxOES((glOrthoxOES_t)ptr);
+    ptr = dlsym(gles_android,"glPointParameterxOES"); disp->set_glPointParameterxOES((glPointParameterxOES_t)ptr);
+    ptr = dlsym(gles_android,"glPointParameterxvOES"); disp->set_glPointParameterxvOES((glPointParameterxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glPointSizexOES"); disp->set_glPointSizexOES((glPointSizexOES_t)ptr);
+    ptr = dlsym(gles_android,"glPolygonOffsetxOES"); disp->set_glPolygonOffsetxOES((glPolygonOffsetxOES_t)ptr);
+    ptr = dlsym(gles_android,"glRotatexOES"); disp->set_glRotatexOES((glRotatexOES_t)ptr);
+    ptr = dlsym(gles_android,"glSampleCoveragexOES"); disp->set_glSampleCoveragexOES((glSampleCoveragexOES_t)ptr);
+    ptr = dlsym(gles_android,"glScalexOES"); disp->set_glScalexOES((glScalexOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexEnvxOES"); disp->set_glTexEnvxOES((glTexEnvxOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexEnvxvOES"); disp->set_glTexEnvxvOES((glTexEnvxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexParameterxOES"); disp->set_glTexParameterxOES((glTexParameterxOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexParameterxvOES"); disp->set_glTexParameterxvOES((glTexParameterxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glTranslatexOES"); disp->set_glTranslatexOES((glTranslatexOES_t)ptr);
+    ptr = dlsym(gles_android,"glIsRenderbufferOES"); disp->set_glIsRenderbufferOES((glIsRenderbufferOES_t)ptr);
+    ptr = dlsym(gles_android,"glBindRenderbufferOES"); disp->set_glBindRenderbufferOES((glBindRenderbufferOES_t)ptr);
+    ptr = dlsym(gles_android,"glDeleteRenderbuffersOES"); disp->set_glDeleteRenderbuffersOES((glDeleteRenderbuffersOES_t)ptr);
+    ptr = dlsym(gles_android,"glGenRenderbuffersOES"); disp->set_glGenRenderbuffersOES((glGenRenderbuffersOES_t)ptr);
+    ptr = dlsym(gles_android,"glRenderbufferStorageOES"); disp->set_glRenderbufferStorageOES((glRenderbufferStorageOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetRenderbufferParameterivOES"); disp->set_glGetRenderbufferParameterivOES((glGetRenderbufferParameterivOES_t)ptr);
+    ptr = dlsym(gles_android,"glIsFramebufferOES"); disp->set_glIsFramebufferOES((glIsFramebufferOES_t)ptr);
+    ptr = dlsym(gles_android,"glBindFramebufferOES"); disp->set_glBindFramebufferOES((glBindFramebufferOES_t)ptr);
+    ptr = dlsym(gles_android,"glDeleteFramebuffersOES"); disp->set_glDeleteFramebuffersOES((glDeleteFramebuffersOES_t)ptr);
+    ptr = dlsym(gles_android,"glGenFramebuffersOES"); disp->set_glGenFramebuffersOES((glGenFramebuffersOES_t)ptr);
+    ptr = dlsym(gles_android,"glCheckFramebufferStatusOES"); disp->set_glCheckFramebufferStatusOES((glCheckFramebufferStatusOES_t)ptr);
+    ptr = dlsym(gles_android,"glFramebufferRenderbufferOES"); disp->set_glFramebufferRenderbufferOES((glFramebufferRenderbufferOES_t)ptr);
+    ptr = dlsym(gles_android,"glFramebufferTexture2DOES"); disp->set_glFramebufferTexture2DOES((glFramebufferTexture2DOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetFramebufferAttachmentParameterivOES"); disp->set_glGetFramebufferAttachmentParameterivOES((glGetFramebufferAttachmentParameterivOES_t)ptr);
+    ptr = dlsym(gles_android,"glGenerateMipmapOES"); disp->set_glGenerateMipmapOES((glGenerateMipmapOES_t)ptr);
+    ptr = dlsym(gles_android,"glMapBufferOES"); disp->set_glMapBufferOES((glMapBufferOES_t)ptr);
+    ptr = dlsym(gles_android,"glUnmapBufferOES"); disp->set_glUnmapBufferOES((glUnmapBufferOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetBufferPointervOES"); disp->set_glGetBufferPointervOES((glGetBufferPointervOES_t)ptr);
+    ptr = dlsym(gles_android,"glCurrentPaletteMatrixOES"); disp->set_glCurrentPaletteMatrixOES((glCurrentPaletteMatrixOES_t)ptr);
+    ptr = dlsym(gles_android,"glLoadPaletteFromModelViewMatrixOES"); disp->set_glLoadPaletteFromModelViewMatrixOES((glLoadPaletteFromModelViewMatrixOES_t)ptr);
+    ptr = dlsym(gles_android,"glMatrixIndexPointerOES"); disp->set_glMatrixIndexPointerOES((glMatrixIndexPointerOES_t)ptr);
+    ptr = dlsym(gles_android,"glWeightPointerOES"); disp->set_glWeightPointerOES((glWeightPointerOES_t)ptr);
+    ptr = dlsym(gles_android,"glQueryMatrixxOES"); disp->set_glQueryMatrixxOES((glQueryMatrixxOES_t)ptr);
+    ptr = dlsym(gles_android,"glDepthRangefOES"); disp->set_glDepthRangefOES((glDepthRangefOES_t)ptr);
+    ptr = dlsym(gles_android,"glFrustumfOES"); disp->set_glFrustumfOES((glFrustumfOES_t)ptr);
+    ptr = dlsym(gles_android,"glOrthofOES"); disp->set_glOrthofOES((glOrthofOES_t)ptr);
+    ptr = dlsym(gles_android,"glClipPlanefOES"); disp->set_glClipPlanefOES((glClipPlanefOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetClipPlanefOES"); disp->set_glGetClipPlanefOES((glGetClipPlanefOES_t)ptr);
+    ptr = dlsym(gles_android,"glClearDepthfOES"); disp->set_glClearDepthfOES((glClearDepthfOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexGenfOES"); disp->set_glTexGenfOES((glTexGenfOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexGenfvOES"); disp->set_glTexGenfvOES((glTexGenfvOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexGeniOES"); disp->set_glTexGeniOES((glTexGeniOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexGenivOES"); disp->set_glTexGenivOES((glTexGenivOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexGenxOES"); disp->set_glTexGenxOES((glTexGenxOES_t)ptr);
+    ptr = dlsym(gles_android,"glTexGenxvOES"); disp->set_glTexGenxvOES((glTexGenxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexGenfvOES"); disp->set_glGetTexGenfvOES((glGetTexGenfvOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexGenivOES"); disp->set_glGetTexGenivOES((glGetTexGenivOES_t)ptr);
+    ptr = dlsym(gles_android,"glGetTexGenxvOES"); disp->set_glGetTexGenxvOES((glGetTexGenxvOES_t)ptr);
+    ptr = dlsym(gles_android,"glBindVertexArrayOES"); disp->set_glBindVertexArrayOES((glBindVertexArrayOES_t)ptr);
+    ptr = dlsym(gles_android,"glDeleteVertexArraysOES"); disp->set_glDeleteVertexArraysOES((glDeleteVertexArraysOES_t)ptr);
+    ptr = dlsym(gles_android,"glGenVertexArraysOES"); disp->set_glGenVertexArraysOES((glGenVertexArraysOES_t)ptr);
+    ptr = dlsym(gles_android,"glIsVertexArrayOES"); disp->set_glIsVertexArrayOES((glIsVertexArrayOES_t)ptr);
+    ptr = dlsym(gles_android,"glDiscardFramebufferEXT"); disp->set_glDiscardFramebufferEXT((glDiscardFramebufferEXT_t)ptr);
+    ptr = dlsym(gles_android,"glMultiDrawArraysEXT"); disp->set_glMultiDrawArraysEXT((glMultiDrawArraysEXT_t)ptr);
+    ptr = dlsym(gles_android,"glMultiDrawElementsEXT"); disp->set_glMultiDrawElementsEXT((glMultiDrawElementsEXT_t)ptr);
+    ptr = dlsym(gles_android,"glClipPlanefIMG"); disp->set_glClipPlanefIMG((glClipPlanefIMG_t)ptr);
+    ptr = dlsym(gles_android,"glClipPlanexIMG"); disp->set_glClipPlanexIMG((glClipPlanexIMG_t)ptr);
+    ptr = dlsym(gles_android,"glRenderbufferStorageMultisampleIMG"); disp->set_glRenderbufferStorageMultisampleIMG((glRenderbufferStorageMultisampleIMG_t)ptr);
+    ptr = dlsym(gles_android,"glFramebufferTexture2DMultisampleIMG"); disp->set_glFramebufferTexture2DMultisampleIMG((glFramebufferTexture2DMultisampleIMG_t)ptr);
+    ptr = dlsym(gles_android,"glDeleteFencesNV"); disp->set_glDeleteFencesNV((glDeleteFencesNV_t)ptr);
+    ptr = dlsym(gles_android,"glGenFencesNV"); disp->set_glGenFencesNV((glGenFencesNV_t)ptr);
+    ptr = dlsym(gles_android,"glIsFenceNV"); disp->set_glIsFenceNV((glIsFenceNV_t)ptr);
+    ptr = dlsym(gles_android,"glTestFenceNV"); disp->set_glTestFenceNV((glTestFenceNV_t)ptr);
+    ptr = dlsym(gles_android,"glGetFenceivNV"); disp->set_glGetFenceivNV((glGetFenceivNV_t)ptr);
+    ptr = dlsym(gles_android,"glFinishFenceNV"); disp->set_glFinishFenceNV((glFinishFenceNV_t)ptr);
+    ptr = dlsym(gles_android,"glSetFenceNV"); disp->set_glSetFenceNV((glSetFenceNV_t)ptr);
+    ptr = dlsym(gles_android,"glGetDriverControlsQCOM"); disp->set_glGetDriverControlsQCOM((glGetDriverControlsQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glGetDriverControlStringQCOM"); disp->set_glGetDriverControlStringQCOM((glGetDriverControlStringQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glEnableDriverControlQCOM"); disp->set_glEnableDriverControlQCOM((glEnableDriverControlQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glDisableDriverControlQCOM"); disp->set_glDisableDriverControlQCOM((glDisableDriverControlQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetTexturesQCOM"); disp->set_glExtGetTexturesQCOM((glExtGetTexturesQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetBuffersQCOM"); disp->set_glExtGetBuffersQCOM((glExtGetBuffersQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetRenderbuffersQCOM"); disp->set_glExtGetRenderbuffersQCOM((glExtGetRenderbuffersQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetFramebuffersQCOM"); disp->set_glExtGetFramebuffersQCOM((glExtGetFramebuffersQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetTexLevelParameterivQCOM"); disp->set_glExtGetTexLevelParameterivQCOM((glExtGetTexLevelParameterivQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtTexObjectStateOverrideiQCOM"); disp->set_glExtTexObjectStateOverrideiQCOM((glExtTexObjectStateOverrideiQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetTexSubImageQCOM"); disp->set_glExtGetTexSubImageQCOM((glExtGetTexSubImageQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetBufferPointervQCOM"); disp->set_glExtGetBufferPointervQCOM((glExtGetBufferPointervQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetShadersQCOM"); disp->set_glExtGetShadersQCOM((glExtGetShadersQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetProgramsQCOM"); disp->set_glExtGetProgramsQCOM((glExtGetProgramsQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtIsProgramBinaryQCOM"); disp->set_glExtIsProgramBinaryQCOM((glExtIsProgramBinaryQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glExtGetProgramBinarySourceQCOM"); disp->set_glExtGetProgramBinarySourceQCOM((glExtGetProgramBinarySourceQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glStartTilingQCOM"); disp->set_glStartTilingQCOM((glStartTilingQCOM_t)ptr);
+    ptr = dlsym(gles_android,"glEndTilingQCOM"); disp->set_glEndTilingQCOM((glEndTilingQCOM_t)ptr);
+
+        return disp;
+}
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/gles_dispatch.h b/tools/emulator/opengl/tests/gles_android_wrapper/gles_dispatch.h
new file mode 100644
index 0000000..98a4fca
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/gles_dispatch.h
@@ -0,0 +1,570 @@
+/*
+* 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 _GLES_DISPATCH_H
+#define _GLES_DISPATCH_H
+
+#include "gles_proc.h"
+
+
+struct gles_dispatch {
+    glAlphaFunc_t glAlphaFunc;
+    glClearColor_t glClearColor;
+    glClearDepthf_t glClearDepthf;
+    glClipPlanef_t glClipPlanef;
+    glColor4f_t glColor4f;
+    glDepthRangef_t glDepthRangef;
+    glFogf_t glFogf;
+    glFogfv_t glFogfv;
+    glFrustumf_t glFrustumf;
+    glGetClipPlanef_t glGetClipPlanef;
+    glGetFloatv_t glGetFloatv;
+    glGetLightfv_t glGetLightfv;
+    glGetMaterialfv_t glGetMaterialfv;
+    glGetTexEnvfv_t glGetTexEnvfv;
+    glGetTexParameterfv_t glGetTexParameterfv;
+    glLightModelf_t glLightModelf;
+    glLightModelfv_t glLightModelfv;
+    glLightf_t glLightf;
+    glLightfv_t glLightfv;
+    glLineWidth_t glLineWidth;
+    glLoadMatrixf_t glLoadMatrixf;
+    glMaterialf_t glMaterialf;
+    glMaterialfv_t glMaterialfv;
+    glMultMatrixf_t glMultMatrixf;
+    glMultiTexCoord4f_t glMultiTexCoord4f;
+    glNormal3f_t glNormal3f;
+    glOrthof_t glOrthof;
+    glPointParameterf_t glPointParameterf;
+    glPointParameterfv_t glPointParameterfv;
+    glPointSize_t glPointSize;
+    glPolygonOffset_t glPolygonOffset;
+    glRotatef_t glRotatef;
+    glScalef_t glScalef;
+    glTexEnvf_t glTexEnvf;
+    glTexEnvfv_t glTexEnvfv;
+    glTexParameterf_t glTexParameterf;
+    glTexParameterfv_t glTexParameterfv;
+    glTranslatef_t glTranslatef;
+    glActiveTexture_t glActiveTexture;
+    glAlphaFuncx_t glAlphaFuncx;
+    glBindBuffer_t glBindBuffer;
+    glBindTexture_t glBindTexture;
+    glBlendFunc_t glBlendFunc;
+    glBufferData_t glBufferData;
+    glBufferSubData_t glBufferSubData;
+    glClear_t glClear;
+    glClearColorx_t glClearColorx;
+    glClearDepthx_t glClearDepthx;
+    glClearStencil_t glClearStencil;
+    glClientActiveTexture_t glClientActiveTexture;
+    glClipPlanex_t glClipPlanex;
+    glColor4ub_t glColor4ub;
+    glColor4x_t glColor4x;
+    glColorMask_t glColorMask;
+    glColorPointer_t glColorPointer;
+    glCompressedTexImage2D_t glCompressedTexImage2D;
+    glCompressedTexSubImage2D_t glCompressedTexSubImage2D;
+    glCopyTexImage2D_t glCopyTexImage2D;
+    glCopyTexSubImage2D_t glCopyTexSubImage2D;
+    glCullFace_t glCullFace;
+    glDeleteBuffers_t glDeleteBuffers;
+    glDeleteTextures_t glDeleteTextures;
+    glDepthFunc_t glDepthFunc;
+    glDepthMask_t glDepthMask;
+    glDepthRangex_t glDepthRangex;
+    glDisable_t glDisable;
+    glDisableClientState_t glDisableClientState;
+    glDrawArrays_t glDrawArrays;
+    glDrawElements_t glDrawElements;
+    glEnable_t glEnable;
+    glEnableClientState_t glEnableClientState;
+    glFinish_t glFinish;
+    glFlush_t glFlush;
+    glFogx_t glFogx;
+    glFogxv_t glFogxv;
+    glFrontFace_t glFrontFace;
+    glFrustumx_t glFrustumx;
+    glGetBooleanv_t glGetBooleanv;
+    glGetBufferParameteriv_t glGetBufferParameteriv;
+    glGetClipPlanex_t glGetClipPlanex;
+    glGenBuffers_t glGenBuffers;
+    glGenTextures_t glGenTextures;
+    glGetError_t glGetError;
+    glGetFixedv_t glGetFixedv;
+    glGetIntegerv_t glGetIntegerv;
+    glGetLightxv_t glGetLightxv;
+    glGetMaterialxv_t glGetMaterialxv;
+    glGetPointerv_t glGetPointerv;
+    glGetString_t glGetString;
+    glGetTexEnviv_t glGetTexEnviv;
+    glGetTexEnvxv_t glGetTexEnvxv;
+    glGetTexParameteriv_t glGetTexParameteriv;
+    glGetTexParameterxv_t glGetTexParameterxv;
+    glHint_t glHint;
+    glIsBuffer_t glIsBuffer;
+    glIsEnabled_t glIsEnabled;
+    glIsTexture_t glIsTexture;
+    glLightModelx_t glLightModelx;
+    glLightModelxv_t glLightModelxv;
+    glLightx_t glLightx;
+    glLightxv_t glLightxv;
+    glLineWidthx_t glLineWidthx;
+    glLoadIdentity_t glLoadIdentity;
+    glLoadMatrixx_t glLoadMatrixx;
+    glLogicOp_t glLogicOp;
+    glMaterialx_t glMaterialx;
+    glMaterialxv_t glMaterialxv;
+    glMatrixMode_t glMatrixMode;
+    glMultMatrixx_t glMultMatrixx;
+    glMultiTexCoord4x_t glMultiTexCoord4x;
+    glNormal3x_t glNormal3x;
+    glNormalPointer_t glNormalPointer;
+    glOrthox_t glOrthox;
+    glPixelStorei_t glPixelStorei;
+    glPointParameterx_t glPointParameterx;
+    glPointParameterxv_t glPointParameterxv;
+    glPointSizex_t glPointSizex;
+    glPolygonOffsetx_t glPolygonOffsetx;
+    glPopMatrix_t glPopMatrix;
+    glPushMatrix_t glPushMatrix;
+    glReadPixels_t glReadPixels;
+    glRotatex_t glRotatex;
+    glSampleCoverage_t glSampleCoverage;
+    glSampleCoveragex_t glSampleCoveragex;
+    glScalex_t glScalex;
+    glScissor_t glScissor;
+    glShadeModel_t glShadeModel;
+    glStencilFunc_t glStencilFunc;
+    glStencilMask_t glStencilMask;
+    glStencilOp_t glStencilOp;
+    glTexCoordPointer_t glTexCoordPointer;
+    glTexEnvi_t glTexEnvi;
+    glTexEnvx_t glTexEnvx;
+    glTexEnviv_t glTexEnviv;
+    glTexEnvxv_t glTexEnvxv;
+    glTexImage2D_t glTexImage2D;
+    glTexParameteri_t glTexParameteri;
+    glTexParameterx_t glTexParameterx;
+    glTexParameteriv_t glTexParameteriv;
+    glTexParameterxv_t glTexParameterxv;
+    glTexSubImage2D_t glTexSubImage2D;
+    glTranslatex_t glTranslatex;
+    glVertexPointer_t glVertexPointer;
+    glViewport_t glViewport;
+    glPointSizePointerOES_t glPointSizePointerOES;
+    glBlendEquationSeparateOES_t glBlendEquationSeparateOES;
+    glBlendFuncSeparateOES_t glBlendFuncSeparateOES;
+    glBlendEquationOES_t glBlendEquationOES;
+    glDrawTexsOES_t glDrawTexsOES;
+    glDrawTexiOES_t glDrawTexiOES;
+    glDrawTexxOES_t glDrawTexxOES;
+    glDrawTexsvOES_t glDrawTexsvOES;
+    glDrawTexivOES_t glDrawTexivOES;
+    glDrawTexxvOES_t glDrawTexxvOES;
+    glDrawTexfOES_t glDrawTexfOES;
+    glDrawTexfvOES_t glDrawTexfvOES;
+    glEGLImageTargetTexture2DOES_t glEGLImageTargetTexture2DOES;
+    glEGLImageTargetRenderbufferStorageOES_t glEGLImageTargetRenderbufferStorageOES;
+    glAlphaFuncxOES_t glAlphaFuncxOES;
+    glClearColorxOES_t glClearColorxOES;
+    glClearDepthxOES_t glClearDepthxOES;
+    glClipPlanexOES_t glClipPlanexOES;
+    glColor4xOES_t glColor4xOES;
+    glDepthRangexOES_t glDepthRangexOES;
+    glFogxOES_t glFogxOES;
+    glFogxvOES_t glFogxvOES;
+    glFrustumxOES_t glFrustumxOES;
+    glGetClipPlanexOES_t glGetClipPlanexOES;
+    glGetFixedvOES_t glGetFixedvOES;
+    glGetLightxvOES_t glGetLightxvOES;
+    glGetMaterialxvOES_t glGetMaterialxvOES;
+    glGetTexEnvxvOES_t glGetTexEnvxvOES;
+    glGetTexParameterxvOES_t glGetTexParameterxvOES;
+    glLightModelxOES_t glLightModelxOES;
+    glLightModelxvOES_t glLightModelxvOES;
+    glLightxOES_t glLightxOES;
+    glLightxvOES_t glLightxvOES;
+    glLineWidthxOES_t glLineWidthxOES;
+    glLoadMatrixxOES_t glLoadMatrixxOES;
+    glMaterialxOES_t glMaterialxOES;
+    glMaterialxvOES_t glMaterialxvOES;
+    glMultMatrixxOES_t glMultMatrixxOES;
+    glMultiTexCoord4xOES_t glMultiTexCoord4xOES;
+    glNormal3xOES_t glNormal3xOES;
+    glOrthoxOES_t glOrthoxOES;
+    glPointParameterxOES_t glPointParameterxOES;
+    glPointParameterxvOES_t glPointParameterxvOES;
+    glPointSizexOES_t glPointSizexOES;
+    glPolygonOffsetxOES_t glPolygonOffsetxOES;
+    glRotatexOES_t glRotatexOES;
+    glSampleCoveragexOES_t glSampleCoveragexOES;
+    glScalexOES_t glScalexOES;
+    glTexEnvxOES_t glTexEnvxOES;
+    glTexEnvxvOES_t glTexEnvxvOES;
+    glTexParameterxOES_t glTexParameterxOES;
+    glTexParameterxvOES_t glTexParameterxvOES;
+    glTranslatexOES_t glTranslatexOES;
+    glIsRenderbufferOES_t glIsRenderbufferOES;
+    glBindRenderbufferOES_t glBindRenderbufferOES;
+    glDeleteRenderbuffersOES_t glDeleteRenderbuffersOES;
+    glGenRenderbuffersOES_t glGenRenderbuffersOES;
+    glRenderbufferStorageOES_t glRenderbufferStorageOES;
+    glGetRenderbufferParameterivOES_t glGetRenderbufferParameterivOES;
+    glIsFramebufferOES_t glIsFramebufferOES;
+    glBindFramebufferOES_t glBindFramebufferOES;
+    glDeleteFramebuffersOES_t glDeleteFramebuffersOES;
+    glGenFramebuffersOES_t glGenFramebuffersOES;
+    glCheckFramebufferStatusOES_t glCheckFramebufferStatusOES;
+    glFramebufferRenderbufferOES_t glFramebufferRenderbufferOES;
+    glFramebufferTexture2DOES_t glFramebufferTexture2DOES;
+    glGetFramebufferAttachmentParameterivOES_t glGetFramebufferAttachmentParameterivOES;
+    glGenerateMipmapOES_t glGenerateMipmapOES;
+    glMapBufferOES_t glMapBufferOES;
+    glUnmapBufferOES_t glUnmapBufferOES;
+    glGetBufferPointervOES_t glGetBufferPointervOES;
+    glCurrentPaletteMatrixOES_t glCurrentPaletteMatrixOES;
+    glLoadPaletteFromModelViewMatrixOES_t glLoadPaletteFromModelViewMatrixOES;
+    glMatrixIndexPointerOES_t glMatrixIndexPointerOES;
+    glWeightPointerOES_t glWeightPointerOES;
+    glQueryMatrixxOES_t glQueryMatrixxOES;
+    glDepthRangefOES_t glDepthRangefOES;
+    glFrustumfOES_t glFrustumfOES;
+    glOrthofOES_t glOrthofOES;
+    glClipPlanefOES_t glClipPlanefOES;
+    glGetClipPlanefOES_t glGetClipPlanefOES;
+    glClearDepthfOES_t glClearDepthfOES;
+    glTexGenfOES_t glTexGenfOES;
+    glTexGenfvOES_t glTexGenfvOES;
+    glTexGeniOES_t glTexGeniOES;
+    glTexGenivOES_t glTexGenivOES;
+    glTexGenxOES_t glTexGenxOES;
+    glTexGenxvOES_t glTexGenxvOES;
+    glGetTexGenfvOES_t glGetTexGenfvOES;
+    glGetTexGenivOES_t glGetTexGenivOES;
+    glGetTexGenxvOES_t glGetTexGenxvOES;
+    glBindVertexArrayOES_t glBindVertexArrayOES;
+    glDeleteVertexArraysOES_t glDeleteVertexArraysOES;
+    glGenVertexArraysOES_t glGenVertexArraysOES;
+    glIsVertexArrayOES_t glIsVertexArrayOES;
+    glDiscardFramebufferEXT_t glDiscardFramebufferEXT;
+    glMultiDrawArraysEXT_t glMultiDrawArraysEXT;
+    glMultiDrawElementsEXT_t glMultiDrawElementsEXT;
+    glClipPlanefIMG_t glClipPlanefIMG;
+    glClipPlanexIMG_t glClipPlanexIMG;
+    glRenderbufferStorageMultisampleIMG_t glRenderbufferStorageMultisampleIMG;
+    glFramebufferTexture2DMultisampleIMG_t glFramebufferTexture2DMultisampleIMG;
+    glDeleteFencesNV_t glDeleteFencesNV;
+    glGenFencesNV_t glGenFencesNV;
+    glIsFenceNV_t glIsFenceNV;
+    glTestFenceNV_t glTestFenceNV;
+    glGetFenceivNV_t glGetFenceivNV;
+    glFinishFenceNV_t glFinishFenceNV;
+    glSetFenceNV_t glSetFenceNV;
+    glGetDriverControlsQCOM_t glGetDriverControlsQCOM;
+    glGetDriverControlStringQCOM_t glGetDriverControlStringQCOM;
+    glEnableDriverControlQCOM_t glEnableDriverControlQCOM;
+    glDisableDriverControlQCOM_t glDisableDriverControlQCOM;
+    glExtGetTexturesQCOM_t glExtGetTexturesQCOM;
+    glExtGetBuffersQCOM_t glExtGetBuffersQCOM;
+    glExtGetRenderbuffersQCOM_t glExtGetRenderbuffersQCOM;
+    glExtGetFramebuffersQCOM_t glExtGetFramebuffersQCOM;
+    glExtGetTexLevelParameterivQCOM_t glExtGetTexLevelParameterivQCOM;
+    glExtTexObjectStateOverrideiQCOM_t glExtTexObjectStateOverrideiQCOM;
+    glExtGetTexSubImageQCOM_t glExtGetTexSubImageQCOM;
+    glExtGetBufferPointervQCOM_t glExtGetBufferPointervQCOM;
+    glExtGetShadersQCOM_t glExtGetShadersQCOM;
+    glExtGetProgramsQCOM_t glExtGetProgramsQCOM;
+    glExtIsProgramBinaryQCOM_t glExtIsProgramBinaryQCOM;
+    glExtGetProgramBinarySourceQCOM_t glExtGetProgramBinarySourceQCOM;
+    glStartTilingQCOM_t glStartTilingQCOM;
+    glEndTilingQCOM_t glEndTilingQCOM;
+    //Accessors
+    glAlphaFunc_t set_glAlphaFunc(glAlphaFunc_t f) { glAlphaFunc_t retval = glAlphaFunc; glAlphaFunc = f; return retval;}
+    glClearColor_t set_glClearColor(glClearColor_t f) { glClearColor_t retval = glClearColor; glClearColor = f; return retval;}
+    glClearDepthf_t set_glClearDepthf(glClearDepthf_t f) { glClearDepthf_t retval = glClearDepthf; glClearDepthf = f; return retval;}
+    glClipPlanef_t set_glClipPlanef(glClipPlanef_t f) { glClipPlanef_t retval = glClipPlanef; glClipPlanef = f; return retval;}
+    glColor4f_t set_glColor4f(glColor4f_t f) { glColor4f_t retval = glColor4f; glColor4f = f; return retval;}
+    glDepthRangef_t set_glDepthRangef(glDepthRangef_t f) { glDepthRangef_t retval = glDepthRangef; glDepthRangef = f; return retval;}
+    glFogf_t set_glFogf(glFogf_t f) { glFogf_t retval = glFogf; glFogf = f; return retval;}
+    glFogfv_t set_glFogfv(glFogfv_t f) { glFogfv_t retval = glFogfv; glFogfv = f; return retval;}
+    glFrustumf_t set_glFrustumf(glFrustumf_t f) { glFrustumf_t retval = glFrustumf; glFrustumf = f; return retval;}
+    glGetClipPlanef_t set_glGetClipPlanef(glGetClipPlanef_t f) { glGetClipPlanef_t retval = glGetClipPlanef; glGetClipPlanef = f; return retval;}
+    glGetFloatv_t set_glGetFloatv(glGetFloatv_t f) { glGetFloatv_t retval = glGetFloatv; glGetFloatv = f; return retval;}
+    glGetLightfv_t set_glGetLightfv(glGetLightfv_t f) { glGetLightfv_t retval = glGetLightfv; glGetLightfv = f; return retval;}
+    glGetMaterialfv_t set_glGetMaterialfv(glGetMaterialfv_t f) { glGetMaterialfv_t retval = glGetMaterialfv; glGetMaterialfv = f; return retval;}
+    glGetTexEnvfv_t set_glGetTexEnvfv(glGetTexEnvfv_t f) { glGetTexEnvfv_t retval = glGetTexEnvfv; glGetTexEnvfv = f; return retval;}
+    glGetTexParameterfv_t set_glGetTexParameterfv(glGetTexParameterfv_t f) { glGetTexParameterfv_t retval = glGetTexParameterfv; glGetTexParameterfv = f; return retval;}
+    glLightModelf_t set_glLightModelf(glLightModelf_t f) { glLightModelf_t retval = glLightModelf; glLightModelf = f; return retval;}
+    glLightModelfv_t set_glLightModelfv(glLightModelfv_t f) { glLightModelfv_t retval = glLightModelfv; glLightModelfv = f; return retval;}
+    glLightf_t set_glLightf(glLightf_t f) { glLightf_t retval = glLightf; glLightf = f; return retval;}
+    glLightfv_t set_glLightfv(glLightfv_t f) { glLightfv_t retval = glLightfv; glLightfv = f; return retval;}
+    glLineWidth_t set_glLineWidth(glLineWidth_t f) { glLineWidth_t retval = glLineWidth; glLineWidth = f; return retval;}
+    glLoadMatrixf_t set_glLoadMatrixf(glLoadMatrixf_t f) { glLoadMatrixf_t retval = glLoadMatrixf; glLoadMatrixf = f; return retval;}
+    glMaterialf_t set_glMaterialf(glMaterialf_t f) { glMaterialf_t retval = glMaterialf; glMaterialf = f; return retval;}
+    glMaterialfv_t set_glMaterialfv(glMaterialfv_t f) { glMaterialfv_t retval = glMaterialfv; glMaterialfv = f; return retval;}
+    glMultMatrixf_t set_glMultMatrixf(glMultMatrixf_t f) { glMultMatrixf_t retval = glMultMatrixf; glMultMatrixf = f; return retval;}
+    glMultiTexCoord4f_t set_glMultiTexCoord4f(glMultiTexCoord4f_t f) { glMultiTexCoord4f_t retval = glMultiTexCoord4f; glMultiTexCoord4f = f; return retval;}
+    glNormal3f_t set_glNormal3f(glNormal3f_t f) { glNormal3f_t retval = glNormal3f; glNormal3f = f; return retval;}
+    glOrthof_t set_glOrthof(glOrthof_t f) { glOrthof_t retval = glOrthof; glOrthof = f; return retval;}
+    glPointParameterf_t set_glPointParameterf(glPointParameterf_t f) { glPointParameterf_t retval = glPointParameterf; glPointParameterf = f; return retval;}
+    glPointParameterfv_t set_glPointParameterfv(glPointParameterfv_t f) { glPointParameterfv_t retval = glPointParameterfv; glPointParameterfv = f; return retval;}
+    glPointSize_t set_glPointSize(glPointSize_t f) { glPointSize_t retval = glPointSize; glPointSize = f; return retval;}
+    glPolygonOffset_t set_glPolygonOffset(glPolygonOffset_t f) { glPolygonOffset_t retval = glPolygonOffset; glPolygonOffset = f; return retval;}
+    glRotatef_t set_glRotatef(glRotatef_t f) { glRotatef_t retval = glRotatef; glRotatef = f; return retval;}
+    glScalef_t set_glScalef(glScalef_t f) { glScalef_t retval = glScalef; glScalef = f; return retval;}
+    glTexEnvf_t set_glTexEnvf(glTexEnvf_t f) { glTexEnvf_t retval = glTexEnvf; glTexEnvf = f; return retval;}
+    glTexEnvfv_t set_glTexEnvfv(glTexEnvfv_t f) { glTexEnvfv_t retval = glTexEnvfv; glTexEnvfv = f; return retval;}
+    glTexParameterf_t set_glTexParameterf(glTexParameterf_t f) { glTexParameterf_t retval = glTexParameterf; glTexParameterf = f; return retval;}
+    glTexParameterfv_t set_glTexParameterfv(glTexParameterfv_t f) { glTexParameterfv_t retval = glTexParameterfv; glTexParameterfv = f; return retval;}
+    glTranslatef_t set_glTranslatef(glTranslatef_t f) { glTranslatef_t retval = glTranslatef; glTranslatef = f; return retval;}
+    glActiveTexture_t set_glActiveTexture(glActiveTexture_t f) { glActiveTexture_t retval = glActiveTexture; glActiveTexture = f; return retval;}
+    glAlphaFuncx_t set_glAlphaFuncx(glAlphaFuncx_t f) { glAlphaFuncx_t retval = glAlphaFuncx; glAlphaFuncx = f; return retval;}
+    glBindBuffer_t set_glBindBuffer(glBindBuffer_t f) { glBindBuffer_t retval = glBindBuffer; glBindBuffer = f; return retval;}
+    glBindTexture_t set_glBindTexture(glBindTexture_t f) { glBindTexture_t retval = glBindTexture; glBindTexture = f; return retval;}
+    glBlendFunc_t set_glBlendFunc(glBlendFunc_t f) { glBlendFunc_t retval = glBlendFunc; glBlendFunc = f; return retval;}
+    glBufferData_t set_glBufferData(glBufferData_t f) { glBufferData_t retval = glBufferData; glBufferData = f; return retval;}
+    glBufferSubData_t set_glBufferSubData(glBufferSubData_t f) { glBufferSubData_t retval = glBufferSubData; glBufferSubData = f; return retval;}
+    glClear_t set_glClear(glClear_t f) { glClear_t retval = glClear; glClear = f; return retval;}
+    glClearColorx_t set_glClearColorx(glClearColorx_t f) { glClearColorx_t retval = glClearColorx; glClearColorx = f; return retval;}
+    glClearDepthx_t set_glClearDepthx(glClearDepthx_t f) { glClearDepthx_t retval = glClearDepthx; glClearDepthx = f; return retval;}
+    glClearStencil_t set_glClearStencil(glClearStencil_t f) { glClearStencil_t retval = glClearStencil; glClearStencil = f; return retval;}
+    glClientActiveTexture_t set_glClientActiveTexture(glClientActiveTexture_t f) { glClientActiveTexture_t retval = glClientActiveTexture; glClientActiveTexture = f; return retval;}
+    glClipPlanex_t set_glClipPlanex(glClipPlanex_t f) { glClipPlanex_t retval = glClipPlanex; glClipPlanex = f; return retval;}
+    glColor4ub_t set_glColor4ub(glColor4ub_t f) { glColor4ub_t retval = glColor4ub; glColor4ub = f; return retval;}
+    glColor4x_t set_glColor4x(glColor4x_t f) { glColor4x_t retval = glColor4x; glColor4x = f; return retval;}
+    glColorMask_t set_glColorMask(glColorMask_t f) { glColorMask_t retval = glColorMask; glColorMask = f; return retval;}
+    glColorPointer_t set_glColorPointer(glColorPointer_t f) { glColorPointer_t retval = glColorPointer; glColorPointer = f; return retval;}
+    glCompressedTexImage2D_t set_glCompressedTexImage2D(glCompressedTexImage2D_t f) { glCompressedTexImage2D_t retval = glCompressedTexImage2D; glCompressedTexImage2D = f; return retval;}
+    glCompressedTexSubImage2D_t set_glCompressedTexSubImage2D(glCompressedTexSubImage2D_t f) { glCompressedTexSubImage2D_t retval = glCompressedTexSubImage2D; glCompressedTexSubImage2D = f; return retval;}
+    glCopyTexImage2D_t set_glCopyTexImage2D(glCopyTexImage2D_t f) { glCopyTexImage2D_t retval = glCopyTexImage2D; glCopyTexImage2D = f; return retval;}
+    glCopyTexSubImage2D_t set_glCopyTexSubImage2D(glCopyTexSubImage2D_t f) { glCopyTexSubImage2D_t retval = glCopyTexSubImage2D; glCopyTexSubImage2D = f; return retval;}
+    glCullFace_t set_glCullFace(glCullFace_t f) { glCullFace_t retval = glCullFace; glCullFace = f; return retval;}
+    glDeleteBuffers_t set_glDeleteBuffers(glDeleteBuffers_t f) { glDeleteBuffers_t retval = glDeleteBuffers; glDeleteBuffers = f; return retval;}
+    glDeleteTextures_t set_glDeleteTextures(glDeleteTextures_t f) { glDeleteTextures_t retval = glDeleteTextures; glDeleteTextures = f; return retval;}
+    glDepthFunc_t set_glDepthFunc(glDepthFunc_t f) { glDepthFunc_t retval = glDepthFunc; glDepthFunc = f; return retval;}
+    glDepthMask_t set_glDepthMask(glDepthMask_t f) { glDepthMask_t retval = glDepthMask; glDepthMask = f; return retval;}
+    glDepthRangex_t set_glDepthRangex(glDepthRangex_t f) { glDepthRangex_t retval = glDepthRangex; glDepthRangex = f; return retval;}
+    glDisable_t set_glDisable(glDisable_t f) { glDisable_t retval = glDisable; glDisable = f; return retval;}
+    glDisableClientState_t set_glDisableClientState(glDisableClientState_t f) { glDisableClientState_t retval = glDisableClientState; glDisableClientState = f; return retval;}
+    glDrawArrays_t set_glDrawArrays(glDrawArrays_t f) { glDrawArrays_t retval = glDrawArrays; glDrawArrays = f; return retval;}
+    glDrawElements_t set_glDrawElements(glDrawElements_t f) { glDrawElements_t retval = glDrawElements; glDrawElements = f; return retval;}
+    glEnable_t set_glEnable(glEnable_t f) { glEnable_t retval = glEnable; glEnable = f; return retval;}
+    glEnableClientState_t set_glEnableClientState(glEnableClientState_t f) { glEnableClientState_t retval = glEnableClientState; glEnableClientState = f; return retval;}
+    glFinish_t set_glFinish(glFinish_t f) { glFinish_t retval = glFinish; glFinish = f; return retval;}
+    glFlush_t set_glFlush(glFlush_t f) { glFlush_t retval = glFlush; glFlush = f; return retval;}
+    glFogx_t set_glFogx(glFogx_t f) { glFogx_t retval = glFogx; glFogx = f; return retval;}
+    glFogxv_t set_glFogxv(glFogxv_t f) { glFogxv_t retval = glFogxv; glFogxv = f; return retval;}
+    glFrontFace_t set_glFrontFace(glFrontFace_t f) { glFrontFace_t retval = glFrontFace; glFrontFace = f; return retval;}
+    glFrustumx_t set_glFrustumx(glFrustumx_t f) { glFrustumx_t retval = glFrustumx; glFrustumx = f; return retval;}
+    glGetBooleanv_t set_glGetBooleanv(glGetBooleanv_t f) { glGetBooleanv_t retval = glGetBooleanv; glGetBooleanv = f; return retval;}
+    glGetBufferParameteriv_t set_glGetBufferParameteriv(glGetBufferParameteriv_t f) { glGetBufferParameteriv_t retval = glGetBufferParameteriv; glGetBufferParameteriv = f; return retval;}
+    glGetClipPlanex_t set_glGetClipPlanex(glGetClipPlanex_t f) { glGetClipPlanex_t retval = glGetClipPlanex; glGetClipPlanex = f; return retval;}
+    glGenBuffers_t set_glGenBuffers(glGenBuffers_t f) { glGenBuffers_t retval = glGenBuffers; glGenBuffers = f; return retval;}
+    glGenTextures_t set_glGenTextures(glGenTextures_t f) { glGenTextures_t retval = glGenTextures; glGenTextures = f; return retval;}
+    glGetError_t set_glGetError(glGetError_t f) { glGetError_t retval = glGetError; glGetError = f; return retval;}
+    glGetFixedv_t set_glGetFixedv(glGetFixedv_t f) { glGetFixedv_t retval = glGetFixedv; glGetFixedv = f; return retval;}
+    glGetIntegerv_t set_glGetIntegerv(glGetIntegerv_t f) { glGetIntegerv_t retval = glGetIntegerv; glGetIntegerv = f; return retval;}
+    glGetLightxv_t set_glGetLightxv(glGetLightxv_t f) { glGetLightxv_t retval = glGetLightxv; glGetLightxv = f; return retval;}
+    glGetMaterialxv_t set_glGetMaterialxv(glGetMaterialxv_t f) { glGetMaterialxv_t retval = glGetMaterialxv; glGetMaterialxv = f; return retval;}
+    glGetPointerv_t set_glGetPointerv(glGetPointerv_t f) { glGetPointerv_t retval = glGetPointerv; glGetPointerv = f; return retval;}
+    glGetString_t set_glGetString(glGetString_t f) { glGetString_t retval = glGetString; glGetString = f; return retval;}
+    glGetTexEnviv_t set_glGetTexEnviv(glGetTexEnviv_t f) { glGetTexEnviv_t retval = glGetTexEnviv; glGetTexEnviv = f; return retval;}
+    glGetTexEnvxv_t set_glGetTexEnvxv(glGetTexEnvxv_t f) { glGetTexEnvxv_t retval = glGetTexEnvxv; glGetTexEnvxv = f; return retval;}
+    glGetTexParameteriv_t set_glGetTexParameteriv(glGetTexParameteriv_t f) { glGetTexParameteriv_t retval = glGetTexParameteriv; glGetTexParameteriv = f; return retval;}
+    glGetTexParameterxv_t set_glGetTexParameterxv(glGetTexParameterxv_t f) { glGetTexParameterxv_t retval = glGetTexParameterxv; glGetTexParameterxv = f; return retval;}
+    glHint_t set_glHint(glHint_t f) { glHint_t retval = glHint; glHint = f; return retval;}
+    glIsBuffer_t set_glIsBuffer(glIsBuffer_t f) { glIsBuffer_t retval = glIsBuffer; glIsBuffer = f; return retval;}
+    glIsEnabled_t set_glIsEnabled(glIsEnabled_t f) { glIsEnabled_t retval = glIsEnabled; glIsEnabled = f; return retval;}
+    glIsTexture_t set_glIsTexture(glIsTexture_t f) { glIsTexture_t retval = glIsTexture; glIsTexture = f; return retval;}
+    glLightModelx_t set_glLightModelx(glLightModelx_t f) { glLightModelx_t retval = glLightModelx; glLightModelx = f; return retval;}
+    glLightModelxv_t set_glLightModelxv(glLightModelxv_t f) { glLightModelxv_t retval = glLightModelxv; glLightModelxv = f; return retval;}
+    glLightx_t set_glLightx(glLightx_t f) { glLightx_t retval = glLightx; glLightx = f; return retval;}
+    glLightxv_t set_glLightxv(glLightxv_t f) { glLightxv_t retval = glLightxv; glLightxv = f; return retval;}
+    glLineWidthx_t set_glLineWidthx(glLineWidthx_t f) { glLineWidthx_t retval = glLineWidthx; glLineWidthx = f; return retval;}
+    glLoadIdentity_t set_glLoadIdentity(glLoadIdentity_t f) { glLoadIdentity_t retval = glLoadIdentity; glLoadIdentity = f; return retval;}
+    glLoadMatrixx_t set_glLoadMatrixx(glLoadMatrixx_t f) { glLoadMatrixx_t retval = glLoadMatrixx; glLoadMatrixx = f; return retval;}
+    glLogicOp_t set_glLogicOp(glLogicOp_t f) { glLogicOp_t retval = glLogicOp; glLogicOp = f; return retval;}
+    glMaterialx_t set_glMaterialx(glMaterialx_t f) { glMaterialx_t retval = glMaterialx; glMaterialx = f; return retval;}
+    glMaterialxv_t set_glMaterialxv(glMaterialxv_t f) { glMaterialxv_t retval = glMaterialxv; glMaterialxv = f; return retval;}
+    glMatrixMode_t set_glMatrixMode(glMatrixMode_t f) { glMatrixMode_t retval = glMatrixMode; glMatrixMode = f; return retval;}
+    glMultMatrixx_t set_glMultMatrixx(glMultMatrixx_t f) { glMultMatrixx_t retval = glMultMatrixx; glMultMatrixx = f; return retval;}
+    glMultiTexCoord4x_t set_glMultiTexCoord4x(glMultiTexCoord4x_t f) { glMultiTexCoord4x_t retval = glMultiTexCoord4x; glMultiTexCoord4x = f; return retval;}
+    glNormal3x_t set_glNormal3x(glNormal3x_t f) { glNormal3x_t retval = glNormal3x; glNormal3x = f; return retval;}
+    glNormalPointer_t set_glNormalPointer(glNormalPointer_t f) { glNormalPointer_t retval = glNormalPointer; glNormalPointer = f; return retval;}
+    glOrthox_t set_glOrthox(glOrthox_t f) { glOrthox_t retval = glOrthox; glOrthox = f; return retval;}
+    glPixelStorei_t set_glPixelStorei(glPixelStorei_t f) { glPixelStorei_t retval = glPixelStorei; glPixelStorei = f; return retval;}
+    glPointParameterx_t set_glPointParameterx(glPointParameterx_t f) { glPointParameterx_t retval = glPointParameterx; glPointParameterx = f; return retval;}
+    glPointParameterxv_t set_glPointParameterxv(glPointParameterxv_t f) { glPointParameterxv_t retval = glPointParameterxv; glPointParameterxv = f; return retval;}
+    glPointSizex_t set_glPointSizex(glPointSizex_t f) { glPointSizex_t retval = glPointSizex; glPointSizex = f; return retval;}
+    glPolygonOffsetx_t set_glPolygonOffsetx(glPolygonOffsetx_t f) { glPolygonOffsetx_t retval = glPolygonOffsetx; glPolygonOffsetx = f; return retval;}
+    glPopMatrix_t set_glPopMatrix(glPopMatrix_t f) { glPopMatrix_t retval = glPopMatrix; glPopMatrix = f; return retval;}
+    glPushMatrix_t set_glPushMatrix(glPushMatrix_t f) { glPushMatrix_t retval = glPushMatrix; glPushMatrix = f; return retval;}
+    glReadPixels_t set_glReadPixels(glReadPixels_t f) { glReadPixels_t retval = glReadPixels; glReadPixels = f; return retval;}
+    glRotatex_t set_glRotatex(glRotatex_t f) { glRotatex_t retval = glRotatex; glRotatex = f; return retval;}
+    glSampleCoverage_t set_glSampleCoverage(glSampleCoverage_t f) { glSampleCoverage_t retval = glSampleCoverage; glSampleCoverage = f; return retval;}
+    glSampleCoveragex_t set_glSampleCoveragex(glSampleCoveragex_t f) { glSampleCoveragex_t retval = glSampleCoveragex; glSampleCoveragex = f; return retval;}
+    glScalex_t set_glScalex(glScalex_t f) { glScalex_t retval = glScalex; glScalex = f; return retval;}
+    glScissor_t set_glScissor(glScissor_t f) { glScissor_t retval = glScissor; glScissor = f; return retval;}
+    glShadeModel_t set_glShadeModel(glShadeModel_t f) { glShadeModel_t retval = glShadeModel; glShadeModel = f; return retval;}
+    glStencilFunc_t set_glStencilFunc(glStencilFunc_t f) { glStencilFunc_t retval = glStencilFunc; glStencilFunc = f; return retval;}
+    glStencilMask_t set_glStencilMask(glStencilMask_t f) { glStencilMask_t retval = glStencilMask; glStencilMask = f; return retval;}
+    glStencilOp_t set_glStencilOp(glStencilOp_t f) { glStencilOp_t retval = glStencilOp; glStencilOp = f; return retval;}
+    glTexCoordPointer_t set_glTexCoordPointer(glTexCoordPointer_t f) { glTexCoordPointer_t retval = glTexCoordPointer; glTexCoordPointer = f; return retval;}
+    glTexEnvi_t set_glTexEnvi(glTexEnvi_t f) { glTexEnvi_t retval = glTexEnvi; glTexEnvi = f; return retval;}
+    glTexEnvx_t set_glTexEnvx(glTexEnvx_t f) { glTexEnvx_t retval = glTexEnvx; glTexEnvx = f; return retval;}
+    glTexEnviv_t set_glTexEnviv(glTexEnviv_t f) { glTexEnviv_t retval = glTexEnviv; glTexEnviv = f; return retval;}
+    glTexEnvxv_t set_glTexEnvxv(glTexEnvxv_t f) { glTexEnvxv_t retval = glTexEnvxv; glTexEnvxv = f; return retval;}
+    glTexImage2D_t set_glTexImage2D(glTexImage2D_t f) { glTexImage2D_t retval = glTexImage2D; glTexImage2D = f; return retval;}
+    glTexParameteri_t set_glTexParameteri(glTexParameteri_t f) { glTexParameteri_t retval = glTexParameteri; glTexParameteri = f; return retval;}
+    glTexParameterx_t set_glTexParameterx(glTexParameterx_t f) { glTexParameterx_t retval = glTexParameterx; glTexParameterx = f; return retval;}
+    glTexParameteriv_t set_glTexParameteriv(glTexParameteriv_t f) { glTexParameteriv_t retval = glTexParameteriv; glTexParameteriv = f; return retval;}
+    glTexParameterxv_t set_glTexParameterxv(glTexParameterxv_t f) { glTexParameterxv_t retval = glTexParameterxv; glTexParameterxv = f; return retval;}
+    glTexSubImage2D_t set_glTexSubImage2D(glTexSubImage2D_t f) { glTexSubImage2D_t retval = glTexSubImage2D; glTexSubImage2D = f; return retval;}
+    glTranslatex_t set_glTranslatex(glTranslatex_t f) { glTranslatex_t retval = glTranslatex; glTranslatex = f; return retval;}
+    glVertexPointer_t set_glVertexPointer(glVertexPointer_t f) { glVertexPointer_t retval = glVertexPointer; glVertexPointer = f; return retval;}
+    glViewport_t set_glViewport(glViewport_t f) { glViewport_t retval = glViewport; glViewport = f; return retval;}
+    glPointSizePointerOES_t set_glPointSizePointerOES(glPointSizePointerOES_t f) { glPointSizePointerOES_t retval = glPointSizePointerOES; glPointSizePointerOES = f; return retval;}
+    glBlendEquationSeparateOES_t set_glBlendEquationSeparateOES(glBlendEquationSeparateOES_t f) { glBlendEquationSeparateOES_t retval = glBlendEquationSeparateOES; glBlendEquationSeparateOES = f; return retval;}
+    glBlendFuncSeparateOES_t set_glBlendFuncSeparateOES(glBlendFuncSeparateOES_t f) { glBlendFuncSeparateOES_t retval = glBlendFuncSeparateOES; glBlendFuncSeparateOES = f; return retval;}
+    glBlendEquationOES_t set_glBlendEquationOES(glBlendEquationOES_t f) { glBlendEquationOES_t retval = glBlendEquationOES; glBlendEquationOES = f; return retval;}
+    glDrawTexsOES_t set_glDrawTexsOES(glDrawTexsOES_t f) { glDrawTexsOES_t retval = glDrawTexsOES; glDrawTexsOES = f; return retval;}
+    glDrawTexiOES_t set_glDrawTexiOES(glDrawTexiOES_t f) { glDrawTexiOES_t retval = glDrawTexiOES; glDrawTexiOES = f; return retval;}
+    glDrawTexxOES_t set_glDrawTexxOES(glDrawTexxOES_t f) { glDrawTexxOES_t retval = glDrawTexxOES; glDrawTexxOES = f; return retval;}
+    glDrawTexsvOES_t set_glDrawTexsvOES(glDrawTexsvOES_t f) { glDrawTexsvOES_t retval = glDrawTexsvOES; glDrawTexsvOES = f; return retval;}
+    glDrawTexivOES_t set_glDrawTexivOES(glDrawTexivOES_t f) { glDrawTexivOES_t retval = glDrawTexivOES; glDrawTexivOES = f; return retval;}
+    glDrawTexxvOES_t set_glDrawTexxvOES(glDrawTexxvOES_t f) { glDrawTexxvOES_t retval = glDrawTexxvOES; glDrawTexxvOES = f; return retval;}
+    glDrawTexfOES_t set_glDrawTexfOES(glDrawTexfOES_t f) { glDrawTexfOES_t retval = glDrawTexfOES; glDrawTexfOES = f; return retval;}
+    glDrawTexfvOES_t set_glDrawTexfvOES(glDrawTexfvOES_t f) { glDrawTexfvOES_t retval = glDrawTexfvOES; glDrawTexfvOES = f; return retval;}
+    glEGLImageTargetTexture2DOES_t set_glEGLImageTargetTexture2DOES(glEGLImageTargetTexture2DOES_t f) { glEGLImageTargetTexture2DOES_t retval = glEGLImageTargetTexture2DOES; glEGLImageTargetTexture2DOES = f; return retval;}
+    glEGLImageTargetRenderbufferStorageOES_t set_glEGLImageTargetRenderbufferStorageOES(glEGLImageTargetRenderbufferStorageOES_t f) { glEGLImageTargetRenderbufferStorageOES_t retval = glEGLImageTargetRenderbufferStorageOES; glEGLImageTargetRenderbufferStorageOES = f; return retval;}
+    glAlphaFuncxOES_t set_glAlphaFuncxOES(glAlphaFuncxOES_t f) { glAlphaFuncxOES_t retval = glAlphaFuncxOES; glAlphaFuncxOES = f; return retval;}
+    glClearColorxOES_t set_glClearColorxOES(glClearColorxOES_t f) { glClearColorxOES_t retval = glClearColorxOES; glClearColorxOES = f; return retval;}
+    glClearDepthxOES_t set_glClearDepthxOES(glClearDepthxOES_t f) { glClearDepthxOES_t retval = glClearDepthxOES; glClearDepthxOES = f; return retval;}
+    glClipPlanexOES_t set_glClipPlanexOES(glClipPlanexOES_t f) { glClipPlanexOES_t retval = glClipPlanexOES; glClipPlanexOES = f; return retval;}
+    glColor4xOES_t set_glColor4xOES(glColor4xOES_t f) { glColor4xOES_t retval = glColor4xOES; glColor4xOES = f; return retval;}
+    glDepthRangexOES_t set_glDepthRangexOES(glDepthRangexOES_t f) { glDepthRangexOES_t retval = glDepthRangexOES; glDepthRangexOES = f; return retval;}
+    glFogxOES_t set_glFogxOES(glFogxOES_t f) { glFogxOES_t retval = glFogxOES; glFogxOES = f; return retval;}
+    glFogxvOES_t set_glFogxvOES(glFogxvOES_t f) { glFogxvOES_t retval = glFogxvOES; glFogxvOES = f; return retval;}
+    glFrustumxOES_t set_glFrustumxOES(glFrustumxOES_t f) { glFrustumxOES_t retval = glFrustumxOES; glFrustumxOES = f; return retval;}
+    glGetClipPlanexOES_t set_glGetClipPlanexOES(glGetClipPlanexOES_t f) { glGetClipPlanexOES_t retval = glGetClipPlanexOES; glGetClipPlanexOES = f; return retval;}
+    glGetFixedvOES_t set_glGetFixedvOES(glGetFixedvOES_t f) { glGetFixedvOES_t retval = glGetFixedvOES; glGetFixedvOES = f; return retval;}
+    glGetLightxvOES_t set_glGetLightxvOES(glGetLightxvOES_t f) { glGetLightxvOES_t retval = glGetLightxvOES; glGetLightxvOES = f; return retval;}
+    glGetMaterialxvOES_t set_glGetMaterialxvOES(glGetMaterialxvOES_t f) { glGetMaterialxvOES_t retval = glGetMaterialxvOES; glGetMaterialxvOES = f; return retval;}
+    glGetTexEnvxvOES_t set_glGetTexEnvxvOES(glGetTexEnvxvOES_t f) { glGetTexEnvxvOES_t retval = glGetTexEnvxvOES; glGetTexEnvxvOES = f; return retval;}
+    glGetTexParameterxvOES_t set_glGetTexParameterxvOES(glGetTexParameterxvOES_t f) { glGetTexParameterxvOES_t retval = glGetTexParameterxvOES; glGetTexParameterxvOES = f; return retval;}
+    glLightModelxOES_t set_glLightModelxOES(glLightModelxOES_t f) { glLightModelxOES_t retval = glLightModelxOES; glLightModelxOES = f; return retval;}
+    glLightModelxvOES_t set_glLightModelxvOES(glLightModelxvOES_t f) { glLightModelxvOES_t retval = glLightModelxvOES; glLightModelxvOES = f; return retval;}
+    glLightxOES_t set_glLightxOES(glLightxOES_t f) { glLightxOES_t retval = glLightxOES; glLightxOES = f; return retval;}
+    glLightxvOES_t set_glLightxvOES(glLightxvOES_t f) { glLightxvOES_t retval = glLightxvOES; glLightxvOES = f; return retval;}
+    glLineWidthxOES_t set_glLineWidthxOES(glLineWidthxOES_t f) { glLineWidthxOES_t retval = glLineWidthxOES; glLineWidthxOES = f; return retval;}
+    glLoadMatrixxOES_t set_glLoadMatrixxOES(glLoadMatrixxOES_t f) { glLoadMatrixxOES_t retval = glLoadMatrixxOES; glLoadMatrixxOES = f; return retval;}
+    glMaterialxOES_t set_glMaterialxOES(glMaterialxOES_t f) { glMaterialxOES_t retval = glMaterialxOES; glMaterialxOES = f; return retval;}
+    glMaterialxvOES_t set_glMaterialxvOES(glMaterialxvOES_t f) { glMaterialxvOES_t retval = glMaterialxvOES; glMaterialxvOES = f; return retval;}
+    glMultMatrixxOES_t set_glMultMatrixxOES(glMultMatrixxOES_t f) { glMultMatrixxOES_t retval = glMultMatrixxOES; glMultMatrixxOES = f; return retval;}
+    glMultiTexCoord4xOES_t set_glMultiTexCoord4xOES(glMultiTexCoord4xOES_t f) { glMultiTexCoord4xOES_t retval = glMultiTexCoord4xOES; glMultiTexCoord4xOES = f; return retval;}
+    glNormal3xOES_t set_glNormal3xOES(glNormal3xOES_t f) { glNormal3xOES_t retval = glNormal3xOES; glNormal3xOES = f; return retval;}
+    glOrthoxOES_t set_glOrthoxOES(glOrthoxOES_t f) { glOrthoxOES_t retval = glOrthoxOES; glOrthoxOES = f; return retval;}
+    glPointParameterxOES_t set_glPointParameterxOES(glPointParameterxOES_t f) { glPointParameterxOES_t retval = glPointParameterxOES; glPointParameterxOES = f; return retval;}
+    glPointParameterxvOES_t set_glPointParameterxvOES(glPointParameterxvOES_t f) { glPointParameterxvOES_t retval = glPointParameterxvOES; glPointParameterxvOES = f; return retval;}
+    glPointSizexOES_t set_glPointSizexOES(glPointSizexOES_t f) { glPointSizexOES_t retval = glPointSizexOES; glPointSizexOES = f; return retval;}
+    glPolygonOffsetxOES_t set_glPolygonOffsetxOES(glPolygonOffsetxOES_t f) { glPolygonOffsetxOES_t retval = glPolygonOffsetxOES; glPolygonOffsetxOES = f; return retval;}
+    glRotatexOES_t set_glRotatexOES(glRotatexOES_t f) { glRotatexOES_t retval = glRotatexOES; glRotatexOES = f; return retval;}
+    glSampleCoveragexOES_t set_glSampleCoveragexOES(glSampleCoveragexOES_t f) { glSampleCoveragexOES_t retval = glSampleCoveragexOES; glSampleCoveragexOES = f; return retval;}
+    glScalexOES_t set_glScalexOES(glScalexOES_t f) { glScalexOES_t retval = glScalexOES; glScalexOES = f; return retval;}
+    glTexEnvxOES_t set_glTexEnvxOES(glTexEnvxOES_t f) { glTexEnvxOES_t retval = glTexEnvxOES; glTexEnvxOES = f; return retval;}
+    glTexEnvxvOES_t set_glTexEnvxvOES(glTexEnvxvOES_t f) { glTexEnvxvOES_t retval = glTexEnvxvOES; glTexEnvxvOES = f; return retval;}
+    glTexParameterxOES_t set_glTexParameterxOES(glTexParameterxOES_t f) { glTexParameterxOES_t retval = glTexParameterxOES; glTexParameterxOES = f; return retval;}
+    glTexParameterxvOES_t set_glTexParameterxvOES(glTexParameterxvOES_t f) { glTexParameterxvOES_t retval = glTexParameterxvOES; glTexParameterxvOES = f; return retval;}
+    glTranslatexOES_t set_glTranslatexOES(glTranslatexOES_t f) { glTranslatexOES_t retval = glTranslatexOES; glTranslatexOES = f; return retval;}
+    glIsRenderbufferOES_t set_glIsRenderbufferOES(glIsRenderbufferOES_t f) { glIsRenderbufferOES_t retval = glIsRenderbufferOES; glIsRenderbufferOES = f; return retval;}
+    glBindRenderbufferOES_t set_glBindRenderbufferOES(glBindRenderbufferOES_t f) { glBindRenderbufferOES_t retval = glBindRenderbufferOES; glBindRenderbufferOES = f; return retval;}
+    glDeleteRenderbuffersOES_t set_glDeleteRenderbuffersOES(glDeleteRenderbuffersOES_t f) { glDeleteRenderbuffersOES_t retval = glDeleteRenderbuffersOES; glDeleteRenderbuffersOES = f; return retval;}
+    glGenRenderbuffersOES_t set_glGenRenderbuffersOES(glGenRenderbuffersOES_t f) { glGenRenderbuffersOES_t retval = glGenRenderbuffersOES; glGenRenderbuffersOES = f; return retval;}
+    glRenderbufferStorageOES_t set_glRenderbufferStorageOES(glRenderbufferStorageOES_t f) { glRenderbufferStorageOES_t retval = glRenderbufferStorageOES; glRenderbufferStorageOES = f; return retval;}
+    glGetRenderbufferParameterivOES_t set_glGetRenderbufferParameterivOES(glGetRenderbufferParameterivOES_t f) { glGetRenderbufferParameterivOES_t retval = glGetRenderbufferParameterivOES; glGetRenderbufferParameterivOES = f; return retval;}
+    glIsFramebufferOES_t set_glIsFramebufferOES(glIsFramebufferOES_t f) { glIsFramebufferOES_t retval = glIsFramebufferOES; glIsFramebufferOES = f; return retval;}
+    glBindFramebufferOES_t set_glBindFramebufferOES(glBindFramebufferOES_t f) { glBindFramebufferOES_t retval = glBindFramebufferOES; glBindFramebufferOES = f; return retval;}
+    glDeleteFramebuffersOES_t set_glDeleteFramebuffersOES(glDeleteFramebuffersOES_t f) { glDeleteFramebuffersOES_t retval = glDeleteFramebuffersOES; glDeleteFramebuffersOES = f; return retval;}
+    glGenFramebuffersOES_t set_glGenFramebuffersOES(glGenFramebuffersOES_t f) { glGenFramebuffersOES_t retval = glGenFramebuffersOES; glGenFramebuffersOES = f; return retval;}
+    glCheckFramebufferStatusOES_t set_glCheckFramebufferStatusOES(glCheckFramebufferStatusOES_t f) { glCheckFramebufferStatusOES_t retval = glCheckFramebufferStatusOES; glCheckFramebufferStatusOES = f; return retval;}
+    glFramebufferRenderbufferOES_t set_glFramebufferRenderbufferOES(glFramebufferRenderbufferOES_t f) { glFramebufferRenderbufferOES_t retval = glFramebufferRenderbufferOES; glFramebufferRenderbufferOES = f; return retval;}
+    glFramebufferTexture2DOES_t set_glFramebufferTexture2DOES(glFramebufferTexture2DOES_t f) { glFramebufferTexture2DOES_t retval = glFramebufferTexture2DOES; glFramebufferTexture2DOES = f; return retval;}
+    glGetFramebufferAttachmentParameterivOES_t set_glGetFramebufferAttachmentParameterivOES(glGetFramebufferAttachmentParameterivOES_t f) { glGetFramebufferAttachmentParameterivOES_t retval = glGetFramebufferAttachmentParameterivOES; glGetFramebufferAttachmentParameterivOES = f; return retval;}
+    glGenerateMipmapOES_t set_glGenerateMipmapOES(glGenerateMipmapOES_t f) { glGenerateMipmapOES_t retval = glGenerateMipmapOES; glGenerateMipmapOES = f; return retval;}
+    glMapBufferOES_t set_glMapBufferOES(glMapBufferOES_t f) { glMapBufferOES_t retval = glMapBufferOES; glMapBufferOES = f; return retval;}
+    glUnmapBufferOES_t set_glUnmapBufferOES(glUnmapBufferOES_t f) { glUnmapBufferOES_t retval = glUnmapBufferOES; glUnmapBufferOES = f; return retval;}
+    glGetBufferPointervOES_t set_glGetBufferPointervOES(glGetBufferPointervOES_t f) { glGetBufferPointervOES_t retval = glGetBufferPointervOES; glGetBufferPointervOES = f; return retval;}
+    glCurrentPaletteMatrixOES_t set_glCurrentPaletteMatrixOES(glCurrentPaletteMatrixOES_t f) { glCurrentPaletteMatrixOES_t retval = glCurrentPaletteMatrixOES; glCurrentPaletteMatrixOES = f; return retval;}
+    glLoadPaletteFromModelViewMatrixOES_t set_glLoadPaletteFromModelViewMatrixOES(glLoadPaletteFromModelViewMatrixOES_t f) { glLoadPaletteFromModelViewMatrixOES_t retval = glLoadPaletteFromModelViewMatrixOES; glLoadPaletteFromModelViewMatrixOES = f; return retval;}
+    glMatrixIndexPointerOES_t set_glMatrixIndexPointerOES(glMatrixIndexPointerOES_t f) { glMatrixIndexPointerOES_t retval = glMatrixIndexPointerOES; glMatrixIndexPointerOES = f; return retval;}
+    glWeightPointerOES_t set_glWeightPointerOES(glWeightPointerOES_t f) { glWeightPointerOES_t retval = glWeightPointerOES; glWeightPointerOES = f; return retval;}
+    glQueryMatrixxOES_t set_glQueryMatrixxOES(glQueryMatrixxOES_t f) { glQueryMatrixxOES_t retval = glQueryMatrixxOES; glQueryMatrixxOES = f; return retval;}
+    glDepthRangefOES_t set_glDepthRangefOES(glDepthRangefOES_t f) { glDepthRangefOES_t retval = glDepthRangefOES; glDepthRangefOES = f; return retval;}
+    glFrustumfOES_t set_glFrustumfOES(glFrustumfOES_t f) { glFrustumfOES_t retval = glFrustumfOES; glFrustumfOES = f; return retval;}
+    glOrthofOES_t set_glOrthofOES(glOrthofOES_t f) { glOrthofOES_t retval = glOrthofOES; glOrthofOES = f; return retval;}
+    glClipPlanefOES_t set_glClipPlanefOES(glClipPlanefOES_t f) { glClipPlanefOES_t retval = glClipPlanefOES; glClipPlanefOES = f; return retval;}
+    glGetClipPlanefOES_t set_glGetClipPlanefOES(glGetClipPlanefOES_t f) { glGetClipPlanefOES_t retval = glGetClipPlanefOES; glGetClipPlanefOES = f; return retval;}
+    glClearDepthfOES_t set_glClearDepthfOES(glClearDepthfOES_t f) { glClearDepthfOES_t retval = glClearDepthfOES; glClearDepthfOES = f; return retval;}
+    glTexGenfOES_t set_glTexGenfOES(glTexGenfOES_t f) { glTexGenfOES_t retval = glTexGenfOES; glTexGenfOES = f; return retval;}
+    glTexGenfvOES_t set_glTexGenfvOES(glTexGenfvOES_t f) { glTexGenfvOES_t retval = glTexGenfvOES; glTexGenfvOES = f; return retval;}
+    glTexGeniOES_t set_glTexGeniOES(glTexGeniOES_t f) { glTexGeniOES_t retval = glTexGeniOES; glTexGeniOES = f; return retval;}
+    glTexGenivOES_t set_glTexGenivOES(glTexGenivOES_t f) { glTexGenivOES_t retval = glTexGenivOES; glTexGenivOES = f; return retval;}
+    glTexGenxOES_t set_glTexGenxOES(glTexGenxOES_t f) { glTexGenxOES_t retval = glTexGenxOES; glTexGenxOES = f; return retval;}
+    glTexGenxvOES_t set_glTexGenxvOES(glTexGenxvOES_t f) { glTexGenxvOES_t retval = glTexGenxvOES; glTexGenxvOES = f; return retval;}
+    glGetTexGenfvOES_t set_glGetTexGenfvOES(glGetTexGenfvOES_t f) { glGetTexGenfvOES_t retval = glGetTexGenfvOES; glGetTexGenfvOES = f; return retval;}
+    glGetTexGenivOES_t set_glGetTexGenivOES(glGetTexGenivOES_t f) { glGetTexGenivOES_t retval = glGetTexGenivOES; glGetTexGenivOES = f; return retval;}
+    glGetTexGenxvOES_t set_glGetTexGenxvOES(glGetTexGenxvOES_t f) { glGetTexGenxvOES_t retval = glGetTexGenxvOES; glGetTexGenxvOES = f; return retval;}
+    glBindVertexArrayOES_t set_glBindVertexArrayOES(glBindVertexArrayOES_t f) { glBindVertexArrayOES_t retval = glBindVertexArrayOES; glBindVertexArrayOES = f; return retval;}
+    glDeleteVertexArraysOES_t set_glDeleteVertexArraysOES(glDeleteVertexArraysOES_t f) { glDeleteVertexArraysOES_t retval = glDeleteVertexArraysOES; glDeleteVertexArraysOES = f; return retval;}
+    glGenVertexArraysOES_t set_glGenVertexArraysOES(glGenVertexArraysOES_t f) { glGenVertexArraysOES_t retval = glGenVertexArraysOES; glGenVertexArraysOES = f; return retval;}
+    glIsVertexArrayOES_t set_glIsVertexArrayOES(glIsVertexArrayOES_t f) { glIsVertexArrayOES_t retval = glIsVertexArrayOES; glIsVertexArrayOES = f; return retval;}
+    glDiscardFramebufferEXT_t set_glDiscardFramebufferEXT(glDiscardFramebufferEXT_t f) { glDiscardFramebufferEXT_t retval = glDiscardFramebufferEXT; glDiscardFramebufferEXT = f; return retval;}
+    glMultiDrawArraysEXT_t set_glMultiDrawArraysEXT(glMultiDrawArraysEXT_t f) { glMultiDrawArraysEXT_t retval = glMultiDrawArraysEXT; glMultiDrawArraysEXT = f; return retval;}
+    glMultiDrawElementsEXT_t set_glMultiDrawElementsEXT(glMultiDrawElementsEXT_t f) { glMultiDrawElementsEXT_t retval = glMultiDrawElementsEXT; glMultiDrawElementsEXT = f; return retval;}
+    glClipPlanefIMG_t set_glClipPlanefIMG(glClipPlanefIMG_t f) { glClipPlanefIMG_t retval = glClipPlanefIMG; glClipPlanefIMG = f; return retval;}
+    glClipPlanexIMG_t set_glClipPlanexIMG(glClipPlanexIMG_t f) { glClipPlanexIMG_t retval = glClipPlanexIMG; glClipPlanexIMG = f; return retval;}
+    glRenderbufferStorageMultisampleIMG_t set_glRenderbufferStorageMultisampleIMG(glRenderbufferStorageMultisampleIMG_t f) { glRenderbufferStorageMultisampleIMG_t retval = glRenderbufferStorageMultisampleIMG; glRenderbufferStorageMultisampleIMG = f; return retval;}
+    glFramebufferTexture2DMultisampleIMG_t set_glFramebufferTexture2DMultisampleIMG(glFramebufferTexture2DMultisampleIMG_t f) { glFramebufferTexture2DMultisampleIMG_t retval = glFramebufferTexture2DMultisampleIMG; glFramebufferTexture2DMultisampleIMG = f; return retval;}
+    glDeleteFencesNV_t set_glDeleteFencesNV(glDeleteFencesNV_t f) { glDeleteFencesNV_t retval = glDeleteFencesNV; glDeleteFencesNV = f; return retval;}
+    glGenFencesNV_t set_glGenFencesNV(glGenFencesNV_t f) { glGenFencesNV_t retval = glGenFencesNV; glGenFencesNV = f; return retval;}
+    glIsFenceNV_t set_glIsFenceNV(glIsFenceNV_t f) { glIsFenceNV_t retval = glIsFenceNV; glIsFenceNV = f; return retval;}
+    glTestFenceNV_t set_glTestFenceNV(glTestFenceNV_t f) { glTestFenceNV_t retval = glTestFenceNV; glTestFenceNV = f; return retval;}
+    glGetFenceivNV_t set_glGetFenceivNV(glGetFenceivNV_t f) { glGetFenceivNV_t retval = glGetFenceivNV; glGetFenceivNV = f; return retval;}
+    glFinishFenceNV_t set_glFinishFenceNV(glFinishFenceNV_t f) { glFinishFenceNV_t retval = glFinishFenceNV; glFinishFenceNV = f; return retval;}
+    glSetFenceNV_t set_glSetFenceNV(glSetFenceNV_t f) { glSetFenceNV_t retval = glSetFenceNV; glSetFenceNV = f; return retval;}
+    glGetDriverControlsQCOM_t set_glGetDriverControlsQCOM(glGetDriverControlsQCOM_t f) { glGetDriverControlsQCOM_t retval = glGetDriverControlsQCOM; glGetDriverControlsQCOM = f; return retval;}
+    glGetDriverControlStringQCOM_t set_glGetDriverControlStringQCOM(glGetDriverControlStringQCOM_t f) { glGetDriverControlStringQCOM_t retval = glGetDriverControlStringQCOM; glGetDriverControlStringQCOM = f; return retval;}
+    glEnableDriverControlQCOM_t set_glEnableDriverControlQCOM(glEnableDriverControlQCOM_t f) { glEnableDriverControlQCOM_t retval = glEnableDriverControlQCOM; glEnableDriverControlQCOM = f; return retval;}
+    glDisableDriverControlQCOM_t set_glDisableDriverControlQCOM(glDisableDriverControlQCOM_t f) { glDisableDriverControlQCOM_t retval = glDisableDriverControlQCOM; glDisableDriverControlQCOM = f; return retval;}
+    glExtGetTexturesQCOM_t set_glExtGetTexturesQCOM(glExtGetTexturesQCOM_t f) { glExtGetTexturesQCOM_t retval = glExtGetTexturesQCOM; glExtGetTexturesQCOM = f; return retval;}
+    glExtGetBuffersQCOM_t set_glExtGetBuffersQCOM(glExtGetBuffersQCOM_t f) { glExtGetBuffersQCOM_t retval = glExtGetBuffersQCOM; glExtGetBuffersQCOM = f; return retval;}
+    glExtGetRenderbuffersQCOM_t set_glExtGetRenderbuffersQCOM(glExtGetRenderbuffersQCOM_t f) { glExtGetRenderbuffersQCOM_t retval = glExtGetRenderbuffersQCOM; glExtGetRenderbuffersQCOM = f; return retval;}
+    glExtGetFramebuffersQCOM_t set_glExtGetFramebuffersQCOM(glExtGetFramebuffersQCOM_t f) { glExtGetFramebuffersQCOM_t retval = glExtGetFramebuffersQCOM; glExtGetFramebuffersQCOM = f; return retval;}
+    glExtGetTexLevelParameterivQCOM_t set_glExtGetTexLevelParameterivQCOM(glExtGetTexLevelParameterivQCOM_t f) { glExtGetTexLevelParameterivQCOM_t retval = glExtGetTexLevelParameterivQCOM; glExtGetTexLevelParameterivQCOM = f; return retval;}
+    glExtTexObjectStateOverrideiQCOM_t set_glExtTexObjectStateOverrideiQCOM(glExtTexObjectStateOverrideiQCOM_t f) { glExtTexObjectStateOverrideiQCOM_t retval = glExtTexObjectStateOverrideiQCOM; glExtTexObjectStateOverrideiQCOM = f; return retval;}
+    glExtGetTexSubImageQCOM_t set_glExtGetTexSubImageQCOM(glExtGetTexSubImageQCOM_t f) { glExtGetTexSubImageQCOM_t retval = glExtGetTexSubImageQCOM; glExtGetTexSubImageQCOM = f; return retval;}
+    glExtGetBufferPointervQCOM_t set_glExtGetBufferPointervQCOM(glExtGetBufferPointervQCOM_t f) { glExtGetBufferPointervQCOM_t retval = glExtGetBufferPointervQCOM; glExtGetBufferPointervQCOM = f; return retval;}
+    glExtGetShadersQCOM_t set_glExtGetShadersQCOM(glExtGetShadersQCOM_t f) { glExtGetShadersQCOM_t retval = glExtGetShadersQCOM; glExtGetShadersQCOM = f; return retval;}
+    glExtGetProgramsQCOM_t set_glExtGetProgramsQCOM(glExtGetProgramsQCOM_t f) { glExtGetProgramsQCOM_t retval = glExtGetProgramsQCOM; glExtGetProgramsQCOM = f; return retval;}
+    glExtIsProgramBinaryQCOM_t set_glExtIsProgramBinaryQCOM(glExtIsProgramBinaryQCOM_t f) { glExtIsProgramBinaryQCOM_t retval = glExtIsProgramBinaryQCOM; glExtIsProgramBinaryQCOM = f; return retval;}
+    glExtGetProgramBinarySourceQCOM_t set_glExtGetProgramBinarySourceQCOM(glExtGetProgramBinarySourceQCOM_t f) { glExtGetProgramBinarySourceQCOM_t retval = glExtGetProgramBinarySourceQCOM; glExtGetProgramBinarySourceQCOM = f; return retval;}
+    glStartTilingQCOM_t set_glStartTilingQCOM(glStartTilingQCOM_t f) { glStartTilingQCOM_t retval = glStartTilingQCOM; glStartTilingQCOM = f; return retval;}
+    glEndTilingQCOM_t set_glEndTilingQCOM(glEndTilingQCOM_t f) { glEndTilingQCOM_t retval = glEndTilingQCOM; glEndTilingQCOM = f; return retval;}
+};
+
+gles_dispatch *create_gles_dispatch(void *gles_andorid);
+
+#endif
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/gles_emul.cfg b/tools/emulator/opengl/tests/gles_android_wrapper/gles_emul.cfg
new file mode 100644
index 0000000..fcb0aeb
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/gles_emul.cfg
@@ -0,0 +1,5 @@
+angeles
+my-tritex
+org.zeroxlab.benchmark
+com.cooliris.media
+com.polarbit.waveblazerlite
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/gles_ftable.h b/tools/emulator/opengl/tests/gles_android_wrapper/gles_ftable.h
new file mode 100644
index 0000000..1895b18
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/gles_ftable.h
@@ -0,0 +1,292 @@
+/*
+* 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.
+*/
+static struct _gles_funcs_by_name {
+    const char *name;
+    void *proc;
+} gles_funcs_by_name[] = {
+    {"glAlphaFunc", (void *)glAlphaFunc},
+    {"glClearColor", (void *)glClearColor},
+    {"glClearDepthf", (void *)glClearDepthf},
+    {"glClipPlanef", (void *)glClipPlanef},
+    {"glColor4f", (void *)glColor4f},
+    {"glDepthRangef", (void *)glDepthRangef},
+    {"glFogf", (void *)glFogf},
+    {"glFogfv", (void *)glFogfv},
+    {"glFrustumf", (void *)glFrustumf},
+    {"glGetClipPlanef", (void *)glGetClipPlanef},
+    {"glGetFloatv", (void *)glGetFloatv},
+    {"glGetLightfv", (void *)glGetLightfv},
+    {"glGetMaterialfv", (void *)glGetMaterialfv},
+    {"glGetTexEnvfv", (void *)glGetTexEnvfv},
+    {"glGetTexParameterfv", (void *)glGetTexParameterfv},
+    {"glLightModelf", (void *)glLightModelf},
+    {"glLightModelfv", (void *)glLightModelfv},
+    {"glLightf", (void *)glLightf},
+    {"glLightfv", (void *)glLightfv},
+    {"glLineWidth", (void *)glLineWidth},
+    {"glLoadMatrixf", (void *)glLoadMatrixf},
+    {"glMaterialf", (void *)glMaterialf},
+    {"glMaterialfv", (void *)glMaterialfv},
+    {"glMultMatrixf", (void *)glMultMatrixf},
+    {"glMultiTexCoord4f", (void *)glMultiTexCoord4f},
+    {"glNormal3f", (void *)glNormal3f},
+    {"glOrthof", (void *)glOrthof},
+    {"glPointParameterf", (void *)glPointParameterf},
+    {"glPointParameterfv", (void *)glPointParameterfv},
+    {"glPointSize", (void *)glPointSize},
+    {"glPolygonOffset", (void *)glPolygonOffset},
+    {"glRotatef", (void *)glRotatef},
+    {"glScalef", (void *)glScalef},
+    {"glTexEnvf", (void *)glTexEnvf},
+    {"glTexEnvfv", (void *)glTexEnvfv},
+    {"glTexParameterf", (void *)glTexParameterf},
+    {"glTexParameterfv", (void *)glTexParameterfv},
+    {"glTranslatef", (void *)glTranslatef},
+    {"glActiveTexture", (void *)glActiveTexture},
+    {"glAlphaFuncx", (void *)glAlphaFuncx},
+    {"glBindBuffer", (void *)glBindBuffer},
+    {"glBindTexture", (void *)glBindTexture},
+    {"glBlendFunc", (void *)glBlendFunc},
+    {"glBufferData", (void *)glBufferData},
+    {"glBufferSubData", (void *)glBufferSubData},
+    {"glClear", (void *)glClear},
+    {"glClearColorx", (void *)glClearColorx},
+    {"glClearDepthx", (void *)glClearDepthx},
+    {"glClearStencil", (void *)glClearStencil},
+    {"glClientActiveTexture", (void *)glClientActiveTexture},
+    {"glClipPlanex", (void *)glClipPlanex},
+    {"glColor4ub", (void *)glColor4ub},
+    {"glColor4x", (void *)glColor4x},
+    {"glColorMask", (void *)glColorMask},
+    {"glColorPointer", (void *)glColorPointer},
+    {"glCompressedTexImage2D", (void *)glCompressedTexImage2D},
+    {"glCompressedTexSubImage2D", (void *)glCompressedTexSubImage2D},
+    {"glCopyTexImage2D", (void *)glCopyTexImage2D},
+    {"glCopyTexSubImage2D", (void *)glCopyTexSubImage2D},
+    {"glCullFace", (void *)glCullFace},
+    {"glDeleteBuffers", (void *)glDeleteBuffers},
+    {"glDeleteTextures", (void *)glDeleteTextures},
+    {"glDepthFunc", (void *)glDepthFunc},
+    {"glDepthMask", (void *)glDepthMask},
+    {"glDepthRangex", (void *)glDepthRangex},
+    {"glDisable", (void *)glDisable},
+    {"glDisableClientState", (void *)glDisableClientState},
+    {"glDrawArrays", (void *)glDrawArrays},
+    {"glDrawElements", (void *)glDrawElements},
+    {"glEnable", (void *)glEnable},
+    {"glEnableClientState", (void *)glEnableClientState},
+    {"glFinish", (void *)glFinish},
+    {"glFlush", (void *)glFlush},
+    {"glFogx", (void *)glFogx},
+    {"glFogxv", (void *)glFogxv},
+    {"glFrontFace", (void *)glFrontFace},
+    {"glFrustumx", (void *)glFrustumx},
+    {"glGetBooleanv", (void *)glGetBooleanv},
+    {"glGetBufferParameteriv", (void *)glGetBufferParameteriv},
+    {"glGetClipPlanex", (void *)glGetClipPlanex},
+    {"glGenBuffers", (void *)glGenBuffers},
+    {"glGenTextures", (void *)glGenTextures},
+    {"glGetError", (void *)glGetError},
+    {"glGetFixedv", (void *)glGetFixedv},
+    {"glGetIntegerv", (void *)glGetIntegerv},
+    {"glGetLightxv", (void *)glGetLightxv},
+    {"glGetMaterialxv", (void *)glGetMaterialxv},
+    {"glGetPointerv", (void *)glGetPointerv},
+    {"glGetString", (void *)glGetString},
+    {"glGetTexEnviv", (void *)glGetTexEnviv},
+    {"glGetTexEnvxv", (void *)glGetTexEnvxv},
+    {"glGetTexParameteriv", (void *)glGetTexParameteriv},
+    {"glGetTexParameterxv", (void *)glGetTexParameterxv},
+    {"glHint", (void *)glHint},
+    {"glIsBuffer", (void *)glIsBuffer},
+    {"glIsEnabled", (void *)glIsEnabled},
+    {"glIsTexture", (void *)glIsTexture},
+    {"glLightModelx", (void *)glLightModelx},
+    {"glLightModelxv", (void *)glLightModelxv},
+    {"glLightx", (void *)glLightx},
+    {"glLightxv", (void *)glLightxv},
+    {"glLineWidthx", (void *)glLineWidthx},
+    {"glLoadIdentity", (void *)glLoadIdentity},
+    {"glLoadMatrixx", (void *)glLoadMatrixx},
+    {"glLogicOp", (void *)glLogicOp},
+    {"glMaterialx", (void *)glMaterialx},
+    {"glMaterialxv", (void *)glMaterialxv},
+    {"glMatrixMode", (void *)glMatrixMode},
+    {"glMultMatrixx", (void *)glMultMatrixx},
+    {"glMultiTexCoord4x", (void *)glMultiTexCoord4x},
+    {"glNormal3x", (void *)glNormal3x},
+    {"glNormalPointer", (void *)glNormalPointer},
+    {"glOrthox", (void *)glOrthox},
+    {"glPixelStorei", (void *)glPixelStorei},
+    {"glPointParameterx", (void *)glPointParameterx},
+    {"glPointParameterxv", (void *)glPointParameterxv},
+    {"glPointSizex", (void *)glPointSizex},
+    {"glPolygonOffsetx", (void *)glPolygonOffsetx},
+    {"glPopMatrix", (void *)glPopMatrix},
+    {"glPushMatrix", (void *)glPushMatrix},
+    {"glReadPixels", (void *)glReadPixels},
+    {"glRotatex", (void *)glRotatex},
+    {"glSampleCoverage", (void *)glSampleCoverage},
+    {"glSampleCoveragex", (void *)glSampleCoveragex},
+    {"glScalex", (void *)glScalex},
+    {"glScissor", (void *)glScissor},
+    {"glShadeModel", (void *)glShadeModel},
+    {"glStencilFunc", (void *)glStencilFunc},
+    {"glStencilMask", (void *)glStencilMask},
+    {"glStencilOp", (void *)glStencilOp},
+    {"glTexCoordPointer", (void *)glTexCoordPointer},
+    {"glTexEnvi", (void *)glTexEnvi},
+    {"glTexEnvx", (void *)glTexEnvx},
+    {"glTexEnviv", (void *)glTexEnviv},
+    {"glTexEnvxv", (void *)glTexEnvxv},
+    {"glTexImage2D", (void *)glTexImage2D},
+    {"glTexParameteri", (void *)glTexParameteri},
+    {"glTexParameterx", (void *)glTexParameterx},
+    {"glTexParameteriv", (void *)glTexParameteriv},
+    {"glTexParameterxv", (void *)glTexParameterxv},
+    {"glTexSubImage2D", (void *)glTexSubImage2D},
+    {"glTranslatex", (void *)glTranslatex},
+    {"glVertexPointer", (void *)glVertexPointer},
+    {"glViewport", (void *)glViewport},
+    {"glPointSizePointerOES", (void *)glPointSizePointerOES},
+    {"glBlendEquationSeparateOES", (void *)glBlendEquationSeparateOES},
+    {"glBlendFuncSeparateOES", (void *)glBlendFuncSeparateOES},
+    {"glBlendEquationOES", (void *)glBlendEquationOES},
+    {"glDrawTexsOES", (void *)glDrawTexsOES},
+    {"glDrawTexiOES", (void *)glDrawTexiOES},
+    {"glDrawTexxOES", (void *)glDrawTexxOES},
+    {"glDrawTexsvOES", (void *)glDrawTexsvOES},
+    {"glDrawTexivOES", (void *)glDrawTexivOES},
+    {"glDrawTexxvOES", (void *)glDrawTexxvOES},
+    {"glDrawTexfOES", (void *)glDrawTexfOES},
+    {"glDrawTexfvOES", (void *)glDrawTexfvOES},
+    {"glEGLImageTargetTexture2DOES", (void *)glEGLImageTargetTexture2DOES},
+    {"glEGLImageTargetRenderbufferStorageOES", (void *)glEGLImageTargetRenderbufferStorageOES},
+    {"glAlphaFuncxOES", (void *)glAlphaFuncxOES},
+    {"glClearColorxOES", (void *)glClearColorxOES},
+    {"glClearDepthxOES", (void *)glClearDepthxOES},
+    {"glClipPlanexOES", (void *)glClipPlanexOES},
+    {"glColor4xOES", (void *)glColor4xOES},
+    {"glDepthRangexOES", (void *)glDepthRangexOES},
+    {"glFogxOES", (void *)glFogxOES},
+    {"glFogxvOES", (void *)glFogxvOES},
+    {"glFrustumxOES", (void *)glFrustumxOES},
+    {"glGetClipPlanexOES", (void *)glGetClipPlanexOES},
+    {"glGetFixedvOES", (void *)glGetFixedvOES},
+    {"glGetLightxvOES", (void *)glGetLightxvOES},
+    {"glGetMaterialxvOES", (void *)glGetMaterialxvOES},
+    {"glGetTexEnvxvOES", (void *)glGetTexEnvxvOES},
+    {"glGetTexParameterxvOES", (void *)glGetTexParameterxvOES},
+    {"glLightModelxOES", (void *)glLightModelxOES},
+    {"glLightModelxvOES", (void *)glLightModelxvOES},
+    {"glLightxOES", (void *)glLightxOES},
+    {"glLightxvOES", (void *)glLightxvOES},
+    {"glLineWidthxOES", (void *)glLineWidthxOES},
+    {"glLoadMatrixxOES", (void *)glLoadMatrixxOES},
+    {"glMaterialxOES", (void *)glMaterialxOES},
+    {"glMaterialxvOES", (void *)glMaterialxvOES},
+    {"glMultMatrixxOES", (void *)glMultMatrixxOES},
+    {"glMultiTexCoord4xOES", (void *)glMultiTexCoord4xOES},
+    {"glNormal3xOES", (void *)glNormal3xOES},
+    {"glOrthoxOES", (void *)glOrthoxOES},
+    {"glPointParameterxOES", (void *)glPointParameterxOES},
+    {"glPointParameterxvOES", (void *)glPointParameterxvOES},
+    {"glPointSizexOES", (void *)glPointSizexOES},
+    {"glPolygonOffsetxOES", (void *)glPolygonOffsetxOES},
+    {"glRotatexOES", (void *)glRotatexOES},
+    {"glSampleCoveragexOES", (void *)glSampleCoveragexOES},
+    {"glScalexOES", (void *)glScalexOES},
+    {"glTexEnvxOES", (void *)glTexEnvxOES},
+    {"glTexEnvxvOES", (void *)glTexEnvxvOES},
+    {"glTexParameterxOES", (void *)glTexParameterxOES},
+    {"glTexParameterxvOES", (void *)glTexParameterxvOES},
+    {"glTranslatexOES", (void *)glTranslatexOES},
+    {"glIsRenderbufferOES", (void *)glIsRenderbufferOES},
+    {"glBindRenderbufferOES", (void *)glBindRenderbufferOES},
+    {"glDeleteRenderbuffersOES", (void *)glDeleteRenderbuffersOES},
+    {"glGenRenderbuffersOES", (void *)glGenRenderbuffersOES},
+    {"glRenderbufferStorageOES", (void *)glRenderbufferStorageOES},
+    {"glGetRenderbufferParameterivOES", (void *)glGetRenderbufferParameterivOES},
+    {"glIsFramebufferOES", (void *)glIsFramebufferOES},
+    {"glBindFramebufferOES", (void *)glBindFramebufferOES},
+    {"glDeleteFramebuffersOES", (void *)glDeleteFramebuffersOES},
+    {"glGenFramebuffersOES", (void *)glGenFramebuffersOES},
+    {"glCheckFramebufferStatusOES", (void *)glCheckFramebufferStatusOES},
+    {"glFramebufferRenderbufferOES", (void *)glFramebufferRenderbufferOES},
+    {"glFramebufferTexture2DOES", (void *)glFramebufferTexture2DOES},
+    {"glGetFramebufferAttachmentParameterivOES", (void *)glGetFramebufferAttachmentParameterivOES},
+    {"glGenerateMipmapOES", (void *)glGenerateMipmapOES},
+    {"glMapBufferOES", (void *)glMapBufferOES},
+    {"glUnmapBufferOES", (void *)glUnmapBufferOES},
+    {"glGetBufferPointervOES", (void *)glGetBufferPointervOES},
+    {"glCurrentPaletteMatrixOES", (void *)glCurrentPaletteMatrixOES},
+    {"glLoadPaletteFromModelViewMatrixOES", (void *)glLoadPaletteFromModelViewMatrixOES},
+    {"glMatrixIndexPointerOES", (void *)glMatrixIndexPointerOES},
+    {"glWeightPointerOES", (void *)glWeightPointerOES},
+    {"glQueryMatrixxOES", (void *)glQueryMatrixxOES},
+    {"glDepthRangefOES", (void *)glDepthRangefOES},
+    {"glFrustumfOES", (void *)glFrustumfOES},
+    {"glOrthofOES", (void *)glOrthofOES},
+    {"glClipPlanefOES", (void *)glClipPlanefOES},
+    {"glGetClipPlanefOES", (void *)glGetClipPlanefOES},
+    {"glClearDepthfOES", (void *)glClearDepthfOES},
+    {"glTexGenfOES", (void *)glTexGenfOES},
+    {"glTexGenfvOES", (void *)glTexGenfvOES},
+    {"glTexGeniOES", (void *)glTexGeniOES},
+    {"glTexGenivOES", (void *)glTexGenivOES},
+    {"glTexGenxOES", (void *)glTexGenxOES},
+    {"glTexGenxvOES", (void *)glTexGenxvOES},
+    {"glGetTexGenfvOES", (void *)glGetTexGenfvOES},
+    {"glGetTexGenivOES", (void *)glGetTexGenivOES},
+    {"glGetTexGenxvOES", (void *)glGetTexGenxvOES},
+    {"glBindVertexArrayOES", (void *)glBindVertexArrayOES},
+    {"glDeleteVertexArraysOES", (void *)glDeleteVertexArraysOES},
+    {"glGenVertexArraysOES", (void *)glGenVertexArraysOES},
+    {"glIsVertexArrayOES", (void *)glIsVertexArrayOES},
+    {"glDiscardFramebufferEXT", (void *)glDiscardFramebufferEXT},
+    {"glMultiDrawArraysEXT", (void *)glMultiDrawArraysEXT},
+    {"glMultiDrawElementsEXT", (void *)glMultiDrawElementsEXT},
+    {"glClipPlanefIMG", (void *)glClipPlanefIMG},
+    {"glClipPlanexIMG", (void *)glClipPlanexIMG},
+    {"glRenderbufferStorageMultisampleIMG", (void *)glRenderbufferStorageMultisampleIMG},
+    {"glFramebufferTexture2DMultisampleIMG", (void *)glFramebufferTexture2DMultisampleIMG},
+    {"glDeleteFencesNV", (void *)glDeleteFencesNV},
+    {"glGenFencesNV", (void *)glGenFencesNV},
+    {"glIsFenceNV", (void *)glIsFenceNV},
+    {"glTestFenceNV", (void *)glTestFenceNV},
+    {"glGetFenceivNV", (void *)glGetFenceivNV},
+    {"glFinishFenceNV", (void *)glFinishFenceNV},
+    {"glSetFenceNV", (void *)glSetFenceNV},
+    {"glGetDriverControlsQCOM", (void *)glGetDriverControlsQCOM},
+    {"glGetDriverControlStringQCOM", (void *)glGetDriverControlStringQCOM},
+    {"glEnableDriverControlQCOM", (void *)glEnableDriverControlQCOM},
+    {"glDisableDriverControlQCOM", (void *)glDisableDriverControlQCOM},
+    {"glExtGetTexturesQCOM", (void *)glExtGetTexturesQCOM},
+    {"glExtGetBuffersQCOM", (void *)glExtGetBuffersQCOM},
+    {"glExtGetRenderbuffersQCOM", (void *)glExtGetRenderbuffersQCOM},
+    {"glExtGetFramebuffersQCOM", (void *)glExtGetFramebuffersQCOM},
+    {"glExtGetTexLevelParameterivQCOM", (void *)glExtGetTexLevelParameterivQCOM},
+    {"glExtTexObjectStateOverrideiQCOM", (void *)glExtTexObjectStateOverrideiQCOM},
+    {"glExtGetTexSubImageQCOM", (void *)glExtGetTexSubImageQCOM},
+    {"glExtGetBufferPointervQCOM", (void *)glExtGetBufferPointervQCOM},
+    {"glExtGetShadersQCOM", (void *)glExtGetShadersQCOM},
+    {"glExtGetProgramsQCOM", (void *)glExtGetProgramsQCOM},
+    {"glExtIsProgramBinaryQCOM", (void *)glExtIsProgramBinaryQCOM},
+    {"glExtGetProgramBinarySourceQCOM", (void *)glExtGetProgramBinarySourceQCOM},
+    {"glStartTilingQCOM", (void *)glStartTilingQCOM},
+    {"glEndTilingQCOM", (void *)glEndTilingQCOM}
+};
+static int gles_num_funcs = sizeof(gles_funcs_by_name) / sizeof(struct _gles_funcs_by_name);
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/gles_proc.h b/tools/emulator/opengl/tests/gles_android_wrapper/gles_proc.h
new file mode 100644
index 0000000..612b658
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/gles_proc.h
@@ -0,0 +1,296 @@
+/*
+* 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 _GLES_PROC_H
+#define _GLES_PROC_H
+
+#include <GLES/gl.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GLES/glext.h>
+
+typedef void (* glAlphaFunc_t) (GLenum, GLclampf);
+typedef void (* glClearColor_t) (GLclampf, GLclampf, GLclampf, GLclampf);
+typedef void (* glClearDepthf_t) (GLclampf);
+typedef void (* glClipPlanef_t) (GLenum, const GLfloat*);
+typedef void (* glColor4f_t) (GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (* glDepthRangef_t) (GLclampf, GLclampf);
+typedef void (* glFogf_t) (GLenum, GLfloat);
+typedef void (* glFogfv_t) (GLenum, const GLfloat*);
+typedef void (* glFrustumf_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (* glGetClipPlanef_t) (GLenum, GLfloat);
+typedef void (* glGetFloatv_t) (GLenum, GLfloat*);
+typedef void (* glGetLightfv_t) (GLenum, GLenum, GLfloat*);
+typedef void (* glGetMaterialfv_t) (GLenum, GLenum, GLfloat*);
+typedef void (* glGetTexEnvfv_t) (GLenum, GLenum, GLfloat*);
+typedef void (* glGetTexParameterfv_t) (GLenum, GLenum, GLfloat*);
+typedef void (* glLightModelf_t) (GLenum, GLfloat);
+typedef void (* glLightModelfv_t) (GLenum, const GLfloat*);
+typedef void (* glLightf_t) (GLenum, GLenum, GLfloat);
+typedef void (* glLightfv_t) (GLenum, GLenum, const GLfloat*);
+typedef void (* glLineWidth_t) (GLfloat);
+typedef void (* glLoadMatrixf_t) (const GLfloat*);
+typedef void (* glMaterialf_t) (GLenum, GLenum, GLfloat);
+typedef void (* glMaterialfv_t) (GLenum, GLenum, const GLfloat*);
+typedef void (* glMultMatrixf_t) (const GLfloat*);
+typedef void (* glMultiTexCoord4f_t) (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (* glNormal3f_t) (GLfloat, GLfloat, GLfloat);
+typedef void (* glOrthof_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (* glPointParameterf_t) (GLenum, GLfloat);
+typedef void (* glPointParameterfv_t) (GLenum, const GLfloat*);
+typedef void (* glPointSize_t) (GLfloat);
+typedef void (* glPolygonOffset_t) (GLfloat, GLfloat);
+typedef void (* glRotatef_t) (GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (* glScalef_t) (GLfloat, GLfloat, GLfloat);
+typedef void (* glTexEnvf_t) (GLenum, GLenum, GLfloat);
+typedef void (* glTexEnvfv_t) (GLenum, GLenum, const GLfloat*);
+typedef void (* glTexParameterf_t) (GLenum, GLenum, GLfloat);
+typedef void (* glTexParameterfv_t) (GLenum, GLenum, const GLfloat*);
+typedef void (* glTranslatef_t) (GLfloat, GLfloat, GLfloat);
+typedef void (* glActiveTexture_t) (GLenum);
+typedef void (* glAlphaFuncx_t) (GLenum, GLclampx);
+typedef void (* glBindBuffer_t) (GLenum, GLuint);
+typedef void (* glBindTexture_t) (GLenum, GLuint);
+typedef void (* glBlendFunc_t) (GLenum, GLenum);
+typedef void (* glBufferData_t) (GLenum, GLsizeiptr, const GLvoid*, GLenum);
+typedef void (* glBufferSubData_t) (GLenum, GLintptr, GLsizeiptr, const GLvoid*);
+typedef void (* glClear_t) (GLbitfield);
+typedef void (* glClearColorx_t) (GLclampx, GLclampx, GLclampx, GLclampx);
+typedef void (* glClearDepthx_t) (GLclampx);
+typedef void (* glClearStencil_t) (GLint);
+typedef void (* glClientActiveTexture_t) (GLenum);
+typedef void (* glClipPlanex_t) (GLenum, const GLfixed*);
+typedef void (* glColor4ub_t) (GLubyte, GLubyte, GLubyte, GLubyte);
+typedef void (* glColor4x_t) (GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glColorMask_t) (GLboolean, GLboolean, GLboolean, GLboolean);
+typedef void (* glColorPointer_t) (GLint, GLenum, GLsizei, const GLvoid*);
+typedef void (* glCompressedTexImage2D_t) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*);
+typedef void (* glCompressedTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*);
+typedef void (* glCopyTexImage2D_t) (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+typedef void (* glCopyTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+typedef void (* glCullFace_t) (GLenum);
+typedef void (* glDeleteBuffers_t) (GLsizei, const GLuint*);
+typedef void (* glDeleteTextures_t) (GLsizei, const GLuint*);
+typedef void (* glDepthFunc_t) (GLenum);
+typedef void (* glDepthMask_t) (GLboolean);
+typedef void (* glDepthRangex_t) (GLclampx, GLclampx);
+typedef void (* glDisable_t) (GLenum);
+typedef void (* glDisableClientState_t) (GLenum);
+typedef void (* glDrawArrays_t) (GLenum, GLint, GLsizei);
+typedef void (* glDrawElements_t) (GLenum, GLsizei, GLenum, const GLvoid*);
+typedef void (* glEnable_t) (GLenum);
+typedef void (* glEnableClientState_t) (GLenum);
+typedef void (* glFinish_t) ();
+typedef void (* glFlush_t) ();
+typedef void (* glFogx_t) (GLenum, GLfixed);
+typedef void (* glFogxv_t) (GLenum, const GLfixed*);
+typedef void (* glFrontFace_t) (GLenum);
+typedef void (* glFrustumx_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glGetBooleanv_t) (GLenum, GLboolean*);
+typedef void (* glGetBufferParameteriv_t) (GLenum, GLenum, GLint*);
+typedef void (* glGetClipPlanex_t) (GLenum, GLfixed);
+typedef void (* glGenBuffers_t) (GLsizei, GLuint*);
+typedef void (* glGenTextures_t) (GLsizei, GLuint*);
+typedef GLenum (* glGetError_t) ();
+typedef void (* glGetFixedv_t) (GLenum, GLfixed*);
+typedef void (* glGetIntegerv_t) (GLenum, GLint*);
+typedef void (* glGetLightxv_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glGetMaterialxv_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glGetPointerv_t) (GLenum, GLvoid*);
+typedef const GLubyte* (* glGetString_t) (GLenum);
+typedef void (* glGetTexEnviv_t) (GLenum, GLenum, GLint*);
+typedef void (* glGetTexEnvxv_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glGetTexParameteriv_t) (GLenum, GLenum, GLint*);
+typedef void (* glGetTexParameterxv_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glHint_t) (GLenum, GLenum);
+typedef GLboolean (* glIsBuffer_t) (GLuint);
+typedef GLboolean (* glIsEnabled_t) (GLenum);
+typedef GLboolean (* glIsTexture_t) (GLuint);
+typedef void (* glLightModelx_t) (GLenum, GLfixed);
+typedef void (* glLightModelxv_t) (GLenum, const GLfixed*);
+typedef void (* glLightx_t) (GLenum, GLenum, GLfixed);
+typedef void (* glLightxv_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glLineWidthx_t) (GLfixed);
+typedef void (* glLoadIdentity_t) ();
+typedef void (* glLoadMatrixx_t) (const GLfixed*);
+typedef void (* glLogicOp_t) (GLenum);
+typedef void (* glMaterialx_t) (GLenum, GLenum, GLfixed);
+typedef void (* glMaterialxv_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glMatrixMode_t) (GLenum);
+typedef void (* glMultMatrixx_t) (const GLfixed*);
+typedef void (* glMultiTexCoord4x_t) (GLenum, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glNormal3x_t) (GLfixed, GLfixed, GLfixed);
+typedef void (* glNormalPointer_t) (GLenum, GLsizei, const GLvoid*);
+typedef void (* glOrthox_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glPixelStorei_t) (GLenum, GLint);
+typedef void (* glPointParameterx_t) (GLenum, GLfixed);
+typedef void (* glPointParameterxv_t) (GLenum, const GLfixed*);
+typedef void (* glPointSizex_t) (GLfixed);
+typedef void (* glPolygonOffsetx_t) (GLfixed, GLfixed);
+typedef void (* glPopMatrix_t) ();
+typedef void (* glPushMatrix_t) ();
+typedef void (* glReadPixels_t) (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*);
+typedef void (* glRotatex_t) (GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glSampleCoverage_t) (GLclampf, GLboolean);
+typedef void (* glSampleCoveragex_t) (GLclampx, GLboolean);
+typedef void (* glScalex_t) (GLfixed, GLfixed, GLfixed);
+typedef void (* glScissor_t) (GLint, GLint, GLsizei, GLsizei);
+typedef void (* glShadeModel_t) (GLenum);
+typedef void (* glStencilFunc_t) (GLenum, GLint, GLuint);
+typedef void (* glStencilMask_t) (GLuint);
+typedef void (* glStencilOp_t) (GLenum, GLenum, GLenum);
+typedef void (* glTexCoordPointer_t) (GLint, GLenum, GLsizei, const GLvoid*);
+typedef void (* glTexEnvi_t) (GLenum, GLenum, GLint);
+typedef void (* glTexEnvx_t) (GLenum, GLenum, GLfixed);
+typedef void (* glTexEnviv_t) (GLenum, GLenum, const GLint*);
+typedef void (* glTexEnvxv_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glTexImage2D_t) (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*);
+typedef void (* glTexParameteri_t) (GLenum, GLenum, GLint);
+typedef void (* glTexParameterx_t) (GLenum, GLenum, GLfixed);
+typedef void (* glTexParameteriv_t) (GLenum, GLenum, const GLint*);
+typedef void (* glTexParameterxv_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*);
+typedef void (* glTranslatex_t) (GLfixed, GLfixed, GLfixed);
+typedef void (* glVertexPointer_t) (GLint, GLenum, GLsizei, const GLvoid*);
+typedef void (* glViewport_t) (GLint, GLint, GLsizei, GLsizei);
+typedef void (* glPointSizePointerOES_t) (GLenum, GLsizei, const GLvoid*);
+typedef void (* glBlendEquationSeparateOES_t) (GLenum, GLenum);
+typedef void (* glBlendFuncSeparateOES_t) (GLenum, GLenum, GLenum, GLenum);
+typedef void (* glBlendEquationOES_t) (GLenum);
+typedef void (* glDrawTexsOES_t) (GLshort, GLshort, GLshort, GLshort, GLshort);
+typedef void (* glDrawTexiOES_t) (GLint, GLint, GLint, GLint, GLint);
+typedef void (* glDrawTexxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glDrawTexsvOES_t) (const GLshort*);
+typedef void (* glDrawTexivOES_t) (const GLint*);
+typedef void (* glDrawTexxvOES_t) (const GLfixed*);
+typedef void (* glDrawTexfOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (* glDrawTexfvOES_t) (const GLfloat*);
+typedef void (* glEGLImageTargetTexture2DOES_t) (GLenum, GLeglImageOES);
+typedef void (* glEGLImageTargetRenderbufferStorageOES_t) (GLenum, GLeglImageOES);
+typedef void (* glAlphaFuncxOES_t) (GLenum, GLclampx);
+typedef void (* glClearColorxOES_t) (GLclampx, GLclampx, GLclampx, GLclampx);
+typedef void (* glClearDepthxOES_t) (GLclampx);
+typedef void (* glClipPlanexOES_t) (GLenum, const GLfixed*);
+typedef void (* glColor4xOES_t) (GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glDepthRangexOES_t) (GLclampx, GLclampx);
+typedef void (* glFogxOES_t) (GLenum, GLfixed);
+typedef void (* glFogxvOES_t) (GLenum, const GLfixed*);
+typedef void (* glFrustumxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glGetClipPlanexOES_t) (GLenum, GLfixed);
+typedef void (* glGetFixedvOES_t) (GLenum, GLfixed*);
+typedef void (* glGetLightxvOES_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glGetMaterialxvOES_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glGetTexEnvxvOES_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glGetTexParameterxvOES_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glLightModelxOES_t) (GLenum, GLfixed);
+typedef void (* glLightModelxvOES_t) (GLenum, const GLfixed*);
+typedef void (* glLightxOES_t) (GLenum, GLenum, GLfixed);
+typedef void (* glLightxvOES_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glLineWidthxOES_t) (GLfixed);
+typedef void (* glLoadMatrixxOES_t) (const GLfixed*);
+typedef void (* glMaterialxOES_t) (GLenum, GLenum, GLfixed);
+typedef void (* glMaterialxvOES_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glMultMatrixxOES_t) (const GLfixed*);
+typedef void (* glMultiTexCoord4xOES_t) (GLenum, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glNormal3xOES_t) (GLfixed, GLfixed, GLfixed);
+typedef void (* glOrthoxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glPointParameterxOES_t) (GLenum, GLfixed);
+typedef void (* glPointParameterxvOES_t) (GLenum, const GLfixed*);
+typedef void (* glPointSizexOES_t) (GLfixed);
+typedef void (* glPolygonOffsetxOES_t) (GLfixed, GLfixed);
+typedef void (* glRotatexOES_t) (GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (* glSampleCoveragexOES_t) (GLclampx, GLboolean);
+typedef void (* glScalexOES_t) (GLfixed, GLfixed, GLfixed);
+typedef void (* glTexEnvxOES_t) (GLenum, GLenum, GLfixed);
+typedef void (* glTexEnvxvOES_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glTexParameterxOES_t) (GLenum, GLenum, GLfixed);
+typedef void (* glTexParameterxvOES_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glTranslatexOES_t) (GLfixed, GLfixed, GLfixed);
+typedef GLboolean (* glIsRenderbufferOES_t) (GLuint);
+typedef void (* glBindRenderbufferOES_t) (GLenum, GLuint);
+typedef void (* glDeleteRenderbuffersOES_t) (GLsizei, const GLuint*);
+typedef void (* glGenRenderbuffersOES_t) (GLsizei, GLuint*);
+typedef void (* glRenderbufferStorageOES_t) (GLenum, GLenum, GLsizei, GLsizei);
+typedef void (* glGetRenderbufferParameterivOES_t) (GLenum, GLenum, GLint*);
+typedef GLboolean (* glIsFramebufferOES_t) (GLuint);
+typedef void (* glBindFramebufferOES_t) (GLenum, GLuint);
+typedef void (* glDeleteFramebuffersOES_t) (GLsizei, const GLuint*);
+typedef void (* glGenFramebuffersOES_t) (GLsizei, GLuint*);
+typedef GLenum (* glCheckFramebufferStatusOES_t) (GLenum);
+typedef void (* glFramebufferRenderbufferOES_t) (GLenum, GLenum, GLenum, GLuint);
+typedef void (* glFramebufferTexture2DOES_t) (GLenum, GLenum, GLenum, GLuint, GLint);
+typedef void (* glGetFramebufferAttachmentParameterivOES_t) (GLenum, GLenum, GLenum, GLint*);
+typedef void (* glGenerateMipmapOES_t) (GLenum);
+typedef void* (* glMapBufferOES_t) (GLenum, GLenum);
+typedef GLboolean (* glUnmapBufferOES_t) (GLenum);
+typedef void (* glGetBufferPointervOES_t) (GLenum, GLenum, GLvoid*);
+typedef void (* glCurrentPaletteMatrixOES_t) (GLuint);
+typedef void (* glLoadPaletteFromModelViewMatrixOES_t) ();
+typedef void (* glMatrixIndexPointerOES_t) (GLint, GLenum, GLsizei, const GLvoid*);
+typedef void (* glWeightPointerOES_t) (GLint, GLenum, GLsizei, const GLvoid*);
+typedef GLbitfield (* glQueryMatrixxOES_t) (GLfixed, GLint);
+typedef void (* glDepthRangefOES_t) (GLclampf, GLclampf);
+typedef void (* glFrustumfOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (* glOrthofOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (* glClipPlanefOES_t) (GLenum, const GLfloat*);
+typedef void (* glGetClipPlanefOES_t) (GLenum, GLfloat);
+typedef void (* glClearDepthfOES_t) (GLclampf);
+typedef void (* glTexGenfOES_t) (GLenum, GLenum, GLfloat);
+typedef void (* glTexGenfvOES_t) (GLenum, GLenum, const GLfloat*);
+typedef void (* glTexGeniOES_t) (GLenum, GLenum, GLint);
+typedef void (* glTexGenivOES_t) (GLenum, GLenum, const GLint*);
+typedef void (* glTexGenxOES_t) (GLenum, GLenum, GLfixed);
+typedef void (* glTexGenxvOES_t) (GLenum, GLenum, const GLfixed*);
+typedef void (* glGetTexGenfvOES_t) (GLenum, GLenum, GLfloat*);
+typedef void (* glGetTexGenivOES_t) (GLenum, GLenum, GLint*);
+typedef void (* glGetTexGenxvOES_t) (GLenum, GLenum, GLfixed*);
+typedef void (* glBindVertexArrayOES_t) (GLuint);
+typedef void (* glDeleteVertexArraysOES_t) (GLsizei, const GLuint*);
+typedef void (* glGenVertexArraysOES_t) (GLsizei, GLuint*);
+typedef GLboolean (* glIsVertexArrayOES_t) (GLuint);
+typedef void (* glDiscardFramebufferEXT_t) (GLenum, GLsizei, const GLenum*);
+typedef void (* glMultiDrawArraysEXT_t) (GLenum, GLint*, GLsizei*, GLsizei);
+typedef void (* glMultiDrawElementsEXT_t) (GLenum, const GLsizei*, GLenum, const GLvoid**, GLsizei);
+typedef void (* glClipPlanefIMG_t) (GLenum, const GLfloat*);
+typedef void (* glClipPlanexIMG_t) (GLenum, const GLfixed*);
+typedef void (* glRenderbufferStorageMultisampleIMG_t) (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+typedef void (* glFramebufferTexture2DMultisampleIMG_t) (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+typedef void (* glDeleteFencesNV_t) (GLsizei, const GLuint*);
+typedef void (* glGenFencesNV_t) (GLsizei, GLuint*);
+typedef GLboolean (* glIsFenceNV_t) (GLuint);
+typedef GLboolean (* glTestFenceNV_t) (GLuint);
+typedef void (* glGetFenceivNV_t) (GLuint, GLenum, GLint*);
+typedef void (* glFinishFenceNV_t) (GLuint);
+typedef void (* glSetFenceNV_t) (GLuint, GLenum);
+typedef void (* glGetDriverControlsQCOM_t) (GLint*, GLsizei, GLuint*);
+typedef void (* glGetDriverControlStringQCOM_t) (GLuint, GLsizei, GLsizei*, GLchar*);
+typedef void (* glEnableDriverControlQCOM_t) (GLuint);
+typedef void (* glDisableDriverControlQCOM_t) (GLuint);
+typedef void (* glExtGetTexturesQCOM_t) (GLuint*, GLint, GLint*);
+typedef void (* glExtGetBuffersQCOM_t) (GLuint*, GLint, GLint*);
+typedef void (* glExtGetRenderbuffersQCOM_t) (GLuint*, GLint, GLint*);
+typedef void (* glExtGetFramebuffersQCOM_t) (GLuint*, GLint, GLint*);
+typedef void (* glExtGetTexLevelParameterivQCOM_t) (GLuint, GLenum, GLint, GLenum, GLint*);
+typedef void (* glExtTexObjectStateOverrideiQCOM_t) (GLenum, GLenum, GLint);
+typedef void (* glExtGetTexSubImageQCOM_t) (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoid*);
+typedef void (* glExtGetBufferPointervQCOM_t) (GLenum, GLvoid*);
+typedef void (* glExtGetShadersQCOM_t) (GLuint*, GLint, GLint*);
+typedef void (* glExtGetProgramsQCOM_t) (GLuint*, GLint, GLint*);
+typedef GLboolean (* glExtIsProgramBinaryQCOM_t) (GLuint);
+typedef void (* glExtGetProgramBinarySourceQCOM_t) (GLuint, GLenum, GLchar*, GLint*);
+typedef void (* glStartTilingQCOM_t) (GLuint, GLuint, GLuint, GLuint, GLbitfield);
+typedef void (* glEndTilingQCOM_t) (GLbitfield);
+
+
+#endif
diff --git a/tools/emulator/opengl/tests/ut_rendercontrol_dec/Android.mk b/tools/emulator/opengl/tests/ut_rendercontrol_dec/Android.mk
new file mode 100644
index 0000000..2ae22d3
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_rendercontrol_dec/Android.mk
@@ -0,0 +1,34 @@
+
+LOCAL_PATH := $(call my-dir)
+
+### ut_rendercontrol Decoder ###########################################
+include $(CLEAR_VARS)
+
+emulatorOpengl := $(LOCAL_PATH)/../..
+EMUGEN := $(HOST_OUT_EXECUTABLES)/emugen
+
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libut_rendercontrol_dec
+LOCAL_SRC_FILES := 
+#LOCAL_CFLAGS += -DDEBUG_PRINTOUT -O0 -g
+intermediates := $(local-intermediates-dir)
+
+LOCAL_STATIC_LIBRARIES := \
+	libOpenglCodecCommon \
+    liblog
+LOCAL_C_INCLUDES += $(emulatorOpengl)/system/OpenglCodecCommon $(emulatorOpengl)/tests/ut_rendercontrol_enc
+
+#we use only *_dec.h as a sentinel for the other generated headers
+GEN := $(intermediates)/ut_rendercontrol_dec.cpp $(intermediates)/ut_rendercontrol_dec.h
+$(GEN): PRIVATE_PATH := $(LOCAL_PATH)
+$(GEN): PRIVATE_CUSTOM_TOOL := $(EMUGEN) -D $(intermediates) -i $(emulatorOpengl)/tests/ut_rendercontrol_enc ut_rendercontrol
+$(GEN): $(EMUGEN) \
+	$(emulatorOpengl)/tests/ut_rendercontrol_enc/ut_rendercontrol.attrib \
+	$(emulatorOpengl)/tests/ut_rendercontrol_enc/ut_rendercontrol.in \
+	$(emulatorOpengl)/tests/ut_rendercontrol_enc/ut_rendercontrol.types
+	$(transform-generated-source)
+
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/tools/emulator/opengl/tests/ut_rendercontrol_enc/Android.mk b/tools/emulator/opengl/tests/ut_rendercontrol_enc/Android.mk
new file mode 100644
index 0000000..1b5d432
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_rendercontrol_enc/Android.mk
@@ -0,0 +1,36 @@
+LOCAL_PATH := $(call my-dir)
+
+emulatorOpengl := $(LOCAL_PATH)/../..
+#### ut_rendercontrol  ####
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES :=  
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libut_rendercontrol_enc
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+ut_intermediates := $(local-intermediates-dir)
+
+LOCAL_C_INCLUDES += $(emulatorOpengl)/system/OpenglCodecCommon 
+
+LOCAL_STATIC_LIBRARIES := \
+        libOpenglCodecCommon
+LOCAL_SHARED_LIBRARIES := libcutils
+
+UT_GEN := \
+	$(ut_intermediates)/ut_rendercontrol_enc.cpp \
+	$(ut_intermediates)/ut_rendercontrol_enc.h
+
+$(UT_GEN) : PRIVATE_PATH = $(LOCAL_PATH)
+$(UT_GEN) : PRIVATE_CUSTOM_TOOL := \
+        $(EMUGEN) -i $(PRIVATE_PATH) -E $(ut_intermediates) ut_rendercontrol
+$(UT_GEN) : $(EMUGEN) \
+        $(LOCAL_PATH)/ut_rendercontrol.in \
+        $(LOCAL_PATH)/ut_rendercontrol.attrib \
+        $(LOCAL_PATH)/ut_rendercontrol.types
+	$(transform-generated-source)
+
+LOCAL_GENERATED_SOURCES += $(UT_GEN)
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.attrib b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.attrib
new file mode 100644
index 0000000..c47a9f9
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.attrib
@@ -0,0 +1,4 @@
+GLOBAL
+	base_opcode 10000
+	encoder_headers <stdint.h>
+
diff --git a/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.in b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.in
new file mode 100644
index 0000000..856fed6
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.in
@@ -0,0 +1,11 @@
+GL_ENTRY(int, createContext, uint32_t pid, uint32_t handle, uint32_t shareCtx)
+GL_ENTRY(int, createSurface, uint32_t pid, uint32_t handle)
+GL_ENTRY(int, makeCurrentContext, uint32_t pid, uint32_t drawSurface, uint32_t readSurface, uint32_t ctxHandle)
+GL_ENTRY(void, swapBuffers, uint32_t pid, uint32_t surface)
+GL_ENTRY(int, destroyContext, uint32_t pid, uint32_t handle)
+GL_ENTRY(int, destroySurface, uint32_t pid, uint32_t handle)
+
+
+
+
+
diff --git a/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.types b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.types
new file mode 100644
index 0000000..eb4dd1b
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.types
@@ -0,0 +1,2 @@
+uint32_t 32 0x%08x
+
diff --git a/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol_types.h b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol_types.h
new file mode 100644
index 0000000..9b7864d
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol_types.h
@@ -0,0 +1,17 @@
+/*
+* 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 <stdint.h>
diff --git a/tools/emulator/opengl/tests/ut_renderer/Android.mk b/tools/emulator/opengl/tests/ut_renderer/Android.mk
new file mode 100644
index 0000000..d48dec4
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/Android.mk
@@ -0,0 +1,60 @@
+# Building this module breaks the Linux build because
+# libxcb.so is not installed in the i686-linux-glibc2.7-4.4.3
+# prebuilt sysroot. Since rebuilding it will take some time, here's a
+# quick fix to unbreak it.
+#
+ifneq (,$(BUILD_EMULATOR_OPENGL))
+
+LOCAL_PATH:=$(call my-dir)
+
+# ut_renderer test program ###########################
+
+include $(CLEAR_VARS)
+
+ifeq ($(HOST_OS), linux)
+
+emulatorOpengl := $(LOCAL_PATH)/../..
+
+LOCAL_MODULE := ut_renderer
+LOCAL_MODULE_TAGS := debug
+
+# add additional depencies to ensure that the generated code that we depend on
+# is generated
+LOCAL_ADDITIONAL_DEPENDENCIES := \
+	$(HOST_OUT_SHARED_LIBRARIES)/libut_rendercontrol_dec$(HOST_SHLIB_SUFFIX) \
+	$(HOST_OUT_SHARED_LIBRARIES)/libGLESv1_dec$(HOST_SHLIB_SUFFIX)
+
+LOCAL_SRC_FILES := ut_renderer.cpp \
+        RenderingThread.cpp \
+	ReadBuffer.cpp \
+	Renderer.cpp \
+	RendererContext.cpp \
+	RendererSurface.cpp \
+	X11Windowing.cpp \
+    TimeUtils.cpp
+
+# define PVR_WAR to support imgtec PVR opengl-ES implementation
+#
+# specifically this MACRO enables code that work arounds a bug 
+# in the implementation where glTextureParameter(...,GL_TEXTURE_RECT,...)
+# is called would cause a crash if the texture dimensions have not been 
+# defined yet.
+
+LOCAL_CFLAGS := -DPVR_WAR 
+#LOCAL_CFLAGS += -g -O0
+
+LOCAL_C_INCLUDES := $(emulatorOpengl)/system/OpenglCodecCommon \
+		$(call intermediates-dir-for, SHARED_LIBRARIES, libut_rendercontrol_dec, HOST) \
+		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv1_dec, HOST) \
+        $(emulatorOpengl)/host/libs/GLESv1_dec \
+        $(emulatorOpengl)/system/GLESv1_enc \
+        $(emulatorOpengl)/tests/ut_rendercontrol_enc
+
+LOCAL_SHARED_LIBRARIES := libut_rendercontrol_dec libGLESv1_dec libEGL_host_wrapper
+LOCAL_STATIC_LIBRARIES := libOpenglCodecCommon
+LOCAL_LDLIBS := -lpthread -lX11 -lrt
+include $(BUILD_HOST_EXECUTABLE)
+
+endif # HOST_OS == linux
+
+endif # BUILD_EMULATOR_OPENGL
diff --git a/tools/emulator/opengl/tests/ut_renderer/NativeWindowing.h b/tools/emulator/opengl/tests/ut_renderer/NativeWindowing.h
new file mode 100644
index 0000000..9468066
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/NativeWindowing.h
@@ -0,0 +1,28 @@
+/*
+* 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 _NATIVE_WINDOWING_H
+#define _NATIVE_WINDOWING_H
+
+#include <EGL/egl.h>
+
+class NativeWindowing {
+public:
+    virtual NativeDisplayType getNativeDisplay() = 0;
+    virtual NativeWindowType createNativeWindow(NativeDisplayType dpy, int width, int height) = 0;
+    virtual int destroyNativeWindow(NativeDisplayType dpy, NativeWindowType win) = 0;
+};
+
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/ReadBuffer.cpp b/tools/emulator/opengl/tests/ut_renderer/ReadBuffer.cpp
new file mode 100644
index 0000000..661b4cc
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/ReadBuffer.cpp
@@ -0,0 +1,53 @@
+/*
+* 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 "ReadBuffer.h"
+#include <string.h>
+#include <assert.h>
+
+ReadBuffer::ReadBuffer(TcpStream *stream, size_t bufsize)
+{
+    m_size = bufsize;
+    m_stream = stream;
+    m_buf = new unsigned char[m_size];
+    m_validData = 0;
+    m_readPtr = m_buf;
+}
+
+ReadBuffer::~ReadBuffer()
+{
+    delete m_buf;
+}
+
+int ReadBuffer::getData()
+{
+    if (m_validData > 0) {
+        memcpy(m_buf, m_readPtr, m_validData);
+    }
+    m_readPtr = m_buf;
+    // get fresh data into the buffer;
+    int stat = m_stream->recv(m_buf + m_validData, m_size - m_validData);
+    if (stat > 0) {
+        m_validData += (size_t) stat;
+    }
+    return stat;
+}
+
+void ReadBuffer::consume(size_t amount)
+{
+    assert(amount <= m_validData);
+    m_validData -= amount;
+    m_readPtr += amount;
+}
diff --git a/tools/emulator/opengl/tests/ut_renderer/ReadBuffer.h b/tools/emulator/opengl/tests/ut_renderer/ReadBuffer.h
new file mode 100644
index 0000000..1b8f6fd
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/ReadBuffer.h
@@ -0,0 +1,36 @@
+/*
+* 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 _READ_BUFFER_H
+#define _READ_BUFFER_H
+
+#include "TcpStream.h"
+
+class ReadBuffer {
+public:
+    ReadBuffer(TcpStream *stream, size_t bufSize);
+    ~ReadBuffer();
+    int getData(); // get fresh data from the stream
+    unsigned char *buf() { return m_readPtr; } // return the next read location
+    size_t validData() { return m_validData; } // return the amount of valid data in readptr
+    void consume(size_t amount); // notify that 'amount' data has been consumed;
+private:
+    unsigned char *m_buf;
+    unsigned char *m_readPtr;
+    size_t m_size;
+    size_t m_validData;
+    TcpStream *m_stream;
+};
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/Renderer.cpp b/tools/emulator/opengl/tests/ut_renderer/Renderer.cpp
new file mode 100644
index 0000000..3228df6
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/Renderer.cpp
@@ -0,0 +1,181 @@
+/*
+* 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 <assert.h>
+#include "RenderingThread.h"
+#include "Renderer.h"
+
+// include operating-system dependent windowing system impelemntation
+#ifdef _WIN32
+#    error "WINDOWS IS NOT SUPPORTED AT THE MOMENT"
+#elif defined __APPLE__
+#    error "Apple OS-X IS NOT SUPPORTED"
+#elif defined (__unix__)
+# include "X11Windowing.h"
+#endif
+
+
+
+
+
+Renderer * Renderer::m_instance = NULL;
+
+Renderer * Renderer::instance()
+{
+    if (m_instance == NULL) m_instance = new Renderer;
+    return m_instance;
+}
+
+Renderer::Renderer()
+{
+    // Unix specific, use your platform specific windowing implementation
+#ifdef __unix__
+    m_nw = new X11Windowing;
+#endif
+
+    m_dpy = eglGetDisplay(m_nw->getNativeDisplay());
+    EGLint major, minor;
+    eglInitialize(m_dpy, &major, &minor);
+    fprintf(stderr, "egl initialized : %d.%d\n", major, minor);
+}
+
+int Renderer::createSurface(RenderingThread *thread, const ClientHandle & handle)
+{
+    android::Mutex::Autolock(this->m_mutex);
+
+    assert(m_surfaces.find(handle) == m_surfaces.end());
+    if (handle.handle == 0) {
+        fprintf(stderr, "trying to create surface for EGL_NO_SURFACE !!!\n");
+        return -1;
+    } else {
+        RendererSurface  *surface = RendererSurface::create(m_dpy, RendererSurface::CONFIG_DEPTH, m_nw);
+        if (surface == NULL) {
+            printf("failed to create surface !!\n");
+            return -1;
+        }
+        m_surfaces.insert(SurfaceMap::value_type(handle, surface));
+    }
+    return 0;
+}
+
+int Renderer::destroySurface(RenderingThread *thread, const ClientHandle &handle)
+{
+    android::Mutex::Autolock(this->m_mutex);
+
+    SurfaceMap::iterator i = m_surfaces.find(handle);
+    if (i == m_surfaces.end()) {
+        printf("removing surface that doesn't exists\n");
+        return -1;
+    }
+    if (i->second->destroy(m_nw)) {
+        m_surfaces.erase(handle);
+    }
+    return 0;
+}
+
+int Renderer::createContext(RenderingThread *thread, const ClientHandle &handle, ClientHandle shareCtx)
+{
+    android::Mutex::Autolock(this->m_mutex);
+
+    assert(m_ctxs.find(handle) == m_ctxs.end());
+    RendererContext *shared = NULL;
+    if (shareCtx.handle != 0) {
+        ContextMap::iterator sctx = m_ctxs.find(shareCtx);
+        if (sctx != m_ctxs.end()) {
+            shared = sctx->second;
+        }
+    }
+
+    RendererContext *ctx =
+        RendererContext::create(m_dpy,
+                                RendererSurface::getEglConfig(m_dpy, RendererSurface::CONFIG_DEPTH),
+                                shared);
+    if (ctx == NULL) {
+        fprintf(stderr, "failed to create context\n");
+        return -1;
+    }
+    m_ctxs.insert(ContextMap::value_type(handle, ctx));
+    return 0;
+}
+
+int Renderer::destroyContext(RenderingThread *thread, const ClientHandle &handle)
+{
+    android::Mutex::Autolock(this->m_mutex);
+
+    ContextMap::iterator i = m_ctxs.find(handle);
+    if (i == m_ctxs.end()) {
+        printf("removing context that doesn't exists\n");
+        return -1;
+    }
+    if (i->second->destroy()) {
+        m_ctxs.erase(handle);
+    }
+    return 0;
+}
+
+int Renderer::makeCurrent(RenderingThread *thread,
+                          const ClientHandle &drawSurface,
+                          const ClientHandle &readSurface,
+                          const ClientHandle & ctx)
+{
+    android::Mutex::Autolock(this->m_mutex);
+
+    RendererContext *currentContext = thread->currentContext();
+
+    ContextMap::iterator c = m_ctxs.find(ctx);
+    EGLContext eglContext;
+    if (ctx.handle != 0 && c != m_ctxs.end()) {
+        if (c->second != currentContext) {
+            // new context is set
+            if (currentContext != NULL) currentContext->unref();
+            c->second->ref();
+            eglContext = c->second->eglContext();
+            thread->setCurrentContext(c->second);
+            thread->glDecoder().setContextData(&c->second->decoderContextData());
+        } else {
+            // same context is already set
+            eglContext = c->second->eglContext();
+        }
+    } else {
+        eglContext = EGL_NO_CONTEXT;
+        if (currentContext != NULL) currentContext->unref();
+        thread->setCurrentContext(NULL);
+        thread->glDecoder().setContextData(NULL);
+    }
+
+    EGLSurface draw = EGL_NO_SURFACE;
+    EGLSurface read = EGL_NO_SURFACE;
+    SurfaceMap::iterator i;
+    i = m_surfaces.find(drawSurface);   if (i != m_surfaces.end()) draw = i->second->eglSurface();
+    i = m_surfaces.find(readSurface);   if (i != m_surfaces.end()) read = i->second->eglSurface();
+
+    return eglMakeCurrent(m_dpy, draw, read, eglContext);
+}
+
+int Renderer::swapBuffers(RenderingThread *thread,
+                          const ClientHandle &surface)
+{
+    android::Mutex::Autolock(this->m_mutex);
+
+    SurfaceMap::iterator s = m_surfaces.find(surface);
+    if (s == m_surfaces.end()) {
+        fprintf(stderr, "swapping buffers for non existing surface\n");
+        return -1;
+    }
+    return eglSwapBuffers(m_dpy, s->second->eglSurface());
+}
diff --git a/tools/emulator/opengl/tests/ut_renderer/Renderer.h b/tools/emulator/opengl/tests/ut_renderer/Renderer.h
new file mode 100644
index 0000000..49be147
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/Renderer.h
@@ -0,0 +1,62 @@
+/*
+* 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 _RENDERER_H_
+#define _RENDERER_H_
+#include <map>
+#include "RendererSurface.h"
+#include "RendererContext.h"
+#include "NativeWindowing.h"
+#include <utils/threads.h>
+
+class RenderingThread;
+
+class Renderer {
+public:
+
+    class ClientHandle {
+    public:
+        unsigned int pid;
+        unsigned int handle;
+        ClientHandle(unsigned int _pid, unsigned int _handle) : pid(_pid), handle(_handle) {}
+
+        bool operator< (const ClientHandle & p) const {
+            bool val = (pid == p.pid) ? handle < p.handle : pid < p.pid;
+            return val;
+        }
+    };
+
+    static Renderer *instance();
+    int createSurface(RenderingThread *thread, const ClientHandle & handle);
+    int destroySurface(RenderingThread *thread, const ClientHandle &handle);
+    int createContext(RenderingThread *thread, const ClientHandle & ctx, const ClientHandle shareCtx);
+    int destroyContext(RenderingThread *thread,const ClientHandle & ctx);
+    int makeCurrent(RenderingThread *thread,
+                    const ClientHandle & drawSurface, const ClientHandle & readSurface, const ClientHandle & ctx);
+    int swapBuffers(RenderingThread *thread, const ClientHandle & surface);
+
+private:
+    typedef std::map<ClientHandle, RendererSurface *> SurfaceMap;
+    typedef std::map<ClientHandle, RendererContext *> ContextMap;
+    static Renderer *m_instance;
+    Renderer();
+    SurfaceMap m_surfaces;
+    ContextMap m_ctxs;
+    NativeWindowing *m_nw;
+    EGLDisplay m_dpy;
+
+    android::Mutex m_mutex; // single global mutex for the renderer class;
+};
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/RendererContext.cpp b/tools/emulator/opengl/tests/ut_renderer/RendererContext.cpp
new file mode 100644
index 0000000..271494d
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/RendererContext.cpp
@@ -0,0 +1,62 @@
+/*
+* 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 "RendererContext.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+RendererContext * RendererContext::create(EGLDisplay dpy, EGLConfig config, RendererContext *shareCtx)
+{
+    EGLContext ctx;
+    EGLContext shared = shareCtx == NULL ? EGL_NO_CONTEXT : shareCtx->eglContext();
+    ctx = eglCreateContext(dpy, config, shared, NULL);
+    if (eglGetError() != EGL_SUCCESS) return NULL;
+
+    return new RendererContext(dpy, ctx);
+}
+
+int RendererContext::destroy()
+{
+    if (count() <= 0) {
+        eglDestroyContext(m_dpy, m_ctx);
+        return 1;
+    }
+    return 0;
+}
+
+#ifdef PVR_WAR
+void RendererContext::setActiveTexture(GLenum texture)
+{
+    m_activeTexture = texture - GL_TEXTURE0;
+}
+
+void RendererContext::setTex2DBind(GLuint texture)
+{
+    m_tex2DBind[m_activeTexture] = texture;
+}
+
+GLuint RendererContext::getTex2DBind()
+{
+    return m_tex2DBind[m_activeTexture];
+}
+
+void RendererContext::addPendingCropRect(int *rect)
+{
+    PendingCropRect *r = new PendingCropRect;
+    r->texture = m_tex2DBind[m_activeTexture];
+    memcpy(r->rect, rect, 4*sizeof(int));
+    m_pendingCropRects.insert(r);
+}
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/RendererContext.h b/tools/emulator/opengl/tests/ut_renderer/RendererContext.h
new file mode 100644
index 0000000..c0fd6dc
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/RendererContext.h
@@ -0,0 +1,125 @@
+/*
+* 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 _RENDERER_CONTEXT_H_
+#define _RENDERER_CONTEXT_H_
+
+#include "RendererObject.h"
+#include "GLDecoderContextData.h"
+
+#include <EGL/egl.h>
+#define GL_API
+#define GL_APIENTRY
+#include <GLES/gl.h>
+#include <string.h>
+
+#ifdef PVR_WAR
+#include <set>
+struct PendingCropRect
+{
+    GLuint texture;
+    int rect[4];
+};
+
+typedef std::set<PendingCropRect *> PendingCropRectSet;
+#endif
+
+class RendererContext : public RendererObject {
+public:
+    static RendererContext *create(EGLDisplay dpy, EGLConfig config, RendererContext *shareCtx);
+    EGLContext eglContext() { return m_ctx; }
+    int destroy();
+    GLDecoderContextData & decoderContextData() { return m_contextData; }
+#ifdef PVR_WAR
+    void setActiveTexture(GLenum texture);
+    GLenum getActiveTexture() { return GL_TEXTURE0 + m_activeTexture; }
+    void setTex2DBind(GLuint texture);
+    void setTex2DEnable(bool enable) {
+        m_tex2DEnable[m_activeTexture] = enable;
+    }
+    bool isTex2DEnable(int texunit) { return m_tex2DEnable[texunit]; }
+    GLuint getTex2DBind();
+    void addPendingCropRect(int *rect);
+    PendingCropRectSet &getPendingCropRects() { return m_pendingCropRects; }
+
+    void setClientActiveTexture(GLenum texture) { m_clientActiveTexture = texture - GL_TEXTURE0; }
+    GLenum getClientActiveTexture() { return m_clientActiveTexture + GL_TEXTURE0; }
+    void enableClientState(GLenum cap, bool enable) {
+        switch(cap) {
+            case GL_VERTEX_ARRAY:
+                m_clientStateEnable[0] = enable;
+                break;
+            case GL_NORMAL_ARRAY:
+                m_clientStateEnable[1] = enable;
+                break;
+            case GL_COLOR_ARRAY:
+                m_clientStateEnable[2] = enable;
+                break;
+            case GL_POINT_SIZE_ARRAY_OES:
+                m_clientStateEnable[3] = enable;
+                break;
+            case GL_TEXTURE_COORD_ARRAY:
+                m_clientStateEnable[4 + m_clientActiveTexture] = enable;
+                break;
+        }
+    }
+
+    bool getClientState(GLenum cap, int texUnit) {
+        switch(cap) {
+            case GL_VERTEX_ARRAY:
+                return m_clientStateEnable[0];
+            case GL_NORMAL_ARRAY:
+                return m_clientStateEnable[1];
+            case GL_COLOR_ARRAY:
+                return m_clientStateEnable[2];
+            case GL_POINT_SIZE_ARRAY_OES:
+                return m_clientStateEnable[3];
+                break;
+            case GL_TEXTURE_COORD_ARRAY:
+                return m_clientStateEnable[4 + texUnit];
+                break;
+        }
+        return false;
+    }
+#endif
+
+private:
+    EGLDisplay m_dpy;
+    EGLContext m_ctx;
+    GLDecoderContextData m_contextData;
+
+    RendererContext(EGLDisplay dpy, EGLContext ctx) :
+        m_dpy(dpy),
+        m_ctx(ctx)
+    {
+#ifdef PVR_WAR
+        m_activeTexture = 0;
+        m_clientActiveTexture = 0;
+        memset(m_tex2DBind, 0, 8*sizeof(GLuint));
+        memset(m_tex2DEnable, 0, 8*sizeof(bool));
+        memset(m_clientStateEnable, 0, 16*sizeof(bool));
+#endif
+    }
+
+#ifdef PVR_WAR
+    int m_tex2DBind[8];
+    bool m_tex2DEnable[8];
+    int m_activeTexture;
+    int m_clientActiveTexture;
+    bool m_clientStateEnable[16];
+    PendingCropRectSet m_pendingCropRects;
+#endif
+};
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/RendererObject.h b/tools/emulator/opengl/tests/ut_renderer/RendererObject.h
new file mode 100644
index 0000000..18c89be
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/RendererObject.h
@@ -0,0 +1,29 @@
+/*
+* 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 _RENDERER_OBJECT_H_
+#define _RENDERER_OBJECT_H_
+
+class RendererObject {
+public:
+    RendererObject() { m_count = 0; }
+
+    int count() { return m_count; }
+    void ref() { m_count++; }
+    void unref() { m_count--; }
+private:
+    int m_count;
+};
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/RendererSurface.cpp b/tools/emulator/opengl/tests/ut_renderer/RendererSurface.cpp
new file mode 100644
index 0000000..2a8dc81
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/RendererSurface.cpp
@@ -0,0 +1,91 @@
+/*
+* 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 "RendererSurface.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "NativeWindowing.h"
+
+#define MAX_ATTRIB 100
+
+
+EGLConfig RendererSurface::getEglConfig(EGLDisplay eglDisplay, SurfaceConfig config)
+{
+    EGLConfig eglConfig;
+    int nConfigs;
+
+    EGLint attrib[MAX_ATTRIB];
+    int pos =0;
+
+    attrib[pos++] = EGL_SURFACE_TYPE; attrib[pos++] = EGL_WINDOW_BIT;
+    if (config & CONFIG_DEPTH) {attrib[pos++] = EGL_DEPTH_SIZE; attrib[pos++] = 1;}
+    attrib[pos++] = EGL_NONE;
+
+    if (!eglChooseConfig(eglDisplay, attrib, &eglConfig, 1, &nConfigs)) {
+        return 0;
+    }
+    /***/
+    int ibuf;
+    if (eglGetConfigAttrib(eglDisplay, eglConfig, EGL_BUFFER_SIZE, &ibuf)) {
+        fprintf(stderr, "EGL COLOR Buffer size: %d\n", ibuf);
+    } else {
+        fprintf(stderr, "eglGetConfigAttrib error: %d\n", eglGetError());
+    }
+    if (eglGetConfigAttrib(eglDisplay, eglConfig, EGL_DEPTH_SIZE, &ibuf)) {
+        fprintf(stderr, "EGL DEPTH Buffer size: %d\n", ibuf);
+    } else {
+        fprintf(stderr, "eglGetConfigAttrib error: %d\n", eglGetError());
+    }
+    /***/
+
+
+    if (nConfigs != 1) {
+        return 0;
+    }
+    return eglConfig;
+}
+
+RendererSurface * RendererSurface::create(EGLDisplay eglDisplay, SurfaceConfig config, NativeWindowing *nw)
+{
+
+    EGLConfig eglConfig = getEglConfig(eglDisplay, config);
+    if (eglConfig == 0) {
+        return NULL;
+    }
+
+    NativeWindowType window = nw->createNativeWindow(nw->getNativeDisplay(), DEFAULT_WIDTH, DEFAULT_HEIGHT);
+    if (window == 0) {
+        return NULL;
+    }
+
+    EGLSurface eglSurface = eglCreateWindowSurface(eglDisplay,
+                                                   eglConfig,
+                                                   window, NULL);
+
+    if (eglGetError() != EGL_SUCCESS) {
+        return NULL;
+    }
+
+    return new RendererSurface(eglDisplay, window, eglSurface, eglConfig);
+}
+
+int RendererSurface::destroy(NativeWindowing *nw)
+{
+    eglDestroySurface(m_eglDisplay, m_eglSurface);
+    nw->destroyNativeWindow(nw->getNativeDisplay(), m_window);
+    return 1;
+}
+
diff --git a/tools/emulator/opengl/tests/ut_renderer/RendererSurface.h b/tools/emulator/opengl/tests/ut_renderer/RendererSurface.h
new file mode 100644
index 0000000..4f6709c
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/RendererSurface.h
@@ -0,0 +1,52 @@
+/*
+* 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 _RENDERER_SURFACE_H_
+#define _RENDERER_SURFACE_H_
+
+#include <EGL/egl.h>
+#include "NativeWindowing.h"
+#include "RendererObject.h"
+
+#define DEFAULT_HEIGHT 480
+#define DEFAULT_WIDTH 320
+
+class RendererSurface : public RendererObject {
+public:
+    typedef enum { CONFIG_DEPTH = 1 << 0 } SurfaceConfig;
+
+    EGLSurface eglSurface() { return m_eglSurface; }
+    EGLConfig eglConfig() { return m_config; }
+    EGLDisplay eglDisplay() { return m_eglDisplay; }
+
+    static RendererSurface * create(EGLDisplay eglDisplay, SurfaceConfig config, NativeWindowing *nw);
+    static EGLConfig getEglConfig(EGLDisplay eglDisplay, SurfaceConfig config);
+
+    int destroy(NativeWindowing *nw);
+
+private:
+    RendererSurface(EGLDisplay display, NativeWindowType window, EGLSurface surface, EGLConfig config) :
+        m_eglDisplay(display),
+        m_config(config),
+        m_window(window),
+        m_eglSurface(surface)
+    {}
+
+    EGLDisplay m_eglDisplay;
+    EGLConfig m_config;
+    NativeWindowType m_window;
+    EGLSurface m_eglSurface;
+};
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/RenderingThread.cpp b/tools/emulator/opengl/tests/ut_renderer/RenderingThread.cpp
new file mode 100644
index 0000000..a7bd939
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/RenderingThread.cpp
@@ -0,0 +1,376 @@
+/*
+* 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 "RenderingThread.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <pthread.h>
+#include "ReadBuffer.h"
+#include "Renderer.h"
+#include "TimeUtils.h"
+
+#include <GLES/glext.h>
+
+__thread RenderingThread * RenderingThread::m_tls;
+
+#ifdef PVR_WAR
+void RenderingThread::s_glTexParameteriv(GLenum target, GLenum param, int *p)
+{
+    if (target == GL_TEXTURE_2D && param == GL_TEXTURE_CROP_RECT_OES) {
+        m_tls->m_currentContext->addPendingCropRect(p);
+    } else {
+        m_tls->m_glTexParameteriv(target, param, p);
+    }
+}
+
+void RenderingThread::s_glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat w, GLfloat h)
+{
+    m_tls->applyPendingCropRects();
+    m_tls->m_glDrawTexfOES(x, y, z, w, h);
+    m_tls->fixTextureEnable();
+}
+
+void RenderingThread::s_glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort w, GLshort h)
+{
+    m_tls->applyPendingCropRects();
+    m_tls->m_glDrawTexsOES(x, y, z, w, h);
+    m_tls->fixTextureEnable();
+}
+
+void RenderingThread::s_glDrawTexiOES(GLint x, GLint y, GLint z, GLint w, GLint h)
+{
+    m_tls->applyPendingCropRects();
+    m_tls->m_glDrawTexiOES(x, y, z, w, h);
+    m_tls->fixTextureEnable();
+}
+
+void RenderingThread::s_glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed w, GLfixed h)
+{
+    m_tls->applyPendingCropRects();
+    m_tls->m_glDrawTexxOES(x, y, z, w, h);
+    m_tls->fixTextureEnable();
+}
+
+void RenderingThread::s_glDrawTexfvOES(GLfloat *coords)
+{
+    m_tls->applyPendingCropRects();
+    m_tls->m_glDrawTexfvOES(coords);
+    m_tls->fixTextureEnable();
+}
+
+void RenderingThread::s_glDrawTexsvOES(GLshort *coords)
+{
+    m_tls->applyPendingCropRects();
+    m_tls->m_glDrawTexsvOES(coords);
+    m_tls->fixTextureEnable();
+}
+
+void RenderingThread::s_glDrawTexivOES(GLint *coords)
+{
+    m_tls->applyPendingCropRects();
+    m_tls->m_glDrawTexivOES(coords);
+    m_tls->fixTextureEnable();
+}
+
+void RenderingThread::s_glDrawTexxvOES(GLfixed *coords)
+{
+    m_tls->applyPendingCropRects();
+    m_tls->m_glDrawTexxvOES(coords);
+    m_tls->fixTextureEnable();
+}
+
+
+void RenderingThread::s_glActiveTexture(GLenum texture)
+{
+    if (texture - GL_TEXTURE0 >= m_tls->m_backendCaps.maxTextureUnits) return;
+
+    m_tls->m_currentContext->setActiveTexture(texture);
+    m_tls->m_glActiveTexture(texture);
+}
+
+void RenderingThread::s_glBindTexture(GLenum target, GLuint texture)
+{
+    if (target == GL_TEXTURE_2D) m_tls->m_currentContext->setTex2DBind(texture);
+    m_tls->m_glBindTexture(target, texture);
+}
+
+void RenderingThread::s_glEnable(GLenum cap)
+{
+    if (cap == GL_TEXTURE_2D) m_tls->m_currentContext->setTex2DEnable(true);
+    m_tls->m_glEnable(cap);
+}
+
+void RenderingThread::s_glDisable(GLenum cap)
+{
+    if (cap == GL_TEXTURE_2D) m_tls->m_currentContext->setTex2DEnable(false);
+    m_tls->m_glDisable(cap);
+}
+
+void RenderingThread::s_glClientActiveTexture(GLenum texture)
+{
+    if (texture - GL_TEXTURE0 >= m_tls->m_backendCaps.maxTextureUnits) return;
+    m_tls->m_currentContext->setClientActiveTexture(texture);
+    m_tls->m_glClientActiveTexture(texture);
+}
+
+void RenderingThread::s_glEnableClientState(GLenum cap)
+{
+    m_tls->m_currentContext->enableClientState(cap, true);
+    m_tls->m_glEnableClientState(cap);
+}
+
+void RenderingThread::s_glDisableClientState(GLenum cap)
+{
+    m_tls->m_currentContext->enableClientState(cap, false);
+    m_tls->m_glDisableClientState(cap);
+}
+
+void RenderingThread::applyPendingCropRects()
+{
+    PendingCropRectSet &rset = m_currentContext->getPendingCropRects();
+    if (rset.size() > 0) {
+        GLuint currBindedTex = m_currentContext->getTex2DBind();
+        for (PendingCropRectSet::iterator i = rset.begin();
+             i != rset.end();
+             i++) {
+            m_glBindTexture(GL_TEXTURE_2D, (*i)->texture);
+            m_glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, (int *)(*i)->rect);
+            delete (*i);
+        }
+        m_glBindTexture(GL_TEXTURE_2D, currBindedTex);
+        rset.clear();
+    }
+}
+
+void RenderingThread::fixTextureEnable()
+{
+    // restore texture units enable state
+    for (unsigned int i=0; i<m_backendCaps.maxTextureUnits; i++) {
+        m_glActiveTexture(GL_TEXTURE0 + i);
+        if (m_currentContext->isTex2DEnable(i)) {
+            m_glEnable(GL_TEXTURE_2D);
+        }
+        else {
+            m_glDisable(GL_TEXTURE_2D);
+        }
+        m_glClientActiveTexture(GL_TEXTURE0 + i);
+        if (m_currentContext->getClientState(GL_TEXTURE_COORD_ARRAY, i)) {
+            m_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+        }
+        else {
+            m_glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+        }
+    }
+    // restore current active texture
+    m_glActiveTexture(m_currentContext->getActiveTexture());
+    m_glClientActiveTexture(m_currentContext->getClientActiveTexture());
+
+    // restore other client state enable bits
+    if (m_currentContext->getClientState(GL_VERTEX_ARRAY, 0)) {
+        m_glEnableClientState(GL_VERTEX_ARRAY);
+    }
+    else {
+        m_glDisableClientState(GL_VERTEX_ARRAY);
+    }
+
+    if (m_currentContext->getClientState(GL_NORMAL_ARRAY, 0)) {
+        m_glEnableClientState(GL_NORMAL_ARRAY);
+    }
+    else {
+        m_glDisableClientState(GL_NORMAL_ARRAY);
+    }
+
+    if (m_currentContext->getClientState(GL_COLOR_ARRAY, 0)) {
+        m_glEnableClientState(GL_COLOR_ARRAY);
+    }
+    else {
+        m_glDisableClientState(GL_COLOR_ARRAY);
+    }
+
+    if (m_currentContext->getClientState(GL_POINT_SIZE_ARRAY_OES, 0)) {
+        m_glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
+    }
+    else {
+        m_glDisableClientState(GL_POINT_SIZE_ARRAY_OES);
+    }
+}
+#endif
+
+
+int RenderingThread::s_createContext(uint32_t pid, uint32_t handle, uint32_t shareCtx)
+{
+    return Renderer::instance()->createContext(m_tls, Renderer::ClientHandle(pid, handle),
+                                               Renderer::ClientHandle(pid, shareCtx));
+
+}
+
+
+int RenderingThread::s_createSurface(uint32_t pid, uint32_t handle)
+{
+    return Renderer::instance()->createSurface(m_tls, Renderer::ClientHandle(pid, handle));
+}
+
+int RenderingThread::s_destroySurface(uint32_t pid, uint32_t handle)
+{
+    return Renderer::instance()->destroySurface(m_tls, Renderer::ClientHandle(pid, handle));
+}
+
+int RenderingThread::s_destroyContext(uint32_t pid, uint32_t handle)
+{
+    return Renderer::instance()->destroyContext(m_tls, Renderer::ClientHandle(pid, handle));
+}
+
+
+int RenderingThread::s_makeCurrent(uint32_t pid, uint32_t drawSurface, uint32_t readSurface, uint32_t ctx)
+{
+    int ret = Renderer::instance()->makeCurrent(m_tls,
+                                             Renderer::ClientHandle(pid, drawSurface),
+                                             Renderer::ClientHandle(pid, readSurface),
+                                             Renderer::ClientHandle(pid, ctx));
+
+    if (ret && ctx) {
+        m_tls->initBackendCaps();
+    }
+
+    return ret;
+}
+
+void RenderingThread::s_swapBuffers(uint32_t pid, uint32_t surface)
+{
+    Renderer::instance()->swapBuffers(m_tls, Renderer::ClientHandle(pid, surface));
+}
+
+
+RenderingThread::RenderingThread(TcpStream *stream) :
+    m_stream(stream),
+    m_currentContext(NULL)
+{
+    m_backendCaps.initialized = false;
+}
+
+int RenderingThread::start(void)
+{
+    if (pthread_create(&m_thread, NULL, s_thread, this) < 0) {
+        perror("pthread_create");
+        return -1;
+    }
+    return 0;
+}
+
+
+void * RenderingThread::s_thread(void *data)
+{
+    RenderingThread *self = (RenderingThread *)data;
+    m_tls = self;
+    return self->thread();
+}
+
+void RenderingThread::initBackendCaps()
+{
+    if (m_backendCaps.initialized) return;
+
+    m_glDec.glGetIntegerv(GL_MAX_TEXTURE_UNITS, (GLint *)&m_backendCaps.maxTextureUnits);
+    m_backendCaps.initialized = true;
+}
+
+void *RenderingThread::thread()
+{
+
+    // initialize our decoders;
+    m_glDec.initGL();
+
+#ifdef PVR_WAR
+    m_glTexParameteriv = m_glDec.set_glTexParameteriv(s_glTexParameteriv);
+    m_glDrawTexfOES = m_glDec.set_glDrawTexfOES(s_glDrawTexfOES);
+    m_glDrawTexsOES = m_glDec.set_glDrawTexsOES(s_glDrawTexsOES);
+    m_glDrawTexiOES = m_glDec.set_glDrawTexiOES(s_glDrawTexiOES);
+    m_glDrawTexxOES = m_glDec.set_glDrawTexxOES(s_glDrawTexxOES);
+    m_glDrawTexfvOES = m_glDec.set_glDrawTexfvOES(s_glDrawTexfvOES);
+    m_glDrawTexsvOES = m_glDec.set_glDrawTexsvOES(s_glDrawTexsvOES);
+    m_glDrawTexivOES = m_glDec.set_glDrawTexivOES(s_glDrawTexivOES);
+    m_glDrawTexxvOES = m_glDec.set_glDrawTexxvOES(s_glDrawTexxvOES);
+    m_glActiveTexture = m_glDec.set_glActiveTexture(s_glActiveTexture);
+    m_glBindTexture = m_glDec.set_glBindTexture(s_glBindTexture);
+    m_glEnable = m_glDec.set_glEnable(s_glEnable);
+    m_glDisable = m_glDec.set_glDisable(s_glDisable);
+    m_glClientActiveTexture = m_glDec.set_glClientActiveTexture(s_glClientActiveTexture);
+    m_glEnableClientState = m_glDec.set_glEnableClientState(s_glEnableClientState);
+    m_glDisableClientState = m_glDec.set_glDisableClientState(s_glDisableClientState);
+#endif
+
+    m_utDec.set_swapBuffers(s_swapBuffers);
+    m_utDec.set_createContext(s_createContext);
+    m_utDec.set_destroyContext(s_destroyContext);
+    m_utDec.set_createSurface(s_createSurface);
+    m_utDec.set_destroySurface(s_destroySurface);
+    m_utDec.set_makeCurrentContext(s_makeCurrent);
+
+    ReadBuffer readBuf(m_stream, DECODER_BUF_SIZE);
+
+    int stats_totalBytes = 0;
+    long long stats_t0 = GetCurrentTimeMS();
+
+    while (1) {
+
+        int stat = readBuf.getData();
+        if (stat == 0) {
+            fprintf(stderr, "client shutdown\n");
+            break;
+        } else if (stat < 0) {
+            perror("getData");
+            break;
+        }
+
+        //
+        // log received bandwidth statistics
+        //
+        stats_totalBytes += readBuf.validData();
+        long long dt = GetCurrentTimeMS() - stats_t0;
+        if (dt > 1000) {
+            float dts = (float)dt / 1000.0f;
+            printf("Used Bandwidth %5.3f MB/s\n", ((float)stats_totalBytes / dts) / (1024.0f*1024.0f));
+            stats_totalBytes = 0;
+            stats_t0 = GetCurrentTimeMS();
+        }
+
+        bool progress = true;
+        while (progress) {
+            progress = false;
+            // we need at least one header (8 bytes) in our buffer
+            if (readBuf.validData() >= 8) {
+                size_t last = m_glDec.decode(readBuf.buf(), readBuf.validData(), m_stream);
+                if (last > 0) {
+                    progress = true;
+                    readBuf.consume(last);
+                }
+            }
+
+            if (readBuf.validData() >= 8) {
+                size_t last = m_utDec.decode(readBuf.buf(), readBuf.validData(), m_stream);
+                if (last > 0) {
+                    readBuf.consume(last);
+                    progress = true;
+                }
+            }
+        }
+    }
+    // shutdown
+    if (m_currentContext != NULL) {
+        m_currentContext->unref();
+    }
+
+    return NULL;
+}
diff --git a/tools/emulator/opengl/tests/ut_renderer/RenderingThread.h b/tools/emulator/opengl/tests/ut_renderer/RenderingThread.h
new file mode 100644
index 0000000..bbc4dd3
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/RenderingThread.h
@@ -0,0 +1,113 @@
+/*
+* 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 _RENDERING_THREAD_H_
+#define _RENDERING_THREAD_H_
+
+#include "TcpStream.h"
+#include "GLDecoder.h"
+#include "ut_rendercontrol_dec.h"
+#include <pthread.h>
+
+#define GL_API
+#define GL_APIENTRY
+
+#include <GLES/egl.h>
+#include <GLES/gl.h>
+
+
+#define WINDOW_WIDTH    320
+#define WINDOW_HEIGHT   480
+
+#define DECODER_BUF_SIZE (4 * 1024 * 1024)
+
+class RendererContext;
+
+class RenderingThread {
+public:
+    RenderingThread(TcpStream *stream);
+    int start();
+    void *thread();
+    RendererContext *currentContext() { return m_currentContext; }
+    void setCurrentContext(RendererContext *ctx) { m_currentContext = ctx; }
+    GLDecoder & glDecoder() { return m_glDec; }
+private:
+    void initBackendCaps();
+
+private:
+    GLDecoder   m_glDec;
+    ut_rendercontrol_decoder_context_t m_utDec;
+
+    TcpStream   *m_stream;
+    pthread_t m_thread;
+    RendererContext * m_currentContext;
+
+    struct BackendCaps {
+        bool initialized;
+        GLuint maxTextureUnits;
+    } m_backendCaps;
+
+    static void * s_thread(void *data);
+    static __thread RenderingThread *m_tls;
+
+    static int s_createContext(uint32_t pid, uint32_t handle, uint32_t shareCtx);
+    static int s_createSurface(uint32_t pid, uint32_t handle);
+    static int s_destroySurface(uint32_t pid, uint32_t handle);
+    static int s_destroyContext(uint32_t pid, uint32_t handle);
+    static int s_makeCurrent(uint32_t pid, uint32_t drawSurface, uint32_t readSurface, uint32_t ctx);
+    static void s_swapBuffers(uint32_t pid, uint32_t surface);
+#ifdef PVR_WAR
+    static void s_glTexParameteriv(GLenum target, GLenum param, int *p);
+    static void s_glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat w, GLfloat h);
+    static void s_glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort w, GLshort h);
+    static void s_glDrawTexiOES(GLint x, GLint y, GLint z, GLint w, GLint h);
+    static void s_glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed w, GLfixed h);
+    static void s_glDrawTexfvOES(GLfloat *coords);
+    static void s_glDrawTexsvOES(GLshort *coords);
+    static void s_glDrawTexivOES(GLint *coords);
+    static void s_glDrawTexxvOES(GLfixed *coords);
+
+    static void s_glActiveTexture(GLenum texture);
+    static void s_glBindTexture(GLenum target, GLuint texture);
+    static void s_glEnable(GLenum cap);
+    static void s_glDisable(GLenum cap);
+    static void s_glClientActiveTexture(GLenum texture);
+    static void s_glEnableClientState(GLenum cap);
+    static void s_glDisableClientState(GLenum cap);
+
+    void applyPendingCropRects();
+    void fixTextureEnable();
+
+    glTexParameteriv_server_proc_t m_glTexParameteriv;
+    glDrawTexfOES_server_proc_t m_glDrawTexfOES;
+    glDrawTexiOES_server_proc_t m_glDrawTexiOES;
+    glDrawTexsOES_server_proc_t m_glDrawTexsOES;
+    glDrawTexxOES_server_proc_t m_glDrawTexxOES;
+    glDrawTexfvOES_server_proc_t m_glDrawTexfvOES;
+    glDrawTexivOES_server_proc_t m_glDrawTexivOES;
+    glDrawTexsvOES_server_proc_t m_glDrawTexsvOES;
+    glDrawTexxvOES_server_proc_t m_glDrawTexxvOES;
+    glActiveTexture_server_proc_t m_glActiveTexture;
+    glBindTexture_server_proc_t m_glBindTexture;
+    glEnable_server_proc_t m_glEnable;
+    glDisable_server_proc_t m_glDisable;
+    glClientActiveTexture_server_proc_t m_glClientActiveTexture;
+    glEnableClientState_server_proc_t m_glEnableClientState;
+    glDisableClientState_server_proc_t m_glDisableClientState;
+#endif
+
+};
+
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/TimeUtils.cpp b/tools/emulator/opengl/tests/ut_renderer/TimeUtils.cpp
new file mode 100644
index 0000000..7f65cca
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/TimeUtils.cpp
@@ -0,0 +1,55 @@
+/*
+* 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 "TimeUtils.h"
+
+#ifdef _WIN32
+#include <Windows.h>
+#include <time.h>
+#include <stdio.h>
+#elif defined(__linux__)
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#else
+#error "Unsupported platform"
+#endif
+
+long long GetCurrentTimeMS()
+{
+#ifdef _WIN32
+    static LARGE_INTEGER freq;
+    static bool bNotInit = true;
+    if ( bNotInit ) {
+        bNotInit = (QueryPerformanceFrequency( &freq ) == FALSE);
+    }
+    LARGE_INTEGER currVal;
+    QueryPerformanceCounter( &currVal );
+
+    return currVal.QuadPart / (freq.QuadPart / 1000);
+
+#elif defined(__linux__)
+
+    struct timespec now;
+    clock_gettime(CLOCK_MONOTONIC, &now);
+    long long iDiff = (now.tv_sec * 1000LL) + now.tv_nsec/1000000LL;
+    return iDiff;
+
+#else
+
+#error "Unsupported platform"
+
+#endif
+}
diff --git a/tools/emulator/opengl/tests/ut_renderer/TimeUtils.h b/tools/emulator/opengl/tests/ut_renderer/TimeUtils.h
new file mode 100644
index 0000000..184a13f
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/TimeUtils.h
@@ -0,0 +1,21 @@
+/*
+* 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 _TIME_UTILS_H
+#define _TIME_UTILS_H
+
+long long GetCurrentTimeMS();
+
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/X11RendererSurface.cpp b/tools/emulator/opengl/tests/ut_renderer/X11RendererSurface.cpp
new file mode 100644
index 0000000..121ee87
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/X11RendererSurface.cpp
@@ -0,0 +1,69 @@
+/*
+* 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 "X11RendererSurface.h"
+
+NativeDisplayType X11RendererSurface::getNativeDisplay()
+{
+    if (m_display == NULL) {
+        m_display = XOpenDisplay(NULL);
+    }
+    return NativeDisplayType(m_display);
+}
+
+int X11RendererSurface::destoryNativeWindow(NativeWindowType win)
+{
+    if (m_display == NULL) return -1;
+
+    Window x11Window = (Window)(win);
+    return XDestroyWindow(m_display, x11Window);
+}
+
+NativeWindowType GlesX11Win::createNativeWindow()
+{
+
+    getNativeDisplay();
+    if (m_display == NULL) {
+        return -1;
+    }
+
+    long defaultScreen = DefaultScreen( dpy );
+    Window rootWindow = RootWindow(dpy, defaultScreen);
+    int depth = DefaultDepth(dpy, defaultScreen);
+    XVisualInfo *visualInfo = new XVisualInfo;
+
+    XMatchVisualInfo(m_display, defaultScreen, , dpeth, TrueColor, visualInfo);
+    if (visualInfo == NULL) {
+        fprintf(stderr, "couldn't find matching visual\n");
+        return -1;
+    }
+
+    Colormap x11Colormap = XCreateColormap(m_display, rootWindow, visualInfo->visual, AllocNone);
+    XSetWindowAttributes sWA;
+    sWA.Colormap = x11Colormap;
+    sWA.event_mask = StructureNotifyMask | ExposureMask;
+    unsigned int eventMask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;
+
+    Window win = XCreateWindow( m_display,
+                                rootWindow,
+                               0, 0, width, height,
+                                 0, CopyFromParent, InputOutput,
+                               CopyFromParent, eventMask, &sWA);
+
+    XMapWindow(m_display, win);
+    XFlush(m_display);
+    return NativeWindowType(win);
+}
+
diff --git a/tools/emulator/opengl/tests/ut_renderer/X11RendererSurface.h b/tools/emulator/opengl/tests/ut_renderer/X11RendererSurface.h
new file mode 100644
index 0000000..be9bcec
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/X11RendererSurface.h
@@ -0,0 +1,37 @@
+/*
+* 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 _X11_RENDERER_SURFACE_H_
+#define _X11_RENDERER_SURFACE_H_
+
+#include <X11/Xutil.h>
+#include <X11/Xlib.h>
+#include <EGL/egl.h>
+
+include "RendererSurface.h"
+
+class X11RendererSurface : public RendererSurface
+{
+public:
+    X11RendererSurface() : RendererSurface() {
+        m_display = NULL;
+    }
+    NativeDisplayType getNativeDisplay();
+    NativeWindowType createNativeWindow();
+    int destroyNativeWindow(NativeWindowType win);
+private:
+    Display m_display;
+};
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/X11Windowing.cpp b/tools/emulator/opengl/tests/ut_renderer/X11Windowing.cpp
new file mode 100644
index 0000000..4009eb4
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/X11Windowing.cpp
@@ -0,0 +1,70 @@
+/*
+* 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 "X11Windowing.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+NativeDisplayType X11Windowing::getNativeDisplay()
+{
+    Display *dpy = XOpenDisplay(NULL);
+    return (NativeDisplayType)dpy;
+}
+
+NativeWindowType X11Windowing::createNativeWindow(NativeDisplayType _dpy, int width, int height)
+{
+    Display *dpy = (Display *) _dpy;
+
+    long defaultScreen = DefaultScreen( dpy );
+    Window rootWindow = RootWindow(dpy, defaultScreen);
+    int depth = DefaultDepth(dpy, defaultScreen);
+    XVisualInfo *visualInfo = new XVisualInfo;
+
+    XMatchVisualInfo(dpy, defaultScreen, depth, TrueColor, visualInfo);
+    if (visualInfo == NULL) {
+        fprintf(stderr, "couldn't find matching visual\n");
+        return NULL;
+    }
+
+    Colormap x11Colormap = XCreateColormap(dpy, rootWindow, visualInfo->visual, AllocNone);
+    XSetWindowAttributes sWA;
+    sWA.colormap = x11Colormap;
+    sWA.event_mask = StructureNotifyMask | ExposureMask;
+    sWA.background_pixel = 0;
+    sWA.border_pixel = 0;
+    unsigned int attributes_mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;
+
+    Window win = XCreateWindow( dpy,
+                                rootWindow,
+                               0, 0, width, height,
+                                 0, CopyFromParent, InputOutput,
+                               CopyFromParent, attributes_mask, &sWA);
+
+    XMapWindow(dpy, win);
+    XFlush(dpy);
+    return NativeWindowType(win);
+}
+
+int X11Windowing::destroyNativeWindow(NativeDisplayType _dpy, NativeWindowType _win)
+{
+    Display *dpy = (Display *)_dpy;
+    Window win = (Window)_win;
+    XDestroyWindow(dpy, win);
+    XFlush(dpy);
+    return 0;
+}
diff --git a/tools/emulator/opengl/tests/ut_renderer/X11Windowing.h b/tools/emulator/opengl/tests/ut_renderer/X11Windowing.h
new file mode 100644
index 0000000..0f0c76b
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/X11Windowing.h
@@ -0,0 +1,27 @@
+/*
+* 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 _X11WINDOWING_H_
+#define _X11WINDOWING_H_
+
+#include "NativeWindowing.h"
+
+class X11Windowing : public NativeWindowing {
+    NativeDisplayType getNativeDisplay();
+    NativeWindowType createNativeWindow(NativeDisplayType _dpy, int width, int height);
+    int destroyNativeWindow(NativeDisplayType dpy, NativeWindowType win);
+};
+
+#endif
diff --git a/tools/emulator/opengl/tests/ut_renderer/ut_renderer.cpp b/tools/emulator/opengl/tests/ut_renderer/ut_renderer.cpp
new file mode 100644
index 0000000..2137a82
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_renderer/ut_renderer.cpp
@@ -0,0 +1,52 @@
+/*
+* 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 <unistd.h>
+#include <string.h>
+#include "codec_defs.h"
+#include "RenderingThread.h"
+#include "TcpStream.h"
+
+
+int main(int argc, char **argv)
+{
+
+    TcpStream *socket = new TcpStream;
+
+    if (socket->listen(CODEC_SERVER_PORT) < 0) {
+        perror("listen");
+        exit(1);
+    }
+
+    printf("waiting for client connection on port: %d\n", CODEC_SERVER_PORT);
+    while (1) {
+        // wait for client connection
+        TcpStream  *glStream = socket->accept();
+        if (glStream == NULL) {
+            printf("failed to get client.. aborting\n");
+            exit(3);
+        }
+        printf("Got client connection, creating a rendering thread;\n");
+        // create a thread to handle this connection
+        RenderingThread *rt = new RenderingThread(glStream);
+        rt->start();
+    }
+
+    return 0;
+}
+
+
diff --git a/tools/emulator/system/lights/Android.mk b/tools/emulator/system/lights/Android.mk
new file mode 100644
index 0000000..c7aa83c
--- /dev/null
+++ b/tools/emulator/system/lights/Android.mk
@@ -0,0 +1,29 @@
+# Copyright (C) 2011 The Android Open Source Project.
+#
+# Original code licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this software 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.
+
+LOCAL_PATH := $(call my-dir)
+
+ifneq ($(TARGET_PRODUCT),sim)
+# HAL module implemenation, not prelinked and stored in
+# hw/<LIGHTS_HARDWARE_MODULE_ID>.<ro.hardware>.so
+include $(CLEAR_VARS)
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_SRC_FILES := lights_qemu.c
+LOCAL_MODULE := lights.goldfish
+LOCAL_MODULE_TAGS := debug
+LOCAL_CFLAGS += -DLIGHT_BACKLIGHT
+include $(BUILD_SHARED_LIBRARY)
+endif
diff --git a/tools/emulator/system/lights/lights_qemu.c b/tools/emulator/system/lights/lights_qemu.c
new file mode 100644
index 0000000..d6576a0
--- /dev/null
+++ b/tools/emulator/system/lights/lights_qemu.c
@@ -0,0 +1,213 @@
+/* Copyright (C) 2011 The Android Open Source Project
+ *
+ * Original code licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * This implements a lights hardware library for the Android emulator.
+ * the following code should be built as a shared library that will be
+ * placed into /system/lib/hw/lights.goldfish.so
+ *
+ * It will be loaded by the code in hardware/libhardware/hardware.c
+ * which is itself called from
+ * ./frameworks/base/services/jni/com_android_server_HardwareService.cpp
+ */
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "Lights"
+#endif
+
+/* we connect with the emulator through the "hw-control" qemud service */
+#define  LIGHTS_SERVICE_NAME "hw-control"
+
+#include <cutils/log.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <hardware/lights.h>
+#include <hardware/qemud.h>
+
+/* Set to 1 to enable debug messages to the log */
+#define DEBUG 0
+#if DEBUG
+# define D(...) LOGD(__VA_ARGS__)
+#else
+# define D(...) do{}while(0)
+#endif
+
+#define  E(...)  LOGE(__VA_ARGS__)
+
+/* Get brightness(0~255) from state. */
+static int
+rgb_to_brightness( struct light_state_t const* state )
+{
+    int color = state->color & 0x00ffffff;
+    return ((77 * ((color >> 16) & 0x00ff))
+            + (150 * ((color >> 8) & 0x00ff)) + (29 * (color & 0x00ff))) >> 8;
+}
+
+/* set backlight brightness by LIGHTS_SERVICE_NAME service. */
+static int
+set_light_backlight( struct light_device_t* dev, struct light_state_t const* state )
+{
+    /* Get Lights service. */
+    int  fd = qemud_channel_open( LIGHTS_SERVICE_NAME );
+
+    if (fd < 0) {
+        E( "%s: no qemud connection", __FUNCTION__ );
+        return -1;
+    }
+
+    D( "%s: On/Off %d/%d flashMode %d brightnessMode %d"
+       " RGB = 0x%08x", __func__,
+       state->flashOnMS,
+       state->flashOffMS,
+       state->flashMode,
+       state->brightnessMode,
+       state->color );
+
+    int brightness = rgb_to_brightness( state );
+
+    char buffer[64];
+    snprintf( buffer, sizeof(buffer), "power:light:brightness:lcd_backlight:%d", brightness );
+    D( "%s: lcd_backlight command: %s", __FUNCTION__, buffer );
+
+    /* send backlight command to perform the backlight setting. */
+    if (qemud_channel_send( fd, buffer, -1 ) < 0) {
+        E( "%s: could not query lcd_backlight: %s", __FUNCTION__, strerror(errno) );
+        close( fd );
+        return -1;
+    }
+
+    close( fd );
+    return 0;
+}
+
+static int
+set_light_buttons( struct light_device_t* dev, struct light_state_t const* state )
+{
+    /* @Waiting for later implementation. */
+    D( "%s: Not implemented.", __FUNCTION__ );
+
+    return 0;
+}
+
+static int
+set_light_battery( struct light_device_t* dev, struct light_state_t const* state )
+{
+    /* @Waiting for later implementation. */
+    D( "%s: Not implemented.", __FUNCTION__ );
+
+    return 0;
+}
+
+static int
+set_light_keyboard( struct light_device_t* dev, struct light_state_t const* state )
+{
+    /* @Waiting for later implementation. */
+    D( "%s: Not implemented.", __FUNCTION__ );
+
+    return 0;
+}
+
+static int
+set_light_notifications( struct light_device_t* dev, struct light_state_t const* state )
+{
+    /* @Waiting for later implementation. */
+    D( "%s: Not implemented.", __FUNCTION__ );
+
+    return 0;
+}
+
+static int
+set_light_attention( struct light_device_t* dev, struct light_state_t const* state )
+{
+    /* @Waiting for later implementation. */
+    D( "%s: Not implemented.", __FUNCTION__ );
+
+    return 0;
+}
+
+/** Close the lights device */
+static int
+close_lights( struct light_device_t *dev )
+{
+    free( dev );
+
+    return 0;
+}
+
+/**
+ * module methods
+ */
+
+/** Open a new instance of a lights device using name */
+static int
+open_lights( const struct hw_module_t* module, char const *name,
+        struct hw_device_t **device )
+{
+    void* set_light;
+
+    if (0 == strcmp( LIGHT_ID_BACKLIGHT, name )) {
+        set_light = set_light_backlight;
+    } else if (0 == strcmp( LIGHT_ID_KEYBOARD, name )) {
+        set_light = set_light_keyboard;
+    } else if (0 == strcmp( LIGHT_ID_BUTTONS, name )) {
+        set_light = set_light_buttons;
+    } else if (0 == strcmp( LIGHT_ID_BATTERY, name )) {
+        set_light = set_light_battery;
+    } else if (0 == strcmp( LIGHT_ID_NOTIFICATIONS, name )) {
+        set_light = set_light_notifications;
+    } else if (0 == strcmp( LIGHT_ID_ATTENTION, name )) {
+        set_light = set_light_attention;
+    } else {
+        D( "%s: %s light isn't supported yet.", __FUNCTION__, name );
+        return -EINVAL;
+    }
+
+    struct light_device_t *dev = malloc( sizeof(struct light_device_t) );
+    if (dev == NULL) {
+        return -EINVAL;
+    }
+    memset( dev, 0, sizeof(*dev) );
+
+    dev->common.tag = HARDWARE_DEVICE_TAG;
+    dev->common.version = 0;
+    dev->common.module = (struct hw_module_t*)module;
+    dev->common.close = (int (*)(struct hw_device_t*))close_lights;
+    dev->set_light = set_light;
+
+    *device = (struct hw_device_t*)dev;
+    return 0;
+}
+
+static struct hw_module_methods_t lights_module_methods = {
+    .open =  open_lights,
+};
+
+/*
+ * The emulator lights Module
+ */
+const struct hw_module_t HAL_MODULE_INFO_SYM = {
+    .tag = HARDWARE_MODULE_TAG,
+    .version_major = 1,
+    .version_minor = 0,
+    .id = LIGHTS_HARDWARE_MODULE_ID,
+    .name = "Goldfish lights Module",
+    .author = "The Android Open Source Project",
+    .methods = &lights_module_methods,
+};
diff --git a/tools/emulator/system/qemud/qemud.c b/tools/emulator/system/qemud/qemud.c
index e1c7b54..dc04de8 100644
--- a/tools/emulator/system/qemud/qemud.c
+++ b/tools/emulator/system/qemud/qemud.c
@@ -81,7 +81,7 @@
 /* name of the single control socket used by the daemon */
 #define CONTROL_SOCKET_NAME  "qemud"
 
-#define  DEBUG     1
+#define  DEBUG     0
 #define  T_ACTIVE  0  /* set to 1 to dump traffic */
 
 #if DEBUG