am 37191b53: SDK JB MR0: doc is 16 rev 3

* commit '37191b53de90cde879c167d1db74d5a73740f4c0':
  SDK JB MR0: doc is 16 rev 3
diff --git a/apps/Development/Android.mk b/apps/Development/Android.mk
index 1cef548..8c0f705 100644
--- a/apps/Development/Android.mk
+++ b/apps/Development/Android.mk
@@ -3,7 +3,7 @@
 
 LOCAL_MODULE_TAGS := eng
 
-LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
 
 LOCAL_SRC_FILES := $(call all-subdir-java-files) \
                 src/com/android/development/IRemoteService.aidl \
diff --git a/build/product_sdk.mk b/build/product_sdk.mk
index 11fda0c..ad82778 100644
--- a/build/product_sdk.mk
+++ b/build/product_sdk.mk
@@ -25,23 +25,29 @@
 # packaged in the SDK.
 #
 
-# Host tools that are parts of the SDK.
+# Host tools and java libraries that are parts of the SDK.
 PRODUCT_PACKAGES += \
 	adb \
 	bios.bin \
+	commons-compress-1.0 \
 	dexdump \
 	dmtracedump \
-	etc1tool \
-	hprof-conv \
-	vgabios-cirrus.bin
-
-# Native host Java libraries that are parts of the SDK.
-PRODUCT_PACKAGES += \
 	emmalib \
+	etc1tool \
 	groovy-all-1.7.0 \
-	guavalib \
-	jsr305lib \
+	guava-tools \
+	hprof-conv \
+	jcommon-1.0.12 \
+	jfreechart-1.0.9 \
+	jfreechart-1.0.9-swt \
 	jython \
 	layoutlib \
-	layoutlib-tests
+	layoutlib-tests \
+	org.eclipse.jface_3.6.2.M20110210-1200 \
+	org.eclipse.equinox.common_3.6.0.v20100503 \
+	org.eclipse.core.commands_3.6.0.I20100512-1500 \
+	osgi \
+	swing-worker-1.1 \
+	vgabios-cirrus.bin
 
+:qa!

diff --git a/build/sdk-android-mips.atree b/build/sdk-android-mips.atree
new file mode 100644
index 0000000..5e8e5ca
--- /dev/null
+++ b/build/sdk-android-mips.atree
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2012 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.
+#
+
+# Copy the little-endian Mips32-fp kernel image to .../kernel-qemu
+prebuilts/qemu-kernel/${TARGET_ARCH}/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu
+
+# version files for the SDK updater, from development.git
+development/sdk/images_mips_source.properties   system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties
diff --git a/build/sdk_only_whitelist.mk b/build/sdk_only_whitelist.mk
index 0ffff04..191e1b4 100644
--- a/build/sdk_only_whitelist.mk
+++ b/build/sdk_only_whitelist.mk
@@ -51,6 +51,7 @@
 	system/core/fastboot \
 	system/core/libcutils \
 	system/core/liblog \
+	system/core/libsparse \
 	system/core/libzipfile \
 	system/extras/ext4_utils
 
diff --git a/build/tools/mk_sdk_repo_xml.sh b/build/tools/mk_sdk_repo_xml.sh
index 832b322..298671d 100755
--- a/build/tools/mk_sdk_repo_xml.sh
+++ b/build/tools/mk_sdk_repo_xml.sh
@@ -57,7 +57,7 @@
 echo "## Using xmlns:sdk=$XMLNS"
 
 # Extract the schema version number from the XMLNS, e.g. it would extract "3"
-VERSION="${XMLNS##*/}"
+XSD_VERSION="${XMLNS##*/}"
 
 # Get the root element from the schema. This is the first element
 # which name starts with "sdk-" (e.g. sdk-repository, sdk-addon)
@@ -87,7 +87,8 @@
   done
 }
 
-# Parse all archives.
+# Definition of the attributes we read from source.properties or manifest.ini
+# files and the equivalent XML element being generated.
 
 ATTRS=(
   # Columns:
@@ -134,6 +135,82 @@
   revision                      revision                 1
 )
 
+
+# Starting with XSD repo-7 and addon-5, some revision elements are no longer just
+# integers. Instead they are in major.minor.micro.preview format. This defines
+# which elements. This depends on the XSD root element and the XSD version.
+
+if [[ "$ROOT" == "sdk-repository" && "$XSD_VERSION" -ge 7 ]] ||
+   [[ "$ROOT" == "sdk-addon"      && "$XSD_VERSION" -ge 5 ]]; then
+FULL_REVISIONS=(
+  tool          revision
+  platform-tool revision
+  @             min-tools-rev
+  @             min-platform-tools-rev
+)
+else
+FULL_REVISIONS=()
+fi
+
+
+# Parse all archives.
+
+function needs_full_revision() {
+  local PARENT="$1"
+  local ELEMENT="$2"
+  shift
+  shift
+  local P E
+
+  while [[ "$1" ]]; do
+    P=$1
+    E=$2
+    if [[ "$E" == "$ELEMENT" ]] && [[ "$P" == "@" || "$P" == "$PARENT" ]]; then
+      return 0 # true
+    fi
+    shift
+    shift
+  done
+
+  return 1 # false
+}
+
+# Parses and print a full revision in the form "1.2.3 rc4".
+# Note that the format requires to have a # space before the
+# optional "rc" (e.g. '1 rc4', not '1rc4') and no space after
+# the rc (so not '1 rc 4' either)
+function write_full_revision() {
+  local VALUE="$1"
+  local EXTRA_SPACE="$2"
+  local KEYS="major minor micro preview"
+  local V K
+
+  while [[ -n "$VALUE" && -n "$KEYS" ]]; do
+    # Take 1st segment delimited by . or space
+    V="${VALUE%%[. ]*}"
+
+    # Print it
+    if [[ "${V:0:2}" == "rc" ]]; then
+      V="${V:2}"
+      K="preview"
+      KEYS=""
+    else
+      K="${KEYS%% *}"
+    fi
+
+    if [[ -n "$V" && -n "$K" ]]; then
+        echo "$EXTRA_SPACE            <sdk:$K>$V</sdk:$K>"
+    fi
+
+    # Take the rest.
+    K="${KEYS#* }"
+    if [[ "$K" == "$KEYS" ]]; then KEYS=""; else KEYS="$K"; fi
+    V="${VALUE#*[. ]}"
+    if [[ "$V" == "$VALUE" ]]; then VALUE=""; else VALUE="$V"; fi
+  done
+}
+
+
 function parse_attributes() {
   local PROPS="$1"
   shift
@@ -151,7 +228,7 @@
     DST=$2
     REV=$3
 
-    if [[ $VERSION -ge $REV ]]; then
+    if [[ $XSD_VERSION -ge $REV ]]; then
       # Parse the property, if present. Any space is replaced by @
       VALUE=$( grep "^$SRC=" "$PROPS" | cut -d = -f 2 | tr ' ' '@' | tr -d '\r' )
       if [[ -n "$VALUE" ]]; then
@@ -172,7 +249,9 @@
 }
 
 function output_attributes() {
-  local OUT="$1"
+  local ELEMENT="$1"
+  local OUT="$2"
+  shift
   shift
   local KEY VALUE
   local NODE LAST_NODE EXTRA_SPACE
@@ -192,7 +271,13 @@
       LAST_NODE="$NODE"
       [[ "$NODE"      ]] && echo "          <sdk:$NODE>" >> "$OUT"
     fi
-    echo "$EXTRA_SPACE        <sdk:$KEY>$VALUE</sdk:$KEY>" >> "$OUT"
+    if needs_full_revision "$ELEMENT" "$KEY" ${FULL_REVISIONS[@]}; then
+      echo "$EXTRA_SPACE        <sdk:$KEY>"       >> "$OUT"
+      write_full_revision "$VALUE" "$EXTRA_SPACE" >> "$OUT"
+      echo "$EXTRA_SPACE        </sdk:$KEY>"      >> "$OUT"
+    else
+      echo "$EXTRA_SPACE        <sdk:$KEY>$VALUE</sdk:$KEY>" >> "$OUT"
+    fi
     shift
     shift
   done
@@ -285,7 +370,7 @@
 
       # Time to generate the XML for the package
       echo "    <sdk:${ELEMENT}>" >> "$OUT"
-      output_attributes "$OUT" $MAP
+      output_attributes "$ELEMENT" "$OUT" $MAP
       [[ -n "$LIBS_XML" ]] && echo "$LIBS_XML" >> "$OUT"
       echo "        <sdk:archives>" >> "$OUT"
     fi
diff --git a/host/windows/usb/android_winusb.inf b/host/windows/usb/android_winusb.inf
index b4462cd..f26a75c 100755
--- a/host/windows/usb/android_winusb.inf
+++ b/host/windows/usb/android_winusb.inf
@@ -6,15 +6,10 @@
 Class               = AndroidUsbDeviceClass

 ClassGuid           = {3F966BD9-FA04-4ec5-991C-D326973B5128}

 Provider            = %ProviderName%

-DriverVer           = 05/24/2012,6.0.0000.00000

+DriverVer           = 08/27/2012,7.0.0000.00001

 CatalogFile.NTx86   = androidwinusb86.cat

 CatalogFile.NTamd64 = androidwinusba64.cat

 

-;

-; This section seems to be required for WinUsb driver installation.

-; If this section is removed the installer will report an error

-; "Required section not found in INF file".

-;

 [ClassInstall32]

 Addreg = AndroidWinUsbClassReg

 

@@ -22,9 +17,11 @@
 HKR,,,0,%ClassName%

 HKR,,Icon,,-1

 

+

 [Manufacturer]

 %ProviderName% = Google, NTx86, NTamd64

 

+

 [Google.NTx86]

 

 ;Google Nexus One

@@ -46,6 +43,21 @@
 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E42&MI_01

 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E44&MI_01

 

+;Google Nexus Q

+%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_2C10

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_2C11

+

+;Google Nexus (generic)

+%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4EE0

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE1

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE2

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE2&MI_01

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE3

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE4&MI_01

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE5

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE6&MI_01

+

+

 [Google.NTamd64]

 

 ;Google Nexus One

@@ -67,6 +79,20 @@
 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E42&MI_01

 %CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E44&MI_01

 

+;Google Nexus Q

+%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_2C10

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_2C11

+

+;Google Nexus (generic)

+%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4EE0

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE1

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE2

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE2&MI_01

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE3

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE4&MI_01

+%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE5

+%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE6&MI_01

+

 [USB_Install]

 Include = winusb.inf

 Needs   = WINUSB.NT

@@ -127,4 +153,4 @@
 SingleBootLoaderInterface   = "Android Bootloader Interface"

 WinUSB_SvcDesc              = "Android USB Driver"

 DISK_NAME                   = "Android WinUsb installation disk"

-ClassName                   = "Android Phone"

+ClassName                   = "Android Device"

diff --git a/host/windows/usb/readme.txt b/host/windows/usb/readme.txt
index 961b45a..d01bc98 100755
--- a/host/windows/usb/readme.txt
+++ b/host/windows/usb/readme.txt
@@ -15,7 +15,7 @@
     * WdfCoInstaller01007.dll

     * WinUSBCoInstaller.dll

     * WUDFUpdate_01007.dll

-    

+

 File contained in i386 and amd64 subfolders are Microsoft distributives needed

 to install WinUsb framework. These files can be obtained from WDK 'redist'

 folder, respectively to the OS: copy x86 files to i386 subfolder, and amd64

diff --git a/ide/eclipse/.classpath b/ide/eclipse/.classpath
index 2e50684..fac25bb 100644
--- a/ide/eclipse/.classpath
+++ b/ide/eclipse/.classpath
@@ -61,6 +61,8 @@
 	<classpathentry kind="src" path="frameworks/ex/common/java"/>
 	<classpathentry kind="src" path="frameworks/ex/variablespeed/src"/>
 	<classpathentry kind="src" path="frameworks/opt/calendar/src"/>
+	<classpathentry kind="src" path="frameworks/opt/telephony/src/java"/>
+	<classpathentry kind="src" path="frameworks/opt/mms/src/java"/>
 	<classpathentry kind="src" path="frameworks/opt/vcard/java"/>
 	<classpathentry kind="src" path="frameworks/support/v13/java"/>
 	<classpathentry kind="src" path="frameworks/support/v13/ics"/>
@@ -102,6 +104,7 @@
 	<classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/voip/java"/>
 	<classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/wifi/java"/>
 	<classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/services_intermediates/src"/>
+	<classpathentry kind="src" path="out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/src/src/java"/>
 	<classpathentry kind="src" path="out/target/common/R"/>
 	<classpathentry kind="src" path="external/apache-http/src"/>
 	<classpathentry kind="src" path="external/bouncycastle/src/main/java"/>
@@ -112,8 +115,8 @@
 	<classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes-jarjar.jar"/>
 	<classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/javalib.jar"/>
 	<classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar"/>
-	<classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar"/>
-	<classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar"/>
+	<classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib.jar"/>
+	<classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar"/>
 	<classpathentry kind="lib" path="out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.jar"/>
 	<classpathentry kind="lib" path="packages/apps/Calculator/arity-2.1.2.jar"/>
 	<classpathentry kind="output" path="out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes"/>
diff --git a/ndk/Android.mk b/ndk/Android.mk
index 0c7e190..e7d9fe9 100644
--- a/ndk/Android.mk
+++ b/ndk/Android.mk
@@ -1 +1,3 @@
 # Please this file empty. It is used to make the Android build system happy.
+
+include development/ndk/sources/android/libportable/Android.mk
diff --git a/ndk/platforms/README.CRT.TXT b/ndk/platforms/README.CRT.TXT
new file mode 100644
index 0000000..c7b2c41
--- /dev/null
+++ b/ndk/platforms/README.CRT.TXT
@@ -0,0 +1,274 @@
+This directory contains the sources of the C runtime object files
+required by the Android NDK toolchains. This document explains
+what they are, as well as a few important details about them.
+
+The files are located under the following directories:
+
+  android-3/arch-arm/src/
+  android-9/arch-x86/src/
+  android-9/arch-mips/src/
+
+They are either C files, or assembly files with an .S extension, which means
+that they'll be sent to the C-preprocessor before being assembled into
+object files. They have the following names and usage:
+
+  crtbegin_static.[cS]
+    This file contains a tiny ELF startup entry point (named '_start')
+    that is linked into every Android _static_ executable. These binaries can
+    run on any Linux ARM system, but cannot perform dynamic linking at all.
+
+    Note that the kernel calls the '_start' entry point directly when it
+    launches such an executable. The _start stub is used to call the
+    C library's runtime initialization, passing it the address of the
+    'main' function.
+
+  crtbegin_dynamic.[cS]
+    This is equivalent to crtbegin_static.[cS] but for _dynamic_ executables.
+    These executables always link to the system C library dynamically.
+
+    When the kernel launches such an executable, it actually starts the
+    dynamic linker (/system/bin/linker), which loads and relocates the
+    executable (possibly loading any dependent system libraries as well),
+    then call the _start stub.
+
+  crtbegin_so.[cS]
+    This is equivalent to crtbegin_dynamic.[cS], but shall be used for
+    shared libraries. One major difference is that there is no _start
+    entry point.
+
+  crtend_android.S
+    This source file shall be used when generating an executable, i.e. used
+    in association with either crtbegin_static.[cS] or crtbegin_dynamic.[cS]
+
+  crtend.S
+    This source file is _strictly_ equivalent to crtend_android.S.
+    Actually, it *must* be compiled into an object named 'crtend_android.o'
+    because that's the hard-coded name that the toolchain binaries expect.
+
+    (the naming difference for this source file is purely historical, it
+    could probably be removed in the future).
+
+  crtend_so.S
+    This source's object file shall be used when generating a shared library,
+    i.e. used in association with crtbegin_so.[cS] only.
+
+Content of these files:
+
+ELF section (lists);
+
+  crtbegin_static.[cS] and crtbegin_dynamic.[cS] contain a '_start' entry point
+  for the corresponding executable. crtbegin_so.[cS] doesn't need any.
+
+  all crtbegin_XXX.[cS] files contain the head of various ELF sections, which are
+  used to list of ELF constructors and destructors. The sections are:
+
+    .init_array:
+        Contains a list of function addresses that are run at load time.
+        This means they are run *before* 'main', in the case of executables,
+        or during 'dlopen()' for shared libraries (either implicit or explicit).
+
+        The functions are called in list order (from first to last).
+
+    .fini_array:
+        Contains a list of destructor addresses that are run at unload time.
+        This means they are run *after* 'exit', in the case of executables,
+        or during 'dlclose()' for shared libraries (either implicit or explicit).
+
+        The functions are called in _reverse_ list order (from last to first).
+
+    .preinit_array:
+        This section can *only* appear in executables. It contains a list of
+        constructors that are run _before_ the ones in .init_array, or those
+        of any dependent shared library (if any).
+
+    .ctors
+        This section shall *not* be used on Android. Used on some GLibc-based
+        Linux systems to hold list of constructors. The toolchains should
+        place all constructors in .init_array instead.
+
+    .dtors
+        This section shall *not* be used on Android. Used on some GLibc-based
+        Linux systems to hold a list of destructors. The toolchains should
+        place all destructors in .fini_array instead.
+
+
+__dso_handle symbol:
+
+  To properly support the C++ ABI, a unique *local* *hidden* symbol named
+  '__dso_handle' must be defined in each shared library.
+
+  This is used to implement static C++ object initialization in a shared
+  library, as in:
+
+      static Foo  foo(10);
+
+  The statement above creates a hidden function, which address will be added
+  to the .init_array section described above. Its compiler-generated code
+  will perform the object construction, and also register static destructor
+  using a call that looks like:
+
+      __cxa_atexit( Foo::~Foo, &foo, &__dso_handle );
+
+  Where '__cxa_atexit' is a special C++ support function provided by the
+  C library. Doing this ensures that the destructor for 'foo' will be
+  automatically called when the shared library containing this code is
+  unloaded (i.e. either through 'dlclose' or at program exit).
+
+  The value of __dso_handle is normally never taken directly.
+
+  See http://sourcery.mentor.com/public/cxx-abi/abi.html#dso-dtor
+
+  WARNING: There is a big caveat regarding this symbol. Read the section
+           named 'IMPORTANT BACKWARDS COMPATIBILITY ISSUES' below.
+
+
+atexit() implementation:
+
+  The Posix standard doesn't mandate the program behaviour's when a shared
+  library which registered a function with 'atexit' is unloaded explicitely
+  (e.g. with 'dlclose()').
+
+  On most BSD systems (including OS X), unloading the library succeeds, but
+  the program will crash when it calls exit() or returns from main().
+
+  On Linux, GLibc provides an implementation that automatically unregisters
+  such atexit() handlers when the corresponding shared library is unloaded.
+
+  However, this requires that the atexit() implementation be part of the
+  shared library itself, rather than the C library.
+
+  The crtbegin_dynamic.[cS] and crtbegin_so.[cS] files contain an tiny
+  implementation of atexit() in assembler that essentially does:
+
+      void atexit(void(*myfunc)(void))
+      {
+         __cxa_atexit(myfunc, NULL, &__dso_handle);
+      }
+
+  Because it references the shared library's hidden __dso_handle symbol,
+  this code cannot be in the C library itself.
+
+  Note that crtbegin_static.[cS] should *not* provide an atexit() function
+  (the latter should be provided by libc.a instead).
+
+  See 'BACKWARDS COMPATIBILITY ISSUES' section below.
+
+
+
+BACKWARDS COMPATIBILITY ISSUES:
+-------------------------------
+
+To maintain binary compatibility to all existing NDK-generated machine code,
+the system's C library (i.e. /system/lib/libc.so) needs to exports symbols
+that shall *not* be exported by the NDK-provided link-time libraries (i.e.
+$NDK/platforms/android-$LEVEL/arch-$ARCH/usr/lib/libc.so).
+
+Starting from NDK r7, the NDK libc.so is itself generated by a script
+(gen-platforms.sh) from a list of symbol files (see libc.so.functions.txt
+and libc.so.variables.txt) and does not contain any implementation code.
+
+The NDK libc.a, on the other hand, is a copy of a given version of the system
+C static library, and shall only be used to generate static executables (it
+is also required to build gdbserver).
+
+1. libgcc compatibility symbols:
+
+  None of the link-time NDK shared libraries should export any libgcc symbol.
+
+  However, on ARM, the system C library needs to export some of them to
+  maintain binary compatibility with 'legacy' NDK machine code. Details are
+  under bionic/libc/arch-arm/bionic/libgcc_compat.c.
+
+  Note that gen-platforms.sh takes care of this by explicitely removing any
+  libgcc symbol from the link-time shared libraries it generates. This is done
+  by using the lists under:
+
+     $NDK/build/tools/unwanted-symbols/$ARCH/libgcc.a.functions.txt
+
+  You will need to update these files when the toolchain changes.
+
+  Note that all libgcc releases should be backwards-compatible, i.e. newer
+  releases always contain all the symbols from previous ones).
+
+
+2. __dso_handle compatibility symbol:
+
+  Earlier versions of the C library exported a __dso_handle symbol
+  *incorrectly*. As such:
+
+   - the system's libc.so shall always export its __dso_handle, as *global*
+     and *public* (in ELF visibility terms). A weak symbol definition is ok
+     but not necessary. This is only to ensure binary compatibility with
+    'legacy' NDK machine code.
+
+   - the NDK link-time libc.so shall *never* export or contain any
+     __dso_handle symbol.
+
+   - The NDK's crtbegin_dynamic.[cS] and crtbegin_so.[cS] shall provide a *local*
+     and *hidden* __dso_handle symbol.
+
+   - The NDK's libc.a will containg a *global* and *public* __dso_handle, since
+     it is a copy of a release-specific system libc.so.
+
+   - crtbegin_static.[cS] shall not provide any __dso_handle symbol, since static
+     executables will use the one in libc.a instead.
+
+Note that existing NDK machine code that links against the system libc's
+__dso_handle will not have their C++ destructors run correctly when the
+library is unloaded. However, this bug can be solved by simply recompiling
+/relinking against a newer NDK release, without touching the original
+sources.
+
+
+
+3. atexit compatibility symbol:
+
+  Earlier versions of the C library implemented and exported an atexit()
+  function. While this is compliant with Posix, this doesn't allow a useful
+  GLibc extension which automatically un-registers atexit() handlers when
+  a shared library is unloaded with dlclose().
+
+  To support this, while providing binary compatibility, the following
+  must apply:
+
+  - The platform's /system/lib/libc.so should *always* export a working
+    atexit() implementation (used by 'legacy' NDK machine code).
+
+  - The NDK link-time libc.so should *never* export atexit()
+
+  - crtbegin_dynamic.[cS] and crtbegin_so.[cS] shall define a *local* *hidden*
+    symbol for atexit(), with a tiny implementation that amounts to the
+    following code:
+
+         void atexit( void(*handler)(void) )
+         {
+            __cxa_atexit( handler, NULL, &__dso_handle );
+         }
+
+  - The NDK libc.a shall provide an atexit() implementation, and
+    crtbegin_static.[cS] shall *not* provide one to avoid conflicts.
+
+Note that existing NDK machine code that links against the system libc's
+atexit symbol will not have their atexit-handler automatically unregistered
+when the library is unloaded. However, this bug can be solved by simply
+recompiling/relinking against a newer NDK release, without touching the
+original sources.
+
+4. __atomic_xxx sompatibility symbols:
+
+This issues is detailed in ndk/docs/ANDROID-ATOMICS.html and
+bionic/libc/arch-arm/bionic/atomics_arm.c. In a nutshell:
+
+   - The system C library *shall* always export on *ARM* the __atomic_cmpxchg,
+     __atomic_inc and __atomic_dec functions to support legacy NDK machine code.
+     Their implementation should have full (i.e. acquire+release) memory ordering
+     semantics.
+
+   - The system C library for other CPU architectures (e.g. x86 or mips) *shall*
+     *not* export any of these symbols.
+
+   - The NDK libc.so *shall* *not* export these symbols at all.
+
+   - The NDK <sys/atomics.h> header shall provide inlined-static versions of
+     these functions that use the built-in GCC atomic functions instead.
+    
diff --git a/ndk/platforms/android-3/arch-arm/include/fenv.h b/ndk/platforms/android-3/arch-arm/include/fenv.h
index e7a8860..534b12c 100644
--- a/ndk/platforms/android-3/arch-arm/include/fenv.h
+++ b/ndk/platforms/android-3/arch-arm/include/fenv.h
@@ -29,10 +29,12 @@
 #ifndef	_FENV_H_
 #define	_FENV_H_
 
-#include <sys/_types.h>
+#include <sys/types.h>
 
-typedef	__uint32_t	fenv_t;
-typedef	__uint32_t	fexcept_t;
+__BEGIN_DECLS
+
+typedef	uint32_t	fenv_t;
+typedef	uint32_t	fexcept_t;
 
 /* Exception flags */
 #define	FE_INVALID	0x0001
@@ -50,7 +52,6 @@
 #define	FE_DOWNWARD	0x0003
 #define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
 			 FE_UPWARD | FE_TOWARDZERO)
-__BEGIN_DECLS
 
 /* Default floating-point environment */
 extern const fenv_t	__fe_dfl_env;
diff --git a/ndk/platforms/android-3/arch-arm/include/machine/_types.h b/ndk/platforms/android-3/arch-arm/include/machine/_types.h
index 6d10e12..3e779ca 100644
--- a/ndk/platforms/android-3/arch-arm/include/machine/_types.h
+++ b/ndk/platforms/android-3/arch-arm/include/machine/_types.h
@@ -46,8 +46,6 @@
 typedef long           ptrdiff_t;
 #endif
 
-//#include <linux/types.h>
-
 /* 7.18.1.1 Exact-width integer types */
 typedef	__signed char		__int8_t;
 typedef	unsigned char		__uint8_t;
diff --git a/ndk/platforms/android-3/arch-arm/include/machine/asm.h b/ndk/platforms/android-3/arch-arm/include/machine/asm.h
index c7bd017..047e54d 100644
--- a/ndk/platforms/android-3/arch-arm/include/machine/asm.h
+++ b/ndk/platforms/android-3/arch-arm/include/machine/asm.h
@@ -70,7 +70,13 @@
 #define _ASM_TYPE_FUNCTION	#function
 #define _ASM_TYPE_OBJECT	#object
 #define _ENTRY(x) \
-	.text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
+	.text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: .fnstart
+
+#define _ASM_SIZE(x)	.size x, .-x;
+
+#define _END(x) \
+	.fnend; \
+	_ASM_SIZE(x)
 
 #ifdef GPROF
 # ifdef __ELF__
@@ -86,8 +92,16 @@
 
 #define	ENTRY(y)	_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
 #define	ENTRY_NP(y)	_ENTRY(_C_LABEL(y))
+#define	END(y)		_END(_C_LABEL(y))
 #define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
 #define	ASENTRY_NP(y)	_ENTRY(_ASM_LABEL(y))
+#define	ASEND(y)	_END(_ASM_LABEL(y))
+
+#ifdef __ELF__
+#define ENTRY_PRIVATE(y)  ENTRY(y); .hidden _C_LABEL(y)
+#else
+#define ENTRY_PRIVATE(y)  ENTRY(y)
+#endif
 
 #define	ASMSTR		.asciz
 
diff --git a/ndk/platforms/android-3/arch-arm/include/machine/cpu-features.h b/ndk/platforms/android-3/arch-arm/include/machine/cpu-features.h
index f836006..80d3fda 100644
--- a/ndk/platforms/android-3/arch-arm/include/machine/cpu-features.h
+++ b/ndk/platforms/android-3/arch-arm/include/machine/cpu-features.h
@@ -38,7 +38,7 @@
  * IMPORTANT: We have no intention to support anything below an ARMv4T !
  */
 
-/* _ARM_ARCH_REVISION is a number corresponding to the ARM revision
+/* __ARM_ARCH__ is a number corresponding to the ARM revision
  * we're going to support
  *
  * it looks like our toolchain doesn't define __ARM_ARCH__
@@ -142,15 +142,50 @@
  *
  *     ldr  pc, [<some address>]
  *
- * note that this affects any instruction that explicitely changes the
+ * note that this affects any instruction that explicitly changes the
  * value of the pc register, including ldm { ...,pc } or 'add pc, #offset'
  */
 #if __ARM_ARCH__ >= 5
 #  define __ARM_HAVE_PC_INTERWORK
 #endif
 
+/* define __ARM_HAVE_LDREX_STREX for ARMv6 and ARMv7 architecture to be
+ * used in replacement of deprecated swp instruction
+ */
+#if __ARM_ARCH__ >= 6
+#  define __ARM_HAVE_LDREX_STREX
+#endif
+
+/* define __ARM_HAVE_DMB for ARMv7 architecture
+ */
+#if __ARM_ARCH__ >= 7
+#  define __ARM_HAVE_DMB
+#endif
+
+/* define __ARM_HAVE_LDREXD for ARMv7 architecture
+ * (also present in ARMv6K, but not implemented in ARMv7-M, neither of which
+ * we care about)
+ */
+#if __ARM_ARCH__ >= 7
+#  define __ARM_HAVE_LDREXD
+#endif
+
+/* define _ARM_HAVE_VFP if we have VFPv3
+ */
+#if __ARM_ARCH__ >= 7 && defined __VFP_FP__
+#  define __ARM_HAVE_VFP
+#endif
+
+/* define _ARM_HAVE_NEON for ARMv7 architecture if we support the
+ * Neon SIMD instruction set extensions. This also implies
+ * that VFPv3-D32 is supported.
+ */
+#if __ARM_ARCH__ >= 7 && defined __ARM_NEON__
+#  define __ARM_HAVE_NEON
+#endif
 
 /* Assembly-only macros */
+#ifdef __ASSEMBLY__
 
 /* define a handy PLD(address) macro since the cache preload
  * is an optional opcode
@@ -161,4 +196,6 @@
 #  define  PLD(reg,offset)    /* nothing */
 #endif
 
+#endif /* ! __ASSEMBLY__ */
+
 #endif /* _ARM_MACHINE_CPU_FEATURES_H */
diff --git a/ndk/platforms/android-3/arch-arm/include/machine/setjmp.h b/ndk/platforms/android-3/arch-arm/include/machine/setjmp.h
index f20cab2..0941202 100644
--- a/ndk/platforms/android-3/arch-arm/include/machine/setjmp.h
+++ b/ndk/platforms/android-3/arch-arm/include/machine/setjmp.h
@@ -1,87 +1,82 @@
-/*	$OpenBSD: setjmp.h,v 1.1 2004/02/01 05:09:49 drahn Exp $	*/
-/*	$NetBSD: setjmp.h,v 1.2 2001/08/25 14:45:59 bjh21 Exp $	*/
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 /*
  * machine/setjmp.h: machine dependent setjmp-related information.
  */
 
-#ifdef __ELF__
-#define	_JBLEN	64		/* size, in longs, of a jmp_buf */
-#else
-#define	_JBLEN	29		/* size, in longs, of a jmp_buf */
-#endif
-
-/*
- * NOTE: The internal structure of a jmp_buf is *PRIVATE*
- *       This information is provided as there is software
- *       that fiddles with this with obtain the stack pointer
- *	 (yes really ! and its commercial !).
+/* _JBLEN is the size of a jmp_buf in longs.
+ * Do not modify this value or you will break the ABI !
  *
- * Description of the setjmp buffer
- *
- * word  0	magic number	(dependant on creator)
- *       1 -  3	f4		fp register 4
- *	 4 -  6	f5		fp register 5
- *	 7 -  9 f6		fp register 6
- *	10 - 12	f7		fp register 7
- *	13	fpsr		fp status register
- *	14	r4		register 4
- *	15	r5		register 5
- *	16	r6		register 6
- *	17	r7		register 7
- *	18	r8		register 8
- *	19	r9		register 9
- *	20	r10		register 10 (sl)
- *	21	r11		register 11 (fp)
- *	22	r12		register 12 (ip)
- *	23	r13		register 13 (sp)
- *	24	r14		register 14 (lr)
- *	25	signal mask	(dependant on magic)
- *	26	(con't)
- *	27	(con't)
- *	28	(con't)
- *
- * The magic number number identifies the jmp_buf and
- * how the buffer was created as well as providing
- * a sanity check
- *
- * A side note I should mention - Please do not tamper
- * with the floating point fields. While they are
- * always saved and restored at the moment this cannot
- * be garenteed especially if the compiler happens
- * to be generating soft-float code so no fp
- * registers will be used.
- *
- * Whilst this can be seen an encouraging people to
- * use the setjmp buffer in this way I think that it
- * is for the best then if changes occur compiles will
- * break rather than just having new builds falling over
- * mysteriously.
+ * This value comes from the original OpenBSD ARM-specific header
+ * that was replaced by this one.
  */
+#define _JBLEN  64
+
+/* According to the ARM AAPCS document, we only need to save
+ * the following registers:
+ *
+ *  Core   r4-r14
+ *
+ *  VFP    d8-d15  (see section 5.1.2.1)
+ *
+ *      Registers s16-s31 (d8-d15, q4-q7) must be preserved across subroutine
+ *      calls; registers s0-s15 (d0-d7, q0-q3) do not need to be preserved
+ *      (and can be used for passing arguments or returning results in standard
+ *      procedure-call variants). Registers d16-d31 (q8-q15), if present, do
+ *      not need to be preserved.
+ *
+ *  FPSCR  saved because GLibc does saves it too.
+ *
+ */
+
+/* The internal structure of a jmp_buf is totally private.
+ * Current layout (may change in the future):
+ *
+ * word   name         description
+ * 0      magic        magic number
+ * 1      sigmask      signal mask (not used with _setjmp / _longjmp)
+ * 2      float_base   base of float registers (d8 to d15)
+ * 18     float_state  floating-point status and control register
+ * 19     core_base    base of core registers (r4 to r14)
+ * 30     reserved     reserved entries (room to grow)
+ * 64
+ *
+ * NOTE: float_base must be at an even word index, since the
+ *       FP registers will be loaded/stored with instructions
+ *       that expect 8-byte alignment.
+ */
+
+#define _JB_MAGIC       0
+#define _JB_SIGMASK     (_JB_MAGIC+1)
+#define _JB_FLOAT_BASE  (_JB_SIGMASK+1)
+#define _JB_FLOAT_STATE (_JB_FLOAT_BASE + (15-8+1)*2)
+#define _JB_CORE_BASE   (_JB_FLOAT_STATE+1)
 
 #define _JB_MAGIC__SETJMP	0x4278f500
 #define _JB_MAGIC_SETJMP	0x4278f501
-
-/* Valid for all jmp_buf's */
-
-#define _JB_MAGIC		 0
-#define _JB_REG_F4		 1
-#define _JB_REG_F5		 4
-#define _JB_REG_F6		 7
-#define _JB_REG_F7		10
-#define _JB_REG_FPSR		13
-#define _JB_REG_R4		14
-#define _JB_REG_R5		15
-#define _JB_REG_R6		16
-#define _JB_REG_R7		17
-#define _JB_REG_R8		18
-#define _JB_REG_R9		19
-#define _JB_REG_R10		20
-#define _JB_REG_R11		21
-#define _JB_REG_R12		22
-#define _JB_REG_R13		23
-#define _JB_REG_R14		24
-
-/* Only valid with the _JB_MAGIC_SETJMP magic */
-
-#define _JB_SIGMASK		25
diff --git a/ndk/platforms/android-3/arch-arm/lib/crtbegin_dynamic.o b/ndk/platforms/android-3/arch-arm/lib/crtbegin_dynamic.o
deleted file mode 100644
index f34cba8..0000000
--- a/ndk/platforms/android-3/arch-arm/lib/crtbegin_dynamic.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/lib/crtbegin_so.o b/ndk/platforms/android-3/arch-arm/lib/crtbegin_so.o
deleted file mode 100644
index 5230178..0000000
--- a/ndk/platforms/android-3/arch-arm/lib/crtbegin_so.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/lib/crtbegin_static.o b/ndk/platforms/android-3/arch-arm/lib/crtbegin_static.o
deleted file mode 100644
index f34cba8..0000000
--- a/ndk/platforms/android-3/arch-arm/lib/crtbegin_static.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/lib/crtend_android.o b/ndk/platforms/android-3/arch-arm/lib/crtend_android.o
deleted file mode 100644
index c57149e..0000000
--- a/ndk/platforms/android-3/arch-arm/lib/crtend_android.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/lib/crtend_so.o b/ndk/platforms/android-3/arch-arm/lib/crtend_so.o
deleted file mode 100644
index c54db97..0000000
--- a/ndk/platforms/android-3/arch-arm/lib/crtend_so.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/src/__dso_handle.h b/ndk/platforms/android-3/arch-arm/src/__dso_handle.h
new file mode 100644
index 0000000..3b56eba
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/src/__dso_handle.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* The __dso_handle global variable is used by static
+   C++ constructors and destructors in the binary.
+   See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
+
+   CRT_LEGACY_WORKAROUND is only defined when building this file
+   for the C library. This forces __dso_handle to be exported by
+   it. This is only required to ensure binary compatibility with
+   old NDK application machine code that contains reference to
+   the symbol, but do not have a proper definition for it.
+
+   These binaries cannot call their destructorson dlclose(), but
+   at least they will not fail to load.
+
+   When this file is built for the NDK, CRT_LEGACY_WORKAROUND
+   should never be defined.
+ */
+
+#ifndef CRT_LEGACY_WORKAROUND
+__attribute__ ((visibility ("hidden")))
+#endif
+__attribute__ ((section (".bss")))
+void *__dso_handle = (void *) 0;
diff --git a/ndk/platforms/android-3/arch-arm/src/__dso_handle_so.h b/ndk/platforms/android-3/arch-arm/src/__dso_handle_so.h
new file mode 100644
index 0000000..bd8b378
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/src/__dso_handle_so.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* The __dso_handle global variable is used by static
+   C++ constructors and destructors in the binary.
+   See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
+*/
+
+__attribute__ ((visibility ("hidden")))
+__attribute__ ((section (".data")))
+void *__dso_handle;
diff --git a/ndk/platforms/android-3/arch-arm/src/atexit.h b/ndk/platforms/android-3/arch-arm/src/atexit.h
new file mode 100644
index 0000000..bc776a8
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/src/atexit.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+extern void *__dso_handle;
+
+__attribute__ ((visibility ("hidden")))
+int atexit(void (*func)(void))
+{
+  return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
+}
diff --git a/ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.c b/ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.c
new file mode 100644
index 0000000..edb417d
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+typedef struct
+{
+    void (**preinit_array)(void);
+    void (**init_array)(void);
+    void (**fini_array)(void);
+    void (**ctor_list)(void);
+} structors_array_t;
+
+extern int main(int argc, char **argv, char **env);
+
+extern void __libc_init(
+  unsigned int *elfdata,
+  void (*onexit)(void),
+  int (*slingshot)(int, char**, char**),
+  structors_array_t const * const structors
+);
+
+__attribute__ ((section (".preinit_array")))
+void (*__PREINIT_ARRAY__)(void) = (void (*)(void)) -1;
+
+__attribute__ ((section (".init_array")))
+void (*__INIT_ARRAY__)(void) = (void (*)(void)) -1;
+
+__attribute__ ((section (".fini_array")))
+void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
+
+__attribute__ ((section (".ctors")))
+void (*__CTOR_LIST__)(void) = (void (*)(void)) -1;
+
+/* this is the small startup code that is first run when
+   any executable that is dynamically-linked with Bionic
+   runs.
+
+   it's purpose is to call __libc_init with appropriate
+   arguments, which are:
+
+    - the address of the raw data block setup by the Linux
+      kernel ELF loader
+
+    - address of an "onexit" function, not used on any
+      platform supported by Bionic
+
+    - address of the "main" function of the program.
+
+    - address of the constructor list
+*/
+
+__attribute__((visibility("hidden")))
+void _start() {
+  structors_array_t array;
+  void *elfdata;
+
+  array.preinit_array = &__PREINIT_ARRAY__;
+  array.init_array =    &__INIT_ARRAY__;
+  array.fini_array =    &__FINI_ARRAY__;
+  array.ctor_list =    &__CTOR_LIST__;
+
+  elfdata = __builtin_frame_address(0) + sizeof(void *);
+  __libc_init(elfdata, (void *) 0, &main, &array);
+}
+
+#include "__dso_handle.h"
+#include "atexit.h"
diff --git a/ndk/platforms/android-3/arch-arm/src/crtbegin_so.c b/ndk/platforms/android-3/arch-arm/src/crtbegin_so.c
new file mode 100644
index 0000000..cd0257a
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/src/crtbegin_so.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+extern void __cxa_finalize(void *);
+extern void *__dso_handle;
+
+__attribute__((visibility("hidden"),destructor))
+void __on_dlclose() {
+  __cxa_finalize(&__dso_handle);
+}
+
+/* CRT_LEGACY_WORKAROUND should only be defined when building
+ * this file as part of the platform's C library.
+ *
+ * The C library already defines a function named 'atexit()'
+ * for backwards compatibility with older NDK-generated binaries.
+ *
+ * For newer ones, 'atexit' is actually embedded in the C
+ * runtime objects that are linked into the final ELF
+ * binary (shared library or executable), and will call
+ * __cxa_atexit() in order to un-register any atexit()
+ * handler when a library is unloaded.
+ *
+ * This function must be global *and* hidden. Only the
+ * code inside the same ELF binary should be able to access it.
+ */
+
+#ifdef CRT_LEGACY_WORKAROUND
+#include "__dso_handle.h"
+#else
+#include "__dso_handle_so.h"
+#include "atexit.h"
+#endif
diff --git a/ndk/platforms/android-3/arch-arm/src/crtbegin_static.c b/ndk/platforms/android-3/arch-arm/src/crtbegin_static.c
new file mode 100644
index 0000000..0a72335
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/src/crtbegin_static.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+typedef struct
+{
+    void (**preinit_array)(void);
+    void (**init_array)(void);
+    void (**fini_array)(void);
+    void (**ctor_list)(void);
+} structors_array_t;
+
+extern int main(int argc, char **argv, char **env);
+
+extern void __libc_init(
+  unsigned int *elfdata,
+  void (*onexit)(void),
+  int (*slingshot)(int, char**, char**),
+  structors_array_t const * const structors
+);
+
+__attribute__ ((section (".preinit_array")))
+void (*__PREINIT_ARRAY__)(void) = (void (*)(void)) -1;
+
+__attribute__ ((section (".init_array")))
+void (*__INIT_ARRAY__)(void) = (void (*)(void)) -1;
+
+__attribute__ ((section (".fini_array")))
+void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
+
+__attribute__ ((section (".ctors")))
+void (*__CTOR_LIST__)(void) = (void (*)(void)) -1;
+
+/* this is the small startup code that is first run when
+   any executable that is statically-linked with Bionic
+   runs.
+
+   it's purpose is to call __libc_init with appropriate
+   arguments, which are:
+
+    - the address of the raw data block setup by the Linux
+      kernel ELF loader
+
+    - address of an "onexit" function, not used on any
+      platform supported by Bionic
+
+    - address of the "main" function of the program.
+
+    - address of the constructor list
+*/
+
+__attribute__((visibility("hidden")))
+void _start() {
+  structors_array_t array;
+  void *elfdata;
+
+  array.preinit_array = &__PREINIT_ARRAY__;
+  array.init_array =    &__INIT_ARRAY__;
+  array.fini_array =    &__FINI_ARRAY__;
+  array.ctor_list =    &__CTOR_LIST__;
+
+  elfdata = __builtin_frame_address(0) + sizeof(void *);
+  __libc_init(elfdata, (void *) 0, &main, &array);
+}
+
+#include "__dso_handle.h"
+/* NOTE: atexit() is  not be provided by crtbegin_static.c, but by libc.a */
diff --git a/ndk/platforms/android-3/arch-arm/src/crtend.S b/ndk/platforms/android-3/arch-arm/src/crtend.S
new file mode 100644
index 0000000..2f3b1ed
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/src/crtend.S
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+	
+	.section .preinit_array, "aw"
+	.long 0
+
+	.section .init_array, "aw"
+	.long 0
+
+	.section .fini_array, "aw"
+	.long 0
+
+	.section .ctors, "aw"
+	.long 0
+
diff --git a/ndk/platforms/android-3/arch-arm/src/crtend_so.S b/ndk/platforms/android-3/arch-arm/src/crtend_so.S
new file mode 100644
index 0000000..a1281c4
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/src/crtend_so.S
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* This is the same than crtend.S except that a shared library
+ * cannot have a .preinit_array
+ */
+	
+	.section .init_array, "aw"
+	.long 0
+
+	.section .fini_array, "aw"
+	.long 0
+
diff --git a/ndk/platforms/android-3/include/link.h b/ndk/platforms/android-3/include/link.h
new file mode 100644
index 0000000..842b448
--- /dev/null
+++ b/ndk/platforms/android-3/include/link.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _LINK_H_
+#define _LINK_H_
+
+#include <sys/types.h>
+#include <elf.h>
+
+__BEGIN_DECLS
+
+/* bionic is currently only 32-bit. */
+#define ElfW(type) Elf32_##type
+
+struct dl_phdr_info {
+  ElfW(Addr) dlpi_addr;
+  const char* dlpi_name;
+  const ElfW(Phdr)* dlpi_phdr;
+  ElfW(Half) dlpi_phnum;
+};
+
+#ifdef __arm__
+typedef long unsigned int* _Unwind_Ptr;
+_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount);
+#else
+int dl_iterate_phdr(int (*cb)(struct dl_phdr_info*, size_t, void*), void*);
+#endif
+
+__END_DECLS
+
+#endif /* _LINK_H_ */
diff --git a/ndk/platforms/android-3/include/malloc.h b/ndk/platforms/android-3/include/malloc.h
index a864286..ec21926 100644
--- a/ndk/platforms/android-3/include/malloc.h
+++ b/ndk/platforms/android-3/include/malloc.h
@@ -1,33 +1,27 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
+ * Copyright (C) 2012 The Android Open Source Project
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
+ * 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
  *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ *      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 _MALLOC_H_
-#define _MALLOC_H_
 
+#ifndef LIBC_INCLUDE_MALLOC_H_
+#define LIBC_INCLUDE_MALLOC_H_
+
+/*
+ * Declaration of malloc routines. Bionic uses dlmalloc (see
+ * upstream-dlmalloc) but doesn't directly include it here to keep the
+ * defined malloc.h interface small.
+ */
 #include <sys/cdefs.h>
 #include <stddef.h>
 
@@ -35,70 +29,33 @@
 
 extern __mallocfunc void*  malloc(size_t);
 extern __mallocfunc void*  calloc(size_t, size_t);
-extern __mallocfunc void*  realloc(void *, size_t);
-extern                void   free(void *);
+extern void*  realloc(void *, size_t);
+extern void   free(void *);
 
-extern void*   memalign(size_t  alignment, size_t  bytesize);
-extern void*   valloc(size_t  bytesize);
-extern void*   pvalloc(size_t  bytesize);
-extern int     mallopt(int  param_number, int  param_value);
-extern size_t  malloc_footprint(void);
-extern size_t  malloc_max_footprint(void);
+extern void*  memalign(size_t  alignment, size_t  bytesize);
+extern size_t malloc_usable_size(void*);
 
+extern void*  valloc(size_t  bytesize);
+extern void*  pvalloc(size_t bytesize);
+
+#ifndef STRUCT_MALLINFO_DECLARED
+#define STRUCT_MALLINFO_DECLARED 1
 struct mallinfo {
-    size_t arena;    /* non-mmapped space allocated from system */
-    size_t ordblks;  /* number of free chunks */
-    size_t smblks;   /* always 0 */
-    size_t hblks;    /* always 0 */
-    size_t hblkhd;   /* space in mmapped regions */
-    size_t usmblks;  /* maximum total allocated space */
-    size_t fsmblks;  /* always 0 */
-    size_t uordblks; /* total allocated space */
-    size_t fordblks; /* total free space */
-    size_t keepcost; /* releasable (via malloc_trim) space */
+  size_t arena;
+  size_t ordblks;
+  size_t smblks;
+  size_t hblks;
+  size_t hblkhd;
+  size_t usmblks;
+  size_t fsmblks;
+  size_t uordblks;
+  size_t fordblks;
+  size_t keepcost;
 };
+#endif  /* STRUCT_MALLINFO_DECLARED */
 
-extern struct mallinfo  mallinfo(void);
-
-
-/*
-  malloc_usable_size(void* p);
-
-  Returns the number of bytes you can actually use in
-  an allocated chunk, which may be more than you requested (although
-  often not) due to alignment and minimum size constraints.
-  You can use this many bytes without worrying about
-  overwriting other allocated objects. This is not a particularly great
-  programming practice. malloc_usable_size can be more useful in
-  debugging and assertions, for example:
-
-  p = malloc(n);
-  assert(malloc_usable_size(p) >= 256);
-*/
-extern size_t malloc_usable_size(void*  block);
-
-/*
-  malloc_stats();
-  Prints on stderr the amount of space obtained from the system (both
-  via sbrk and mmap), the maximum amount (which may be more than
-  current if malloc_trim and/or munmap got called), and the current
-  number of bytes allocated via malloc (or realloc, etc) but not yet
-  freed. Note that this is the number of bytes allocated, not the
-  number requested. It will be larger than the number requested
-  because of alignment and bookkeeping overhead. Because it includes
-  alignment wastage as being in use, this figure may be greater than
-  zero even when no user-level chunks are allocated.
-
-  The reported current and maximum system memory can be inaccurate if
-  a program makes other calls to system memory allocation functions
-  (normally sbrk) outside of malloc.
-
-  malloc_stats prints only the most commonly interesting statistics.
-  More information can be obtained by calling mallinfo.
-*/
-extern void  malloc_stats(void);
+extern struct mallinfo mallinfo(void);
 
 __END_DECLS
 
-#endif /* _MALLOC_H_ */
-
+#endif  /* LIBC_INCLUDE_MALLOC_H_ */
diff --git a/ndk/platforms/android-3/include/net/if_dl.h b/ndk/platforms/android-3/include/net/if_dl.h
deleted file mode 100644
index 1f0c080..0000000
--- a/ndk/platforms/android-3/include/net/if_dl.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*	$NetBSD: if_dl.h,v 1.18 2005/12/11 23:05:24 thorpej Exp $	*/
-
-/*
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)if_dl.h	8.1 (Berkeley) 6/10/93
- */
-
-/*
- * A Link-Level Sockaddr may specify the interface in one of two
- * ways: either by means of a system-provided index number (computed
- * anew and possibly differently on every reboot), or by a human-readable
- * string such as "il0" (for managerial convenience).
- *
- * Census taking actions, such as something akin to SIOCGCONF would return
- * both the index and the human name.
- *
- * High volume transactions (such as giving a link-level ``from'' address
- * in a recvfrom or recvmsg call) may be likely only to provide the indexed
- * form, (which requires fewer copy operations and less space).
- *
- * The form and interpretation  of the link-level address is purely a matter
- * of convention between the device driver and its consumers; however, it is
- * expected that all drivers for an interface of a given if_type will agree.
- */
-
-#ifndef _NET_IF_DL_H_
-#define _NET_IF_DL_H_
-
-#include <sys/socket.h>
-
-/*
- * Structure of a Link-Level sockaddr:
- */
-struct sockaddr_dl {
-	u_char	    sdl_len;	/* Total length of sockaddr */
-	sa_family_t sdl_family;	/* AF_LINK */
-	u_int16_t   sdl_index;	/* if != 0, system given index for interface */
-	u_char	    sdl_type;	/* interface type */
-	u_char	    sdl_nlen;	/* interface name length, no trailing 0 reqd. */
-	u_char	    sdl_alen;	/* link level address length */
-	u_char	    sdl_slen;	/* link layer selector length */
-	char	    sdl_data[12]; /* minimum work area, can be larger;
-				     contains both if name and ll address */
-};
-
-/* We do arithmetic directly with these, so keep them char instead of void */
-#define LLADDR(s) ((char *)((s)->sdl_data + (s)->sdl_nlen))
-#define CLLADDR(s) ((const char *)((s)->sdl_data + (s)->sdl_nlen))
-
-#ifndef _KERNEL
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-void	link_addr(const char *, struct sockaddr_dl *);
-char	*link_ntoa(const struct sockaddr_dl *);
-__END_DECLS
-
-#endif /* !_KERNEL */
-
-#endif /* !_NET_IF_DL_H_ */
diff --git a/ndk/platforms/android-3/include/stdint.h b/ndk/platforms/android-3/include/stdint.h
index e791475..49879cb 100644
--- a/ndk/platforms/android-3/include/stdint.h
+++ b/ndk/platforms/android-3/include/stdint.h
@@ -31,8 +31,6 @@
 #include <stddef.h>
 #include <sys/_types.h>
 
-
-
 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
 #  define __STDINT_LIMITS
 #endif
@@ -41,20 +39,14 @@
 #  define  __STDINT_MACROS
 #endif
 
-#if !defined __STRICT_ANSI__ || __STDC_VERSION__ >= 199901L
-#  define __STDC_INT64__
-#endif
-
 typedef __int8_t      int8_t;
 typedef __uint8_t     uint8_t;
 typedef __int16_t     int16_t;
 typedef __uint16_t    uint16_t;
 typedef __int32_t     int32_t;
 typedef __uint32_t    uint32_t;
-#if defined(__STDC_INT64__)
 typedef __int64_t     int64_t;
 typedef __uint64_t    uint64_t;
-#endif
 
 /*
  * int8_t & uint8_t
@@ -93,7 +85,6 @@
  * int16_t & uint16_t
  */
 
-
 typedef int16_t       int_least16_t;
 typedef int32_t       int_fast16_t;
 
@@ -156,17 +147,16 @@
 #  define UINT_FAST32_C(c) UINT32_C(c)
 #endif
 
-#if defined(__STDC_INT64__)
 /*
  *  int64_t
  */
+
 typedef int64_t       int_least64_t;
 typedef int64_t       int_fast64_t;
 
 typedef uint64_t      uint_least64_t;
 typedef uint64_t      uint_fast64_t;
 
-
 #ifdef __STDINT_LIMITS
 #  define INT64_MIN        (__INT64_C(-9223372036854775807)-1)
 #  define INT64_MAX        (__INT64_C(9223372036854775807))
@@ -193,13 +183,10 @@
 #  define UINT_FAST64_C(c)  UINT64_C(c)
 #endif
 
-
 #  define __PRI64_RANK   "ll"
 #  define __PRIFAST_RANK ""
 #  define __PRIPTR_RANK  ""
 
-#endif /* __STDC_INT64__ */
-
 /*
  * intptr_t & uintptr_t
  */
@@ -221,14 +208,10 @@
 #  define PTRDIFF_C(c)  INT32_C(c)
 #endif
 
-
-
 /*
  *  intmax_t & uintmax_t
  */
 
-#if defined(__STDC_INT64__)
-
 typedef uint64_t uintmax_t;
 typedef int64_t  intmax_t;
 
@@ -243,25 +226,6 @@
 #  define UINTMAX_C(c)	UINT64_C(c)
 #endif
 
-#else /* !__STDC_INT64__ */
-
-typedef uint32_t  uintmax_t;
-typedef int32_t   intmax_t;
-
-#ifdef __STDINT_LIMITS
-#  define  INTMAX_MIN    INT32_MIN
-#  define  INTMAX_MAX    INT32_MAX
-#  define  UINTMAX_MAX   UINT32_MAX
-#endif
-
-#ifdef __STDINT_MACROS
-#  define INTMAX_C(c)	INT32_C(c)
-#  define UINTMAX_C(c)	UINT32_C(c)
-#endif
-
-#endif /* !__STDC_INT64__ */
-
-
 /* size_t is defined by the GCC-specific <stddef.h> */
 #ifndef _SSIZE_T_DEFINED_
 #define _SSIZE_T_DEFINED_
diff --git a/ndk/platforms/android-3/include/sys/linux-unistd.h b/ndk/platforms/android-3/include/sys/linux-unistd.h
deleted file mode 100644
index 789271e..0000000
--- a/ndk/platforms/android-3/include/sys/linux-unistd.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/* auto-generated by gensyscalls.py, do not touch */
-#ifndef _BIONIC_LINUX_UNISTD_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void             _exit (int);
-void             _exit_thread (int);
-pid_t            __fork (void);
-pid_t            _waitpid (pid_t, int*, int, struct rusage*);
-int              waitid (int, pid_t, struct siginfo_t*, int,void*);
-pid_t            __clone (int (*fn)(void*), void *child_stack, int flags, void *arg);
-int              execve (const char*, char* const*, char* const*);
-int              setuid (uid_t);
-uid_t            getuid (void);
-gid_t            getgid (void);
-uid_t            geteuid (void);
-gid_t            getegid (void);
-uid_t            getresuid (void);
-gid_t            getresgid (void);
-pid_t            gettid (void);
-int              getgroups (int, gid_t *);
-pid_t            getpgid (pid_t);
-pid_t            getppid (void);
-pid_t            setsid (void);
-int              setgid (gid_t);
-int              seteuid (uid_t);
-int              setreuid (uid_t, uid_t);
-int              setresuid (uid_t, uid_t, uid_t);
-int              setresgid (gid_t, gid_t, gid_t);
-void*            __brk (void*);
-int              kill (pid_t, int);
-int              tkill (pid_t tid, int sig);
-int              __ptrace (int request, int pid, void* addr, void* data);
-int              __set_thread_area (void*  user_desc);
-int              __getpriority (int, int);
-int              setpriority (int, int, int);
-int              setrlimit (int resource, const struct rlimit *rlp);
-int              getrlimit (int resource, struct rlimit *rlp);
-int              getrusage (int who, struct rusage*  r_usage);
-int              setgroups (int, const gid_t *);
-pid_t            getpgrp (void);
-int              setpgid (pid_t, pid_t);
-pid_t            vfork (void);
-int              setregid (gid_t, gid_t);
-int              chroot (const char *);
-int              prctl (int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5);
-int              capget (cap_user_header_t header, cap_user_data_t data);
-int              capset (cap_user_header_t header, const cap_user_data_t data);
-int              acct (const char*  filepath);
-ssize_t          read (int, void*, size_t);
-ssize_t          write (int, const void*, size_t);
-ssize_t          __pread64 (int, void *, size_t, off_t, off_t);
-ssize_t          __pwrite64 (int, void *, size_t, off_t, off_t);
-int              __open (const char*, int, mode_t);
-int              __openat (int, const char*, int, mode_t);
-int              close (int);
-int              creat (const char*, mode_t);
-off_t            lseek (int, off_t, int);
-int              __llseek (int, unsigned long, unsigned long, loff_t*, int);
-pid_t            getpid (void);
-void *           mmap (void *, size_t, int, int, int, long);
-void *           __mmap2 (void*, size_t, int, int, int, long);
-int              munmap (void *, size_t);
-void *           mremap (void *, size_t, size_t, unsigned long);
-int              msync (const void *, size_t, int);
-int              mprotect (const void *, size_t, int);
-int              madvise (const void *, size_t, int);
-int              mlock (const void *addr, size_t len);
-int              munlock (const void *addr, size_t len);
-int              mincore (void*  start, size_t  length, unsigned char*  vec);
-int              __ioctl (int, int, void *);
-int              readv (int, const struct iovec *, int);
-int              writev (int, const struct iovec *, int);
-int              __fcntl (int, int, void*);
-int              flock (int, int);
-int              fchmod (int, mode_t);
-int              dup (int);
-int              pipe (int *);
-int              dup2 (int, int);
-int              select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
-int              ftruncate (int, off_t);
-int              getdents (unsigned int, struct dirent *, unsigned int);
-int              fsync (int);
-int              fchown (int, uid_t, gid_t);
-void             sync (void);
-int              __fcntl64 (int, int, void *);
-int              fstatfs (int, size_t, struct statfs *);
-ssize_t          sendfile (int out_fd, int in_fd, off_t *offset, size_t count);
-int              fstatat (int dirfd, const char *path, struct stat *buf, int flags);
-int              mkdirat (int dirfd, const char *pathname, mode_t mode);
-int              fchownat (int dirfd, const char *path, uid_t owner, gid_t group, int flags);
-int              fchmodat (int dirfd, const char *path, mode_t mode, int flags);
-int              renameat (int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
-int              link (const char*, const char*);
-int              unlink (const char*);
-int              unlinkat (int, const char *, int);
-int              chdir (const char*);
-int              mknod (const char*, mode_t, dev_t);
-int              chmod (const char*,mode_t);
-int              chown (const char *, uid_t, gid_t);
-int              lchown (const char*, uid_t, gid_t);
-int              mount (const char*, const char*, const char*, unsigned long, const void*);
-int              umount (const char*);
-int              umount2 (const char*, int);
-int              fstat (int, struct stat*);
-int              stat (const char *, struct stat *);
-int              lstat (const char *, struct stat *);
-int              mkdir (const char *, mode_t);
-int              readlink (const char *, char *, size_t);
-int              rmdir (const char *);
-int              rename (const char *, const char *);
-int              __getcwd (char * buf, size_t size);
-int              access (const char *, int);
-int              symlink (const char *, const char *);
-int              fchdir (int);
-int              truncate (const char*, off_t);
-int              __statfs64 (const char *, size_t, struct statfs *);
-int              pause (void);
-int              gettimeofday (struct timeval*, struct timezone*);
-int              settimeofday (const struct timeval*, const struct timezone*);
-clock_t          times (struct tms *);
-int              nanosleep (const struct timespec *, struct timespec *);
-int              clock_gettime (clockid_t clk_id, struct timespec *tp);
-int              clock_settime (clockid_t clk_id, const struct timespec *tp);
-int              clock_getres (clockid_t clk_id, struct timespec *res);
-int              clock_nanosleep (const struct timespec *req, struct timespec *rem);
-int              getitimer (int, const struct itimerval *);
-int              setitimer (int, const struct itimerval *, struct itimerval *);
-int              __timer_create (clockid_t clockid, struct sigevent *evp, timer_t *timerid);
-int              __timer_settime (timer_t, int, const struct itimerspec*, struct itimerspec*);
-int              __timer_gettime (timer_t, struct itimerspec*);
-int              __timer_getoverrun (timer_t);
-int              __timer_delete (timer_t);
-int              utimes (const char*, const struct timeval tvp[2]);
-int              sigaction (int, const struct sigaction *, struct sigaction *);
-int              sigprocmask (int, const sigset_t *, sigset_t *);
-int              __sigsuspend (int unused1, int unused2, unsigned mask);
-int              __rt_sigaction (int sig, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize);
-int              __rt_sigprocmask (int  how, const sigset_t *set, sigset_t *oset, size_t sigsetsize);
-int              __rt_sigtimedwait (const sigset_t *set, struct siginfo_t  *info, struct timespec_t  *timeout, size_t  sigset_size);
-int              sigpending (sigset_t *);
-int              socket (int, int, int);
-int              socketpair (int, int, int, int*);
-int              bind (int, struct sockaddr *, int);
-int              connect (int, struct sockaddr *, socklen_t);
-int              listen (int, int);
-int              accept (int, struct sockaddr *, socklen_t *);
-int              getsockname (int, struct sockaddr *, socklen_t *);
-int              getpeername (int, struct sockaddr *, socklen_t *);
-int              sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
-int              recvfrom (int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
-int              shutdown (int, int);
-int              setsockopt (int, int, int, const void *, socklen_t);
-int              getsockopt (int, int, int, void *, socklen_t *);
-int              sendmsg (int, const struct msghdr *, unsigned int);
-int              recvmsg (int, struct msghdr *, unsigned int);
-int              socket (int, int, int);
-int              bind (int, struct sockaddr *, int);
-int              connect (int, struct sockaddr *, socklen_t);
-int              listen (int, int);
-int              accept (int, struct sockaddr *, socklen_t *);
-int              getsockname (int, struct sockaddr *, socklen_t *);
-int              getpeername (int, struct sockaddr *, socklen_t *);
-int              socketpair (int, int, int, int*);
-int              sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
-int              recvfrom (int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
-int              shutdown (int, int);
-int              setsockopt (int, int, int, const void *, socklen_t);
-int              getsockopt (int, int, int, void *, socklen_t *);
-int              sendmsg (int, const struct msghdr *, unsigned int);
-int              recvmsg (int, struct msghdr *, unsigned int);
-int              sched_setscheduler (pid_t pid, int policy, const struct sched_param *param);
-int              sched_getscheduler (pid_t pid);
-int              sched_yield (void);
-int              sched_setparam (pid_t pid, const struct sched_param *param);
-int              sched_getparam (pid_t pid, struct sched_param *param);
-int              sched_get_priority_max (int policy);
-int              sched_get_priority_min (int policy);
-int              sched_rr_get_interval (pid_t pid, struct timespec *interval);
-int              uname (struct utsname *);
-pid_t            __wait4 (pid_t pid, int *status, int options, struct rusage *rusage);
-mode_t           umask (mode_t);
-int              __reboot (int, int, int, void *);
-int              __syslog (int, char *, int);
-int              init_module (void *, unsigned long, const char *);
-int              delete_module (const char*, unsigned int);
-int              klogctl (int, char *, int);
-int              futex (void *, int, int, void *, void *, int);
-int              epoll_create (int size);
-int              epoll_ctl (int epfd, int op, int fd, struct epoll_event *event);
-int              epoll_wait (int epfd, struct epoll_event *events, int max, int timeout);
-int              inotify_init (void);
-int              inotify_add_watch (int, const char *, unsigned int);
-int              inotify_rm_watch (int, unsigned int);
-int              poll (struct pollfd *, unsigned int, long);
-int              __set_tls (void*);
-int              cacheflush (long start, long end, long flags);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _BIONIC_LINUX_UNISTD_H_ */
diff --git a/ndk/platforms/android-5/samples/hello-gl2/default.properties b/ndk/platforms/android-5/samples/hello-gl2/default.properties
index dbf05f2..9d135cb 100644
--- a/ndk/platforms/android-5/samples/hello-gl2/default.properties
+++ b/ndk/platforms/android-5/samples/hello-gl2/default.properties
@@ -8,4 +8,4 @@
 # project structure.
 
 # Project target.
-target=android-5
+target=android-7
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/signal.h b/ndk/platforms/android-9/arch-mips/include/asm/signal.h
index b51ad71..5f5ac77 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/signal.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/signal.h
@@ -92,32 +92,33 @@
 #define MINSIGSTKSZ 2048
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SIGSTKSZ 8192
+struct siginfo;
 #define SIG_BLOCK 1  
 #define SIG_UNBLOCK 2  
-#define SIG_SETMASK 3  
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SIG_SETMASK 3  
 #include <asm-generic/signal.h>
 struct sigaction {
  unsigned int sa_flags;
- union {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ union {
  __sighandler_t sa_handler;
  void (*sa_sigaction) (int, struct siginfo *, void *);
  } __sigaction_handler;
-#define sa_handler __sigaction_handler.sa_handler
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define sa_handler __sigaction_handler.sa_handler
 #define sa_sigaction __sigaction_handler.sa_sigaction
  sigset_t sa_mask;
 };
-struct k_sigaction {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct k_sigaction {
  struct sigaction sa;
 };
 typedef struct sigaltstack {
- void *ss_sp;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ void *ss_sp;
  size_t ss_size;
  int ss_flags;
 } stack_t;
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/ndk/platforms/android-9/arch-mips/include/fenv.h b/ndk/platforms/android-9/arch-mips/include/fenv.h
new file mode 100644
index 0000000..583d002
--- /dev/null
+++ b/ndk/platforms/android-9/arch-mips/include/fenv.h
@@ -0,0 +1,220 @@
+/*-
+ * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/msun/mips/fenv.h,v 1.1 2008/04/26 12:20:29 imp Exp $
+ */
+
+#ifndef	_FENV_H_
+#define	_FENV_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+__BEGIN_DECLS
+
+typedef	__uint32_t	fenv_t;
+typedef	__uint32_t	fexcept_t;
+
+/* Exception flags */
+#define	FE_INVALID	0x0001
+#define	FE_DIVBYZERO	0x0002
+#define	FE_OVERFLOW	0x0004
+#define	FE_UNDERFLOW	0x0008
+#define	FE_INEXACT	0x0010
+#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
+			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+
+/* Rounding modes */
+#define	FE_TONEAREST	0x0000
+#define	FE_TOWARDZERO	0x0001
+#define	FE_UPWARD	0x0002
+#define	FE_DOWNWARD	0x0003
+#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
+			 FE_UPWARD | FE_TOWARDZERO)
+
+/* Default floating-point environment */
+extern const fenv_t	__fe_dfl_env;
+#define	FE_DFL_ENV	(&__fe_dfl_env)
+
+/* We need to be able to map status flag positions to mask flag positions */
+#define _FPUSW_SHIFT	16
+#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
+
+#ifdef	ARM_HARD_FLOAT
+#define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
+#define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
+#else
+#define __rfs(__fpsr)
+#define __wfs(__fpsr)
+#endif
+
+static __inline int
+feclearexcept(int __excepts)
+{
+	fexcept_t __fpsr;
+
+	__rfs(&__fpsr);
+	__fpsr &= ~__excepts;
+	__wfs(__fpsr);
+	return (0);
+}
+
+static __inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+	fexcept_t __fpsr;
+
+	__rfs(&__fpsr);
+	*__flagp = __fpsr & __excepts;
+	return (0);
+}
+
+static __inline int
+fesetexceptflag(const fexcept_t *__flagp, int __excepts)
+{
+	fexcept_t __fpsr;
+
+	__rfs(&__fpsr);
+	__fpsr &= ~__excepts;
+	__fpsr |= *__flagp & __excepts;
+	__wfs(__fpsr);
+	return (0);
+}
+
+static __inline int
+feraiseexcept(int __excepts)
+{
+	fexcept_t __ex = __excepts;
+
+	fesetexceptflag(&__ex, __excepts);	/* XXX */
+	return (0);
+}
+
+static __inline int
+fetestexcept(int __excepts)
+{
+	fexcept_t __fpsr;
+
+	__rfs(&__fpsr);
+	return (__fpsr & __excepts);
+}
+
+static __inline int
+fegetround(void)
+{
+
+	/*
+	 * Apparently, the rounding mode is specified as part of the
+	 * instruction format on ARM, so the dynamic rounding mode is
+	 * indeterminate.  Some FPUs may differ.
+	 */
+	return (-1);
+}
+
+static __inline int
+fesetround(int __round)
+{
+
+	return (-1);
+}
+
+static __inline int
+fegetenv(fenv_t *__envp)
+{
+
+	__rfs(__envp);
+	return (0);
+}
+
+static __inline int
+feholdexcept(fenv_t *__envp)
+{
+	fenv_t __env;
+
+	__rfs(&__env);
+	*__envp = __env;
+	__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
+	__wfs(__env);
+	return (0);
+}
+
+static __inline int
+fesetenv(const fenv_t *__envp)
+{
+
+	__wfs(*__envp);
+	return (0);
+}
+
+static __inline int
+feupdateenv(const fenv_t *__envp)
+{
+	fexcept_t __fpsr;
+
+	__rfs(&__fpsr);
+	__wfs(*__envp);
+	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
+	return (0);
+}
+
+#if __BSD_VISIBLE
+
+static __inline int
+feenableexcept(int __mask)
+{
+	fenv_t __old_fpsr, __new_fpsr;
+
+	__rfs(&__old_fpsr);
+	__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
+	__wfs(__new_fpsr);
+	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static __inline int
+fedisableexcept(int __mask)
+{
+	fenv_t __old_fpsr, __new_fpsr;
+
+	__rfs(&__old_fpsr);
+	__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+	__wfs(__new_fpsr);
+	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static __inline int
+fegetexcept(void)
+{
+	fenv_t __fpsr;
+
+	__rfs(&__fpsr);
+	return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
+}
+
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif	/* !_FENV_H_ */
+
diff --git a/ndk/platforms/android-9/arch-mips/include/link.h b/ndk/platforms/android-9/arch-mips/include/link.h
deleted file mode 100644
index 1c009c6..0000000
--- a/ndk/platforms/android-9/arch-mips/include/link.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* 
-   For building unwind-dw2-fde-glibc.c for MIPS frame unwinding,
-   we need to have <link.h> that defines struct dl_phdr_info,
-   ELFW(type), and dl_iterate_phdr().
-*/ 
-
-#include <sys/types.h>
-#include <elf.h>
-
-struct dl_phdr_info
-{
-    Elf32_Addr dlpi_addr;
-    const char *dlpi_name;
-    const Elf32_Phdr *dlpi_phdr;
-    Elf32_Half dlpi_phnum;
-};
-
-#if _MIPS_SZPTR == 32
-#define ElfW(type)	Elf32_##type
-#elif _MIPS_SZPTR == 64
-#define ElfW(type)	Elf64_##type
-#endif
-
-int
-dl_iterate_phdr(int (*cb)(struct dl_phdr_info *info, size_t size, void *data),
-                void *data);
diff --git a/ndk/platforms/android-9/arch-mips/include/machine/kernel.h b/ndk/platforms/android-9/arch-mips/include/machine/kernel.h
index 462b8e3..69ad40c 100644
--- a/ndk/platforms/android-9/arch-mips/include/machine/kernel.h
+++ b/ndk/platforms/android-9/arch-mips/include/machine/kernel.h
@@ -25,8 +25,8 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#ifndef _ARCH_ARM_KERNEL_H
-#define _ARCH_ARM_KERNEL_H
+#ifndef _ARCH_MIPS_KERNEL_H
+#define _ARCH_MIPS_KERNEL_H
 
 /* this file contains kernel-specific definitions that were optimized out of
    our processed kernel headers, but still useful nonetheless... */
@@ -39,4 +39,4 @@
 typedef unsigned long   __kernel_fsfilcnt_t;
 typedef unsigned int    __kernel_id_t;
 
-#endif /* _ARCH_ARM_KERNEL_H */
+#endif /* _ARCH_MIPS_KERNEL_H */
diff --git a/ndk/platforms/android-9/arch-mips/include/machine/signal.h b/ndk/platforms/android-9/arch-mips/include/machine/signal.h
index 96ebf76..4efb856 100644
--- a/ndk/platforms/android-9/arch-mips/include/machine/signal.h
+++ b/ndk/platforms/android-9/arch-mips/include/machine/signal.h
@@ -57,7 +57,7 @@
  * a non-standard exit is performed.
  */
 
-#if defined(ANDROID_CHANGES)
+#if defined(__ANDROID__)
 
 /*
  * The Linux and OpenBSD sigcontext structures are slightly different
@@ -104,7 +104,7 @@
 
 #else /* __LANGUAGE_ASSEMBLY */
 
-#ifdef ANDROID_CHANGES
+#ifdef __ANDROID__
 
 #define	SC_REGMASK	(0*REGSZ)
 #define	SC_STATUS	(1*REGSZ)
@@ -140,7 +140,7 @@
 #define	SC_FPUSED	(70 * REGSZ)
 #define	SC_FPC_EIR	(71 * REGSZ)
 
-#endif /*ANDROID CHANGES*/
+#endif /* __ANDROID__ */
 
 #endif /* __LANGUAGE_ASSEMBLY */
 
diff --git a/ndk/platforms/android-9/arch-mips/include/sys/linux-unistd.h b/ndk/platforms/android-9/arch-mips/include/sys/linux-unistd.h
deleted file mode 100644
index 2bb3c95..0000000
--- a/ndk/platforms/android-9/arch-mips/include/sys/linux-unistd.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/* auto-generated by gensyscalls.py, do not touch */
-#ifndef _BIONIC_LINUX_UNISTD_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void             _exit (int);
-void             _exit_thread (int);
-pid_t            __fork (void);
-pid_t            _waitpid (pid_t, int*, int, struct rusage*);
-int              __waitid (int, pid_t, struct siginfo_t*, int,void*);
-pid_t            __sys_clone (int, void*, int*, void*, int*);
-int              execve (const char*, char* const*, char* const*);
-int              __setuid (uid_t);
-int              __setuid (uid_t);
-uid_t            getuid (void);
-uid_t            getuid (void);
-gid_t            getgid (void);
-gid_t            getgid (void);
-uid_t            geteuid (void);
-uid_t            geteuid (void);
-gid_t            getegid (void);
-gid_t            getegid (void);
-uid_t            getresuid (void);
-uid_t            getresuid (void);
-gid_t            getresgid (void);
-gid_t            getresgid (void);
-pid_t            gettid (void);
-int              getgroups (int, gid_t *);
-int              getgroups (int, gid_t *);
-pid_t            getpgid (pid_t);
-pid_t            getppid (void);
-pid_t            setsid (void);
-int              setgid (gid_t);
-int              setgid (gid_t);
-int              seteuid (uid_t);
-int              __setreuid (uid_t, uid_t);
-int              __setreuid (uid_t, uid_t);
-int              __setresuid (uid_t, uid_t, uid_t);
-int              __setresuid (uid_t, uid_t, uid_t);
-int              setresgid (gid_t, gid_t, gid_t);
-int              setresgid (gid_t, gid_t, gid_t);
-void*            __brk (void*);
-int              kill (pid_t, int);
-int              tkill (pid_t tid, int sig);
-int              __ptrace (int request, int pid, void* addr, void* data);
-int              __set_thread_area (void*  user_desc);
-int              __getpriority (int, int);
-int              setpriority (int, int, int);
-int              setrlimit (int resource, const struct rlimit *rlp);
-int              getrlimit (int resource, struct rlimit *rlp);
-int              getrlimit (int resource, struct rlimit *rlp);
-int              getrusage (int who, struct rusage*  r_usage);
-int              setgroups (int, const gid_t *);
-int              setgroups (int, const gid_t *);
-pid_t            getpgrp (void);
-int              setpgid (pid_t, pid_t);
-pid_t            vfork (void);
-int              setregid (gid_t, gid_t);
-int              setregid (gid_t, gid_t);
-int              chroot (const char *);
-int              prctl (int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5);
-int              capget (cap_user_header_t header, cap_user_data_t data);
-int              capset (cap_user_header_t header, const cap_user_data_t data);
-int              sigaltstack (const stack_t*, stack_t*);
-int              acct (const char*  filepath);
-ssize_t          read (int, void*, size_t);
-ssize_t          write (int, const void*, size_t);
-ssize_t          pread64 (int, void *, size_t, off64_t);
-ssize_t          pwrite64 (int, void *, size_t, off64_t);
-int              __open (const char*, int, mode_t);
-int              __openat (int, const char*, int, mode_t);
-int              close (int);
-int              creat (const char*, mode_t);
-off_t            lseek (int, off_t, int);
-int              __llseek (int, unsigned long, unsigned long, loff_t*, int);
-pid_t            getpid (void);
-void *           mmap (void *, size_t, int, int, int, long);
-void *           __mmap2 (void*, size_t, int, int, int, long);
-int              munmap (void *, size_t);
-void *           mremap (void *, size_t, size_t, unsigned long);
-int              msync (const void *, size_t, int);
-int              mprotect (const void *, size_t, int);
-int              madvise (const void *, size_t, int);
-int              mlock (const void *addr, size_t len);
-int              munlock (const void *addr, size_t len);
-int              mincore (void*  start, size_t  length, unsigned char*  vec);
-int              __ioctl (int, int, void *);
-int              readv (int, const struct iovec *, int);
-int              writev (int, const struct iovec *, int);
-int              __fcntl (int, int, void*);
-int              flock (int, int);
-int              fchmod (int, mode_t);
-int              dup (int);
-int              pipe (int *);
-int              pipe2 (int *, int);
-int              dup2 (int, int);
-int              select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
-int              ftruncate (int, off_t);
-int              ftruncate64 (int, off64_t);
-int              getdents (unsigned int, struct dirent *, unsigned int);
-int              fsync (int);
-int              fdatasync (int);
-int              fchown (int, uid_t, gid_t);
-int              fchown (int, uid_t, gid_t);
-void             sync (void);
-int              __fcntl64 (int, int, void *);
-int              __fstatfs64 (int, size_t, struct statfs *);
-ssize_t          sendfile (int out_fd, int in_fd, off_t *offset, size_t count);
-int              fstatat (int dirfd, const char *path, struct stat *buf, int flags);
-int              mkdirat (int dirfd, const char *pathname, mode_t mode);
-int              fchownat (int dirfd, const char *path, uid_t owner, gid_t group, int flags);
-int              fchmodat (int dirfd, const char *path, mode_t mode, int flags);
-int              renameat (int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
-int              link (const char*, const char*);
-int              unlink (const char*);
-int              unlinkat (int, const char *, int);
-int              chdir (const char*);
-int              mknod (const char*, mode_t, dev_t);
-int              chmod (const char*,mode_t);
-int              chown (const char *, uid_t, gid_t);
-int              chown (const char *, uid_t, gid_t);
-int              lchown (const char*, uid_t, gid_t);
-int              lchown (const char*, uid_t, gid_t);
-int              mount (const char*, const char*, const char*, unsigned long, const void*);
-int              umount (const char*);
-int              umount2 (const char*, int);
-int              fstat (int, struct stat*);
-int              stat (const char *, struct stat *);
-int              lstat (const char *, struct stat *);
-int              mkdir (const char *, mode_t);
-int              readlink (const char *, char *, size_t);
-int              rmdir (const char *);
-int              rename (const char *, const char *);
-int              __getcwd (char * buf, size_t size);
-int              access (const char *, int);
-int              symlink (const char *, const char *);
-int              fchdir (int);
-int              truncate (const char*, off_t);
-int              __statfs64 (const char *, size_t, struct statfs *);
-int              pause (void);
-int              gettimeofday (struct timeval*, struct timezone*);
-int              settimeofday (const struct timeval*, const struct timezone*);
-clock_t          times (struct tms *);
-int              nanosleep (const struct timespec *, struct timespec *);
-int              clock_gettime (clockid_t clk_id, struct timespec *tp);
-int              clock_settime (clockid_t clk_id, const struct timespec *tp);
-int              clock_getres (clockid_t clk_id, struct timespec *res);
-int              clock_nanosleep (const struct timespec *req, struct timespec *rem);
-int              getitimer (int, const struct itimerval *);
-int              setitimer (int, const struct itimerval *, struct itimerval *);
-int              __timer_create (clockid_t clockid, struct sigevent *evp, timer_t *timerid);
-int              __timer_settime (timer_t, int, const struct itimerspec*, struct itimerspec*);
-int              __timer_gettime (timer_t, struct itimerspec*);
-int              __timer_getoverrun (timer_t);
-int              __timer_delete (timer_t);
-int              utimes (const char*, const struct timeval tvp[2]);
-int              utimensat (int, const char *, const struct timespec times[2], int);
-int              sigaction (int, const struct sigaction *, struct sigaction *);
-int              sigprocmask (int, const sigset_t *, sigset_t *);
-int              __sigsuspend (int unused1, int unused2, unsigned mask);
-int              __rt_sigaction (int sig, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize);
-int              __rt_sigprocmask (int  how, const sigset_t *set, sigset_t *oset, size_t sigsetsize);
-int              __rt_sigtimedwait (const sigset_t *set, struct siginfo_t  *info, struct timespec_t  *timeout, size_t  sigset_size);
-int              sigpending (sigset_t *);
-int              socket (int, int, int);
-int              socketpair (int, int, int, int*);
-int              bind (int, struct sockaddr *, int);
-int              connect (int, struct sockaddr *, socklen_t);
-int              listen (int, int);
-int              accept (int, struct sockaddr *, socklen_t *);
-int              getsockname (int, struct sockaddr *, socklen_t *);
-int              getpeername (int, struct sockaddr *, socklen_t *);
-int              sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
-int              recvfrom (int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
-int              shutdown (int, int);
-int              setsockopt (int, int, int, const void *, socklen_t);
-int              getsockopt (int, int, int, void *, socklen_t *);
-int              sendmsg (int, const struct msghdr *, unsigned int);
-int              recvmsg (int, struct msghdr *, unsigned int);
-int              socket (int, int, int);
-int              bind (int, struct sockaddr *, int);
-int              connect (int, struct sockaddr *, socklen_t);
-int              listen (int, int);
-int              accept (int, struct sockaddr *, socklen_t *);
-int              getsockname (int, struct sockaddr *, socklen_t *);
-int              getpeername (int, struct sockaddr *, socklen_t *);
-int              socketpair (int, int, int, int*);
-int              sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
-int              recvfrom (int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
-int              shutdown (int, int);
-int              setsockopt (int, int, int, const void *, socklen_t);
-int              getsockopt (int, int, int, void *, socklen_t *);
-int              sendmsg (int, const struct msghdr *, unsigned int);
-int              recvmsg (int, struct msghdr *, unsigned int);
-int              __socketcall (int, unsigned long*);
-int              sched_setscheduler (pid_t pid, int policy, const struct sched_param *param);
-int              sched_getscheduler (pid_t pid);
-int              sched_yield (void);
-int              sched_setparam (pid_t pid, const struct sched_param *param);
-int              sched_getparam (pid_t pid, struct sched_param *param);
-int              sched_get_priority_max (int policy);
-int              sched_get_priority_min (int policy);
-int              sched_rr_get_interval (pid_t pid, struct timespec *interval);
-int              sched_setaffinity (pid_t pid, size_t setsize, const cpu_set_t* set);
-int              __sched_getaffinity (pid_t pid, size_t setsize, cpu_set_t* set);
-int              __getcpu (unsigned *cpu, unsigned *node, void *unused);
-int              ioprio_set (int which, int who, int ioprio);
-int              ioprio_get (int which, int who);
-int              uname (struct utsname *);
-pid_t            __wait4 (pid_t pid, int *status, int options, struct rusage *rusage);
-mode_t           umask (mode_t);
-int              __reboot (int, int, int, void *);
-int              __syslog (int, char *, int);
-int              init_module (void *, unsigned long, const char *);
-int              delete_module (const char*, unsigned int);
-int              klogctl (int, char *, int);
-int              sysinfo (struct sysinfo *);
-int              futex (void *, int, int, void *, void *, int);
-int              epoll_create (int size);
-int              epoll_ctl (int epfd, int op, int fd, struct epoll_event *event);
-int              epoll_wait (int epfd, struct epoll_event *events, int max, int timeout);
-int              inotify_init (void);
-int              inotify_add_watch (int, const char *, unsigned int);
-int              inotify_rm_watch (int, unsigned int);
-int              poll (struct pollfd *, unsigned int, long);
-int              eventfd (unsigned int, int);
-int              __set_tls (void*);
-int              cacheflush (long start, long end, long flags);
-int              _flush_cache (char *addr, const int nbytes, const int op);
-int              syscall (int number,...);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _BIONIC_LINUX_UNISTD_H_ */
diff --git a/ndk/platforms/android-9/arch-mips/lib/crtbegin_dynamic.o b/ndk/platforms/android-9/arch-mips/lib/crtbegin_dynamic.o
deleted file mode 100644
index 3202d1a..0000000
--- a/ndk/platforms/android-9/arch-mips/lib/crtbegin_dynamic.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/lib/crtbegin_so.o b/ndk/platforms/android-9/arch-mips/lib/crtbegin_so.o
deleted file mode 100644
index ddfd100..0000000
--- a/ndk/platforms/android-9/arch-mips/lib/crtbegin_so.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/lib/crtbegin_static.o b/ndk/platforms/android-9/arch-mips/lib/crtbegin_static.o
deleted file mode 100644
index 34c5337..0000000
--- a/ndk/platforms/android-9/arch-mips/lib/crtbegin_static.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/lib/crtend_android.o b/ndk/platforms/android-9/arch-mips/lib/crtend_android.o
deleted file mode 100644
index 4ac6536..0000000
--- a/ndk/platforms/android-9/arch-mips/lib/crtend_android.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/lib/crtend_so.o b/ndk/platforms/android-9/arch-mips/lib/crtend_so.o
deleted file mode 100644
index 5c68629..0000000
--- a/ndk/platforms/android-9/arch-mips/lib/crtend_so.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin_dynamic.S b/ndk/platforms/android-9/arch-mips/src/crtbegin_dynamic.S
index 7d1fac7..be42fb2 100644
--- a/ndk/platforms/android-9/arch-mips/src/crtbegin_dynamic.S
+++ b/ndk/platforms/android-9/arch-mips/src/crtbegin_dynamic.S
@@ -64,6 +64,9 @@
 	la	$a3, 1f
 	subu	$sp, 32
 	la	$t9, __libc_init
+# Use jalr intead of jr so stack unwinding past __libc_init can terminate at _start
+	jalr	$t9
+	move	$t9, $0
 	j	$t9
 	.end	__start
 
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin_so.S b/ndk/platforms/android-9/arch-mips/src/crtbegin_so.S
index f4fc9b8..68dddfe 100644
--- a/ndk/platforms/android-9/arch-mips/src/crtbegin_so.S
+++ b/ndk/platforms/android-9/arch-mips/src/crtbegin_so.S
@@ -38,24 +38,7 @@
 	.long -1
 	.long __do_global_dtors_aux
 
-	.section .ctors, "aw"
-	.type __CTOR_LIST__, @object
-	.globl __CTOR_LIST__
-__CTOR_LIST__:
-	.long -1
-
-	.section .dtors, "aw"
-	.type __DTOR_LIST__, @object
-	.globl __DTOR_LIST__
-__DTOR_LIST__:
-	.long -1
-
 	.abicalls
-	.section	.eh_frame,"a",@progbits
-	.align	2
-	.type	__EH_FRAME_BEGIN__, @object
-	.size	__EH_FRAME_BEGIN__, 0
-__EH_FRAME_BEGIN__:
 	.text
 	.align	2
 	.set	nomips16
@@ -105,8 +88,6 @@
 	.size	__do_global_dtors_aux, .-__do_global_dtors_aux
 	.local	completed.1269
 	.comm	completed.1269,1,1
-	.local	object.1265
-	.comm	object.1265,24,4
 	.weak	__cxa_finalize
 
 .include "__dso_handle.S"
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin_static.S b/ndk/platforms/android-9/arch-mips/src/crtbegin_static.S
index 9f00811..58bab82 100644
--- a/ndk/platforms/android-9/arch-mips/src/crtbegin_static.S
+++ b/ndk/platforms/android-9/arch-mips/src/crtbegin_static.S
@@ -64,6 +64,9 @@
 	la	$a3, 1f
 	subu	$sp, 32
 	la	$t9, __libc_init
+# Use jalr intead of jr so stack unwinding past __libc_init can terminate at _start
+	jalr	$t9
+	move	$t9, $0
 	j	$t9
 	.end	__start
 
diff --git a/ndk/platforms/android-9/arch-mips/src/crtend_so.S b/ndk/platforms/android-9/arch-mips/src/crtend_so.S
index d0bb090..f09c427 100644
--- a/ndk/platforms/android-9/arch-mips/src/crtend_so.S
+++ b/ndk/platforms/android-9/arch-mips/src/crtend_so.S
@@ -3,21 +3,3 @@
 
 	.section .fini_array, "aw"
 	.long 0
-
-	.section .ctors, "aw", @progbits
-	.type __CTOR_END__, @object
-__CTOR_END__:
-	.long 0
-	
-	.section .dtors, "aw", @progbits
-	.type __DTOR_END__, @object
-__DTOR_END__:
-	.long 0
-
-	.section	.eh_frame,"a",@progbits
-	.align 4
-	.type	__FRAME_END__, @object
-	.size	__FRAME_END__, 4
-__FRAME_END__:
-	.zero	4
-	
diff --git a/ndk/platforms/android-9/arch-x86/include/fenv.h b/ndk/platforms/android-9/arch-x86/include/fenv.h
index 710494c..4e322b7 100644
--- a/ndk/platforms/android-9/arch-x86/include/fenv.h
+++ b/ndk/platforms/android-9/arch-x86/include/fenv.h
@@ -32,6 +32,8 @@
 #include <sys/cdefs.h>
 #include <sys/_types.h>
 
+__BEGIN_DECLS
+
 /*                   
  * To preserve binary compatibility with FreeBSD 5.3, we pack the
  * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
@@ -65,8 +67,6 @@
 #define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
 			 FE_UPWARD | FE_TOWARDZERO)
 
-__BEGIN_DECLS
-
 /* Default floating-point environment */
 extern const fenv_t	__fe_dfl_env;
 #define	FE_DFL_ENV	(&__fe_dfl_env)
diff --git a/ndk/platforms/android-9/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
index 65892a1..d3d9eeb 100644
--- a/ndk/platforms/android-9/arch-x86/include/machine/_types.h
+++ b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
@@ -58,8 +58,6 @@
 #  endif
 #endif
 
-#include <linux/types.h>
-
 /* 7.18.1.1 Exact-width integer types */
 typedef	__signed char		__int8_t;
 typedef	unsigned char		__uint8_t;
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o b/ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o
deleted file mode 100644
index 17704f5..0000000
--- a/ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o b/ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o
deleted file mode 100644
index cf50f1d..0000000
--- a/ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtbegin_static.o b/ndk/platforms/android-9/arch-x86/lib/crtbegin_static.o
deleted file mode 100644
index 17704f5..0000000
--- a/ndk/platforms/android-9/arch-x86/lib/crtbegin_static.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtend_android.o b/ndk/platforms/android-9/arch-x86/lib/crtend_android.o
deleted file mode 100644
index 87716a0..0000000
--- a/ndk/platforms/android-9/arch-x86/lib/crtend_android.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtend_so.o b/ndk/platforms/android-9/arch-x86/lib/crtend_so.o
deleted file mode 100644
index 4c4460f..0000000
--- a/ndk/platforms/android-9/arch-x86/lib/crtend_so.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/src/__dso_handle.S b/ndk/platforms/android-9/arch-x86/src/__dso_handle.S
new file mode 100644
index 0000000..3e80128
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/__dso_handle.S
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+# The __dso_handle global variable is used by static
+# C++ constructors and destructors in the binary.
+# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
+#
+        .section .bss
+        .align 4
+
+#ifndef CRT_LEGACY_WORKAROUND
+	.hidden __dso_handle
+#endif
+
+        .globl __dso_handle
+__dso_handle:
+        .long 0
diff --git a/ndk/platforms/android-9/arch-x86/src/__dso_handle_so.S b/ndk/platforms/android-9/arch-x86/src/__dso_handle_so.S
new file mode 100644
index 0000000..77a5d7f
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/__dso_handle_so.S
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+# The __dso_handle global variable is used by static
+# C++ constructors and destructors in the binary.
+# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
+#
+	.data
+        .align 4
+	.hidden __dso_handle
+        .globl __dso_handle
+__dso_handle:
+        .long __dso_handle
diff --git a/ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.S b/ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.S
new file mode 100644
index 0000000..59fe86e
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.S
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * Contributed by: Intel Corporation
+ */
+
+	.text
+	.p2align 4,,15
+	.globl	__stack_chk_fail_local
+	.hidden	__stack_chk_fail_local
+	.type	__stack_chk_fail_local, @function
+
+__stack_chk_fail_local:
+#ifdef __PIC__
+	pushl	%ebx
+	call	__x86.get_pc_thunk.bx
+	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
+	call	__stack_chk_fail@PLT
+#else /* PIC */
+	jmp   __stack_chk_fail
+#endif /* not PIC */
+
+	.size	__stack_chk_fail_local, .-__stack_chk_fail_local
diff --git a/ndk/platforms/android-9/arch-x86/src/atexit.S b/ndk/platforms/android-9/arch-x86/src/atexit.S
new file mode 100644
index 0000000..b28f40b
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/atexit.S
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+	.text
+	.p2align 4,,15
+	.globl	atexit
+	.hidden	atexit
+	.type	atexit, @function
+atexit:
+	pushl	%ebp
+	movl	%esp, %ebp
+	pushl	%ebx
+	call	__x86.get_pc_thunk.bx
+	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
+	subl	$20, %esp
+	movl	$0, 4(%esp)
+	movl	__dso_handle@GOTOFF(%ebx), %eax
+	movl	%eax, 8(%esp)
+	movl	8(%ebp), %eax
+	movl	%eax, (%esp)
+	call	__cxa_atexit@PLT
+	addl	$20, %esp
+	popl	%ebx
+	popl	%ebp
+	ret
+	.size	atexit, .-atexit
+
+	.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+	.globl	__x86.get_pc_thunk.bx
+	.hidden	__x86.get_pc_thunk.bx
+	.type	__x86.get_pc_thunk.bx, @function
+__x86.get_pc_thunk.bx:
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	movl	(%esp), %ebx
+	ret
diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin_dynamic.S b/ndk/platforms/android-9/arch-x86/src/crtbegin_dynamic.S
new file mode 100644
index 0000000..0ccad70
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/crtbegin_dynamic.S
@@ -0,0 +1,138 @@
+# bionic/arch-x86/bionic/crtbegin_dynamic.S
+#
+# Copyright 2006, The Android Open Source Project
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in the
+#       documentation and/or other materials provided with the distribution.
+#     * Neither the name of Google Inc. nor the names of its contributors may
+#       be used to endorse or promote products derived from this software
+#       without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR 
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
+# EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+	.text
+	.align 4
+	.type _start, @function
+	.globl _start
+
+# this is the small startup code that is first run when
+# any executable that is dynamically-linked with Bionic
+# runs.
+#
+# it's purpose is to call __libc_init with appropriate
+# arguments, which are:
+#
+#    - the address of the raw data block setup by the Linux
+#      kernel ELF loader
+#
+#    - address of an "onexit" function, not used on any
+#      platform supported by Bionic
+#
+#    - address of the "main" function of the program. We
+#      can't hard-code it in the adr pseudo instruction
+#      so we use a tiny trampoline that will get relocated
+#      by the dynamic linker before this code runs
+#
+#    - address of the constructor list
+#
+_start:	
+        mov     %esp, %eax
+        # before push arguments, align the stack to a 16 byte boundary
+        andl    $~15, %esp
+        mov     $1f, %edx
+        pushl   %edx
+        mov     $0f, %edx
+        pushl   %edx
+        mov     $0, %edx
+        pushl   %edx
+        pushl   %eax
+        call    __libc_init
+
+0:  jmp   main
+
+1:  .long   __PREINIT_ARRAY__
+    .long   __INIT_ARRAY__
+    .long   __FINI_ARRAY__
+
+	.section .preinit_array, "aw"
+	.globl __PREINIT_ARRAY__
+__PREINIT_ARRAY__:
+	.long -1
+
+	.section .init_array, "aw"
+	.globl __INIT_ARRAY__
+__INIT_ARRAY__:
+	.long -1
+	.long	frame_dummy
+
+	.section .fini_array, "aw"
+	.globl __FINI_ARRAY__
+__FINI_ARRAY__:
+	.long -1
+	.long	__do_global_dtors_aux
+
+	.section	.eh_frame,"a",@progbits
+	.align 4
+	.type	__EH_FRAME_BEGIN__, @object
+__EH_FRAME_BEGIN__:
+	.text
+	.p2align 4,,15
+	.type	__do_global_dtors_aux, @function
+__do_global_dtors_aux:
+	pushl	%ebp
+	movl	%esp, %ebp
+	subl	$24, %esp
+	cmpb	$0, completed.4454
+	jne	.L4
+	movl	$__deregister_frame_info_bases, %eax
+	testl	%eax, %eax
+	je	.L3
+	movl	$__EH_FRAME_BEGIN__, (%esp)
+	call	__deregister_frame_info_bases
+.L3:
+	movb	$1, completed.4454
+.L4:
+	leave
+	ret
+	.text
+	.p2align 4,,15
+	.type	frame_dummy, @function
+frame_dummy:
+	pushl	%ebp
+	movl	$__register_frame_info_bases, %eax
+	movl	%esp, %ebp
+	subl	$24, %esp
+	testl	%eax, %eax
+	je	.L7
+	movl	%ebx, 12(%esp)
+	movl	$0, 8(%esp)
+	movl	$object.4466, 4(%esp)
+	movl	$__EH_FRAME_BEGIN__, (%esp)
+	call	__register_frame_info_bases
+.L7:
+	leave
+	ret
+	.local	completed.4454
+	.comm	completed.4454,1,1
+	.local	object.4466
+	.comm	object.4466,24,4
+	.weak	__register_frame_info_bases
+	.weak	__deregister_frame_info_bases
+
+#include "__dso_handle.S"
+#include "atexit.S"
+#include "__stack_chk_fail_local.S"
diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin_so.S b/ndk/platforms/android-9/arch-x86/src/crtbegin_so.S
new file mode 100644
index 0000000..99662fe
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/crtbegin_so.S
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+.section .init_array, "aw"
+.align 4
+.type __INIT_ARRAY__, @object
+.globl __INIT_ARRAY__
+__INIT_ARRAY__:
+    .long -1
+    .long frame_dummy
+
+.section .fini_array, "aw"
+.align 4
+.type __FINI_ARRAY__, @object
+.globl __FINI_ARRAY__
+__FINI_ARRAY__:
+    .long -1
+    .long __do_global_dtors_aux
+
+	.section	.eh_frame,"a",@progbits
+	.align 4
+	.type	__EH_FRAME_BEGIN__, @object
+__EH_FRAME_BEGIN__:
+	.text
+	.p2align 4,,15
+	.type	__do_global_dtors_aux, @function
+__do_global_dtors_aux:
+	pushl	%ebp
+	movl	%esp, %ebp
+	pushl	%ebx
+	call	__x86.get_pc_thunk.bx
+	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
+	subl	$20, %esp
+	cmpb	$0, completed.4454@GOTOFF(%ebx)
+	jne	.L5
+	movl	__dso_handle@GOTOFF(%ebx), %eax
+	movl	%eax, (%esp)
+	call	__cxa_finalize@PLT
+	movl	__deregister_frame_info_bases@GOT(%ebx), %eax
+	testl	%eax, %eax
+	je	.L4
+	leal	__EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax
+	movl	%eax, (%esp)
+	call	__deregister_frame_info_bases@PLT
+.L4:
+	movb	$1, completed.4454@GOTOFF(%ebx)
+.L5:
+	addl	$20, %esp
+	popl	%ebx
+	popl	%ebp
+	ret
+	.text
+	.p2align 4,,15
+	.type	frame_dummy, @function
+frame_dummy:
+	pushl	%ebp
+	movl	%esp, %ebp
+	pushl	%ebx
+	call	__x86.get_pc_thunk.bx
+	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
+	subl	$20, %esp
+	movl	__register_frame_info_bases@GOT(%ebx), %eax
+	testl	%eax, %eax
+	je	.L8
+	leal	object.4469@GOTOFF(%ebx), %eax
+	movl	%eax, 4(%esp)
+	leal	__EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax
+	movl	%ebx, 12(%esp)
+	movl	$0, 8(%esp)
+	movl	%eax, (%esp)
+	call	__register_frame_info_bases@PLT
+.L8:
+	addl	$20, %esp
+	popl	%ebx
+	popl	%ebp
+	ret
+	.local	completed.4454
+	.comm	completed.4454,1,1
+	.local	object.4469
+	.comm	object.4469,24,4
+	.weak	__register_frame_info_bases
+	.weak	__deregister_frame_info_bases
+
+#include "__dso_handle_so.S"
+#include "atexit.S"
+#include "__stack_chk_fail_local.S"
diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin_static.S b/ndk/platforms/android-9/arch-x86/src/crtbegin_static.S
new file mode 100644
index 0000000..4fffecd
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/crtbegin_static.S
@@ -0,0 +1,138 @@
+# bionic/arch-x86/bionic/crtbegin_static.S
+#
+# Copyright 2006, The Android Open Source Project
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in the
+#       documentation and/or other materials provided with the distribution.
+#     * Neither the name of Google Inc. nor the names of its contributors may
+#       be used to endorse or promote products derived from this software
+#       without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR 
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
+# EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+	.text
+	.align 4
+	.type _start, @function
+	.globl _start
+
+# this is the small startup code that is first run when
+# any executable that is statically-linked with Bionic
+# runs.
+#
+# it's purpose is to call __libc_init with appropriate
+# arguments, which are:
+#
+#    - the address of the raw data block setup by the Linux
+#      kernel ELF loader
+#
+#    - address of an "onexit" function, not used on any
+#      platform supported by Bionic
+#
+#    - address of the "main" function of the program. We
+#      can't hard-code it in the adr pseudo instruction
+#      so we use a tiny trampoline that will get relocated
+#      by the dynamic linker before this code runs
+#
+#    - address of the constructor list
+#
+_start:	
+        mov     %esp, %eax
+        # before push arguments, align the stack to a 16 byte boundary
+        andl    $~15, %esp
+        mov     $1f, %edx
+        pushl   %edx
+        mov     $0f, %edx
+        pushl   %edx
+        mov     $0, %edx
+        pushl   %edx
+        pushl   %eax
+        call    __libc_init
+
+0:  jmp   main
+
+1:  .long   __PREINIT_ARRAY__
+    .long   __INIT_ARRAY__
+    .long   __FINI_ARRAY__
+
+	.section .preinit_array, "aw"
+	.globl __PREINIT_ARRAY__
+__PREINIT_ARRAY__:
+	.long -1
+
+	.section .init_array, "aw"
+	.globl __INIT_ARRAY__
+__INIT_ARRAY__:
+	.long -1
+	.long	frame_dummy
+
+	.section .fini_array, "aw"
+	.globl __FINI_ARRAY__
+__FINI_ARRAY__:
+	.long -1
+	.long	__do_global_dtors_aux
+
+	.section	.eh_frame,"a",@progbits
+	.align 4
+	.type	__EH_FRAME_BEGIN__, @object
+__EH_FRAME_BEGIN__:
+	.text
+	.p2align 4,,15
+	.type	__do_global_dtors_aux, @function
+__do_global_dtors_aux:
+	pushl	%ebp
+	movl	%esp, %ebp
+	subl	$24, %esp
+	cmpb	$0, completed.4454
+	jne	.L4
+	movl	$__deregister_frame_info_bases, %eax
+	testl	%eax, %eax
+	je	.L3
+	movl	$__EH_FRAME_BEGIN__, (%esp)
+	call	__deregister_frame_info_bases
+.L3:
+	movb	$1, completed.4454
+.L4:
+	leave
+	ret
+	.text
+	.p2align 4,,15
+	.type	frame_dummy, @function
+frame_dummy:
+	pushl	%ebp
+	movl	$__register_frame_info_bases, %eax
+	movl	%esp, %ebp
+	subl	$24, %esp
+	testl	%eax, %eax
+	je	.L7
+	movl	%ebx, 12(%esp)
+	movl	$0, 8(%esp)
+	movl	$object.4466, 4(%esp)
+	movl	$__EH_FRAME_BEGIN__, (%esp)
+	call	__register_frame_info_bases
+.L7:
+	leave
+	ret
+	.local	completed.4454
+	.comm	completed.4454,1,1
+	.local	object.4466
+	.comm	object.4466,24,4
+	.weak	__register_frame_info_bases
+	.weak	__deregister_frame_info_bases
+
+#include "__dso_handle.S"
+#include "atexit.S"
+#include "__stack_chk_fail_local.S"
diff --git a/ndk/platforms/android-9/arch-x86/src/crtend.S b/ndk/platforms/android-9/arch-x86/src/crtend.S
new file mode 100644
index 0000000..68447e7
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/crtend.S
@@ -0,0 +1,15 @@
+	.section .preinit_array, "aw"
+	.long 0
+
+	.section .init_array, "aw"
+	.long 0
+
+	.section .fini_array, "aw"
+	.long 0
+
+	.section	.eh_frame,"a",@progbits
+	.align 4
+	.type	__FRAME_END__, @object
+	.size	__FRAME_END__, 4
+__FRAME_END__:
+	.zero	4
diff --git a/ndk/platforms/android-9/arch-x86/src/crtend_so.S b/ndk/platforms/android-9/arch-x86/src/crtend_so.S
new file mode 100644
index 0000000..63e58b9
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/src/crtend_so.S
@@ -0,0 +1,12 @@
+.section .init_array, "aw"
+    .long 0
+
+.section .fini_array, "aw"
+    .long 0
+
+	.section	.eh_frame,"a",@progbits
+	.align 4
+	.type	__FRAME_END__, @object
+	.size	__FRAME_END__, 4
+__FRAME_END__:
+	.zero	4
diff --git a/ndk/platforms/android-9/include/sys/linux-unistd.h b/ndk/platforms/android-9/include/sys/linux-unistd.h
deleted file mode 100644
index 23853da..0000000
--- a/ndk/platforms/android-9/include/sys/linux-unistd.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/* auto-generated by gensyscalls.py, do not touch */
-#ifndef _BIONIC_LINUX_UNISTD_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void             _exit (int);
-void             _exit_thread (int);
-pid_t            __fork (void);
-pid_t            _waitpid (pid_t, int*, int, struct rusage*);
-int              __waitid (int, pid_t, struct siginfo_t*, int,void*);
-pid_t            __sys_clone (int, void*, int*, void*, int*);
-int              execve (const char*, char* const*, char* const*);
-int              __setuid (uid_t);
-uid_t            getuid (void);
-gid_t            getgid (void);
-uid_t            geteuid (void);
-gid_t            getegid (void);
-uid_t            getresuid (void);
-gid_t            getresgid (void);
-pid_t            gettid (void);
-int              getgroups (int, gid_t *);
-pid_t            getpgid (pid_t);
-pid_t            getppid (void);
-pid_t            setsid (void);
-int              setgid (gid_t);
-int              seteuid (uid_t);
-int              __setreuid (uid_t, uid_t);
-int              __setresuid (uid_t, uid_t, uid_t);
-int              setresgid (gid_t, gid_t, gid_t);
-void*            __brk (void*);
-int              kill (pid_t, int);
-int              tkill (pid_t tid, int sig);
-int              __ptrace (int request, int pid, void* addr, void* data);
-int              __set_thread_area (void*  user_desc);
-int              __getpriority (int, int);
-int              setpriority (int, int, int);
-int              setrlimit (int resource, const struct rlimit *rlp);
-int              getrlimit (int resource, struct rlimit *rlp);
-int              getrusage (int who, struct rusage*  r_usage);
-int              setgroups (int, const gid_t *);
-pid_t            getpgrp (void);
-int              setpgid (pid_t, pid_t);
-pid_t            vfork (void);
-int              setregid (gid_t, gid_t);
-int              chroot (const char *);
-int              prctl (int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5);
-int              capget (cap_user_header_t header, cap_user_data_t data);
-int              capset (cap_user_header_t header, const cap_user_data_t data);
-int              sigaltstack (const stack_t*, stack_t*);
-int              acct (const char*  filepath);
-ssize_t          read (int, void*, size_t);
-ssize_t          write (int, const void*, size_t);
-ssize_t          __pread64 (int, void *, size_t, off_t, off_t);
-ssize_t          __pwrite64 (int, void *, size_t, off_t, off_t);
-int              __open (const char*, int, mode_t);
-int              __openat (int, const char*, int, mode_t);
-int              close (int);
-int              creat (const char*, mode_t);
-off_t            lseek (int, off_t, int);
-int              __llseek (int, unsigned long, unsigned long, loff_t*, int);
-pid_t            getpid (void);
-void *           mmap (void *, size_t, int, int, int, long);
-void *           __mmap2 (void*, size_t, int, int, int, long);
-int              munmap (void *, size_t);
-void *           mremap (void *, size_t, size_t, unsigned long);
-int              msync (const void *, size_t, int);
-int              mprotect (const void *, size_t, int);
-int              madvise (const void *, size_t, int);
-int              mlock (const void *addr, size_t len);
-int              munlock (const void *addr, size_t len);
-int              mincore (void*  start, size_t  length, unsigned char*  vec);
-int              __ioctl (int, int, void *);
-int              readv (int, const struct iovec *, int);
-int              writev (int, const struct iovec *, int);
-int              __fcntl (int, int, void*);
-int              flock (int, int);
-int              fchmod (int, mode_t);
-int              dup (int);
-int              pipe (int *);
-int              pipe2 (int *, int);
-int              dup2 (int, int);
-int              select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
-int              ftruncate (int, off_t);
-int              getdents (unsigned int, struct dirent *, unsigned int);
-int              fsync (int);
-int              fdatasync (int);
-int              fchown (int, uid_t, gid_t);
-void             sync (void);
-int              __fcntl64 (int, int, void *);
-int              __fstatfs64 (int, size_t, struct statfs *);
-ssize_t          sendfile (int out_fd, int in_fd, off_t *offset, size_t count);
-int              fstatat (int dirfd, const char *path, struct stat *buf, int flags);
-int              mkdirat (int dirfd, const char *pathname, mode_t mode);
-int              fchownat (int dirfd, const char *path, uid_t owner, gid_t group, int flags);
-int              fchmodat (int dirfd, const char *path, mode_t mode, int flags);
-int              renameat (int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
-int              link (const char*, const char*);
-int              unlink (const char*);
-int              unlinkat (int, const char *, int);
-int              chdir (const char*);
-int              mknod (const char*, mode_t, dev_t);
-int              chmod (const char*,mode_t);
-int              chown (const char *, uid_t, gid_t);
-int              lchown (const char*, uid_t, gid_t);
-int              mount (const char*, const char*, const char*, unsigned long, const void*);
-int              umount (const char*);
-int              umount2 (const char*, int);
-int              fstat (int, struct stat*);
-int              stat (const char *, struct stat *);
-int              lstat (const char *, struct stat *);
-int              mkdir (const char *, mode_t);
-int              readlink (const char *, char *, size_t);
-int              rmdir (const char *);
-int              rename (const char *, const char *);
-int              __getcwd (char * buf, size_t size);
-int              access (const char *, int);
-int              symlink (const char *, const char *);
-int              fchdir (int);
-int              truncate (const char*, off_t);
-int              __statfs64 (const char *, size_t, struct statfs *);
-int              pause (void);
-int              gettimeofday (struct timeval*, struct timezone*);
-int              settimeofday (const struct timeval*, const struct timezone*);
-clock_t          times (struct tms *);
-int              nanosleep (const struct timespec *, struct timespec *);
-int              clock_gettime (clockid_t clk_id, struct timespec *tp);
-int              clock_settime (clockid_t clk_id, const struct timespec *tp);
-int              clock_getres (clockid_t clk_id, struct timespec *res);
-int              clock_nanosleep (const struct timespec *req, struct timespec *rem);
-int              getitimer (int, const struct itimerval *);
-int              setitimer (int, const struct itimerval *, struct itimerval *);
-int              __timer_create (clockid_t clockid, struct sigevent *evp, timer_t *timerid);
-int              __timer_settime (timer_t, int, const struct itimerspec*, struct itimerspec*);
-int              __timer_gettime (timer_t, struct itimerspec*);
-int              __timer_getoverrun (timer_t);
-int              __timer_delete (timer_t);
-int              utimes (const char*, const struct timeval tvp[2]);
-int              sigaction (int, const struct sigaction *, struct sigaction *);
-int              sigprocmask (int, const sigset_t *, sigset_t *);
-int              __sigsuspend (int unused1, int unused2, unsigned mask);
-int              __rt_sigaction (int sig, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize);
-int              __rt_sigprocmask (int  how, const sigset_t *set, sigset_t *oset, size_t sigsetsize);
-int              __rt_sigtimedwait (const sigset_t *set, struct siginfo_t  *info, struct timespec_t  *timeout, size_t  sigset_size);
-int              sigpending (sigset_t *);
-int              socket (int, int, int);
-int              socketpair (int, int, int, int*);
-int              bind (int, struct sockaddr *, int);
-int              connect (int, struct sockaddr *, socklen_t);
-int              listen (int, int);
-int              accept (int, struct sockaddr *, socklen_t *);
-int              getsockname (int, struct sockaddr *, socklen_t *);
-int              getpeername (int, struct sockaddr *, socklen_t *);
-int              sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
-int              recvfrom (int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
-int              shutdown (int, int);
-int              setsockopt (int, int, int, const void *, socklen_t);
-int              getsockopt (int, int, int, void *, socklen_t *);
-int              sendmsg (int, const struct msghdr *, unsigned int);
-int              recvmsg (int, struct msghdr *, unsigned int);
-int              socket (int, int, int);
-int              bind (int, struct sockaddr *, int);
-int              connect (int, struct sockaddr *, socklen_t);
-int              listen (int, int);
-int              accept (int, struct sockaddr *, socklen_t *);
-int              getsockname (int, struct sockaddr *, socklen_t *);
-int              getpeername (int, struct sockaddr *, socklen_t *);
-int              socketpair (int, int, int, int*);
-int              sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
-int              recvfrom (int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
-int              shutdown (int, int);
-int              setsockopt (int, int, int, const void *, socklen_t);
-int              getsockopt (int, int, int, void *, socklen_t *);
-int              sendmsg (int, const struct msghdr *, unsigned int);
-int              recvmsg (int, struct msghdr *, unsigned int);
-int              __socketcall (int, unsigned long*);
-int              sched_setscheduler (pid_t pid, int policy, const struct sched_param *param);
-int              sched_getscheduler (pid_t pid);
-int              sched_yield (void);
-int              sched_setparam (pid_t pid, const struct sched_param *param);
-int              sched_getparam (pid_t pid, struct sched_param *param);
-int              sched_get_priority_max (int policy);
-int              sched_get_priority_min (int policy);
-int              sched_rr_get_interval (pid_t pid, struct timespec *interval);
-int              ioprio_set (int which, int who, int ioprio);
-int              ioprio_get (int which, int who);
-int              uname (struct utsname *);
-pid_t            __wait4 (pid_t pid, int *status, int options, struct rusage *rusage);
-mode_t           umask (mode_t);
-int              __reboot (int, int, int, void *);
-int              __syslog (int, char *, int);
-int              init_module (void *, unsigned long, const char *);
-int              delete_module (const char*, unsigned int);
-int              klogctl (int, char *, int);
-int              sysinfo (struct sysinfo *);
-int              futex (void *, int, int, void *, void *, int);
-int              epoll_create (int size);
-int              epoll_ctl (int epfd, int op, int fd, struct epoll_event *event);
-int              epoll_wait (int epfd, struct epoll_event *events, int max, int timeout);
-int              inotify_init (void);
-int              inotify_add_watch (int, const char *, unsigned int);
-int              inotify_rm_watch (int, unsigned int);
-int              poll (struct pollfd *, unsigned int, long);
-int              eventfd (unsigned int, int);
-int              __set_tls (void*);
-int              cacheflush (long start, long end, long flags);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _BIONIC_LINUX_UNISTD_H_ */
diff --git a/ndk/platforms/android-9/samples/native-activity/default.properties b/ndk/platforms/android-9/samples/native-activity/default.properties
index 9a2c9f6..8010039 100644
--- a/ndk/platforms/android-9/samples/native-activity/default.properties
+++ b/ndk/platforms/android-9/samples/native-activity/default.properties
@@ -8,4 +8,4 @@
 # project structure.
 
 # Project target.
-target=android-9
+target=android-10
diff --git a/ndk/platforms/android-9/samples/native-activity/jni/Application.mk b/ndk/platforms/android-9/samples/native-activity/jni/Application.mk
index 22d188e..682f11b 100644
--- a/ndk/platforms/android-9/samples/native-activity/jni/Application.mk
+++ b/ndk/platforms/android-9/samples/native-activity/jni/Application.mk
@@ -1 +1 @@
-APP_PLATFORM := android-9
+APP_PLATFORM := android-10
diff --git a/ndk/platforms/android-9/samples/native-audio/default.properties b/ndk/platforms/android-9/samples/native-audio/default.properties
index eada70a..d63a41e 100644
--- a/ndk/platforms/android-9/samples/native-audio/default.properties
+++ b/ndk/platforms/android-9/samples/native-audio/default.properties
@@ -8,6 +8,6 @@
 # project structure.
 
 # Project target.
-target=android-9
+target=android-10
 # Indicates whether an apk should be generated for each density.
 split.density=false
diff --git a/ndk/platforms/android-9/samples/native-plasma/default.properties b/ndk/platforms/android-9/samples/native-plasma/default.properties
index 9a2c9f6..8010039 100644
--- a/ndk/platforms/android-9/samples/native-plasma/default.properties
+++ b/ndk/platforms/android-9/samples/native-plasma/default.properties
@@ -8,4 +8,4 @@
 # project structure.
 
 # Project target.
-target=android-9
+target=android-10
diff --git a/ndk/platforms/android-9/samples/native-plasma/jni/Application.mk b/ndk/platforms/android-9/samples/native-plasma/jni/Application.mk
index 23fa139..70bbb62 100644
--- a/ndk/platforms/android-9/samples/native-plasma/jni/Application.mk
+++ b/ndk/platforms/android-9/samples/native-plasma/jni/Application.mk
@@ -1,3 +1,3 @@
 # The ARMv7 is significanly faster due to the use of the hardware FPU
 APP_ABI := armeabi armeabi-v7a
-APP_PLATFORM := android-9
+APP_PLATFORM := android-10
diff --git a/ndk/platforms/common/src/crtbrand.c b/ndk/platforms/common/src/crtbrand.c
new file mode 100644
index 0000000..e0fa6f0
--- /dev/null
+++ b/ndk/platforms/common/src/crtbrand.c
@@ -0,0 +1,70 @@
+/*-
+ * Copyright 2000 David E. O'Brien, John D. Polstra.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* The following trick defines int32_t w/o including <stdint.h>
+   We want "int" to be 4-byte.  But just in case it isn't, the following
+   line turns into "typedef int int32_t[0]" and later fails with error messages
+   read like:
+
+      crtbrand.c:83: error: excess elements in struct initializer
+ */
+typedef int int32_t[sizeof(int) == 4];
+
+#define ABI_VENDOR	"Android"
+#define ABI_SECTION	".note.android.ident"
+#define ABI_NOTETYPE	1
+#define ABI_ANDROID_API	PLATFORM_SDK_VERSION
+
+/*
+ * Special ".note" entry to tag an Android binary and specify the ABI version.
+ *
+ * For all arches except sparc, gcc emits the section directive for the
+ * following struct with a PROGBITS type.  However, the section should be
+ * of NOTE type, according to the Generic SysV ABI spec.
+ *
+ * Unfortunately, there is no clean way to tell gcc to use another section type,
+ * so this C file (or the C file that includes it) must be compiled in multiple
+ * steps:
+ *
+ * - Compile the .c file to a .s file.
+ * - Edit the .s file to change the 'progbits' type to 'note', for the section
+ *   directive that defines the .note.ABI-tag section.
+ * - Compile the .s file to an object file.
+ *
+ * These steps are done in the invididual Makefiles for each applicable arch.
+ */
+static const struct {
+    int32_t	namesz;
+    int32_t	descsz;
+    int32_t	type;
+    char	name[sizeof ABI_VENDOR];
+    int32_t	android_api;
+} abitag __attribute__ ((section (ABI_SECTION), aligned(4), used)) = {
+    sizeof ABI_VENDOR,
+    sizeof(int32_t),
+    ABI_NOTETYPE,
+    ABI_VENDOR,
+    ABI_ANDROID_API,
+};
diff --git a/ndk/samples/hello-jni/jni/hello-jni.c b/ndk/samples/hello-jni/jni/hello-jni.c
index 632ac17..be1e6a7 100644
--- a/ndk/samples/hello-jni/jni/hello-jni.c
+++ b/ndk/samples/hello-jni/jni/hello-jni.c
@@ -21,7 +21,7 @@
  * to return a new VM String. See the corresponding Java source
  * file located at:
  *
- *   apps/samples/hello-jni/project/src/com/example/HelloJni/HelloJni.java
+ *   apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java
  */
 jstring
 Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
diff --git a/ndk/samples/hello-jni/src/com/example/hellojni/HelloJni.java b/ndk/samples/hello-jni/src/com/example/hellojni/HelloJni.java
index 97ab6d9..05cf67c 100644
--- a/ndk/samples/hello-jni/src/com/example/hellojni/HelloJni.java
+++ b/ndk/samples/hello-jni/src/com/example/hellojni/HelloJni.java
@@ -57,7 +57,7 @@
 
     /* this is used to load the 'hello-jni' library on application
      * startup. The library has already been unpacked into
-     * /data/data/com.example.HelloJni/lib/libhello-jni.so at
+     * /data/data/com.example.hellojni/lib/libhello-jni.so at
      * installation time by the package manager.
      */
     static {
diff --git a/ndk/samples/hello-jni/tests/AndroidManifest.xml b/ndk/samples/hello-jni/tests/AndroidManifest.xml
index d6be01e..f15450b 100644
--- a/ndk/samples/hello-jni/tests/AndroidManifest.xml
+++ b/ndk/samples/hello-jni/tests/AndroidManifest.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.example.HelloJni.tests"
+          package="com.example.hellojni.tests"
           android:versionCode="1"
           android:versionName="1.0">
     <!-- We add an application tag here just so that we can indicate that
@@ -12,10 +12,10 @@
     </application>
     <!--
     This declares that this application uses the instrumentation test runner targeting
-    the package of com.example.HelloJni.  To run the tests use the command:
-    "adb shell am instrument -w com.example.HelloJni.tests/android.test.InstrumentationTestRunner"
+    the package of com.example.hellojni.  To run the tests use the command:
+    "adb shell am instrument -w com.example.hellojni.tests/android.test.InstrumentationTestRunner"
     -->
     <instrumentation android:name="android.test.InstrumentationTestRunner"
-                     android:targetPackage="com.example.HelloJni"
+                     android:targetPackage="com.example.hellojni"
                      android:label="Tests for HelloJni"/>
 </manifest>
diff --git a/ndk/samples/hello-jni/tests/src/com/example/HelloJni/HelloJniTest.java b/ndk/samples/hello-jni/tests/src/com/example/hellojni/HelloJniTest.java
similarity index 69%
rename from ndk/samples/hello-jni/tests/src/com/example/HelloJni/HelloJniTest.java
rename to ndk/samples/hello-jni/tests/src/com/example/hellojni/HelloJniTest.java
index 519d857..8ba6117 100644
--- a/ndk/samples/hello-jni/tests/src/com/example/HelloJni/HelloJniTest.java
+++ b/ndk/samples/hello-jni/tests/src/com/example/hellojni/HelloJniTest.java
@@ -1,4 +1,4 @@
-package com.example.HelloJni;
+package com.example.hellojni;
 
 import android.test.ActivityInstrumentationTestCase;
 
@@ -9,13 +9,13 @@
  * <p/>
  * To run this test, you can type:
  * adb shell am instrument -w \
- * -e class com.example.HelloJni.HelloJniTest \
- * com.example.HelloJni.tests/android.test.InstrumentationTestRunner
+ * -e class com.example.hellojni.HelloJniTest \
+ * com.example.hellojni.tests/android.test.InstrumentationTestRunner
  */
 public class HelloJniTest extends ActivityInstrumentationTestCase<HelloJni> {
 
     public HelloJniTest() {
-        super("com.example.HelloJni", HelloJni.class);
+        super("com.example.hellojni", HelloJni.class);
     }
 
 }
diff --git a/ndk/samples/two-libs/res/values/strings.xml b/ndk/samples/two-libs/res/values/strings.xml
index ae57f1f..858cdb4 100644
--- a/ndk/samples/two-libs/res/values/strings.xml
+++ b/ndk/samples/two-libs/res/values/strings.xml
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <string name="app_name">TwoLib</string>
+    <string name="app_name">TwoLibs</string>
 </resources>
diff --git a/ndk/samples/two-libs/tests/AndroidManifest.xml b/ndk/samples/two-libs/tests/AndroidManifest.xml
index a7dd602..a787419 100644
--- a/ndk/samples/two-libs/tests/AndroidManifest.xml
+++ b/ndk/samples/two-libs/tests/AndroidManifest.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.example.TwoLib.tests"
+          package="com.example.twolibs.tests"
           android:versionCode="1"
           android:versionName="1.0">
     <!-- We add an application tag here just so that we can indicate that
@@ -12,10 +12,10 @@
     </application>
     <!--
     This declares that this application uses the instrumentation test runner targeting
-    the package of com.example.TwoLib.  To run the tests use the command:
-    "adb shell am instrument -w com.example.TwoLib.tests/android.test.InstrumentationTestRunner"
+    the package of com.example.twolibs.  To run the tests use the command:
+    "adb shell am instrument -w com.example.twolibs.tests/android.test.InstrumentationTestRunner"
     -->
     <instrumentation android:name="android.test.InstrumentationTestRunner"
-                     android:targetPackage="com.example.TwoLib"
-                     android:label="Tests for TwoLib"/>
+                     android:targetPackage="com.example.twolibs"
+                     android:label="Tests for TwoLibs"/>
 </manifest>
diff --git a/ndk/samples/two-libs/tests/src/com/example/TwoLib/TwoLibTest.java b/ndk/samples/two-libs/tests/src/com/example/TwoLib/TwoLibTest.java
deleted file mode 100644
index 2924502..0000000
--- a/ndk/samples/two-libs/tests/src/com/example/TwoLib/TwoLibTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.example.TwoLib;
-
-import android.test.ActivityInstrumentationTestCase;
-
-/**
- * This is a simple framework for a test of an Application.  See
- * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
- * how to write and extend Application tests.
- * <p/>
- * To run this test, you can type:
- * adb shell am instrument -w \
- * -e class com.example.TwoLib.TwoLibTest \
- * com.example.TwoLib.tests/android.test.InstrumentationTestRunner
- */
-public class TwoLibTest extends ActivityInstrumentationTestCase<TwoLib> {
-
-    public TwoLibTest() {
-        super("com.example.TwoLib", TwoLib.class);
-    }
-
-}
diff --git a/ndk/samples/two-libs/tests/src/com/example/twolibs/TwoLibsTest.java b/ndk/samples/two-libs/tests/src/com/example/twolibs/TwoLibsTest.java
new file mode 100644
index 0000000..6e910be
--- /dev/null
+++ b/ndk/samples/two-libs/tests/src/com/example/twolibs/TwoLibsTest.java
@@ -0,0 +1,21 @@
+package com.example.twolibs;
+
+import android.test.ActivityInstrumentationTestCase;
+
+/**
+ * This is a simple framework for a test of an Application.  See
+ * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
+ * how to write and extend Application tests.
+ * <p/>
+ * To run this test, you can type:
+ * adb shell am instrument -w \
+ * -e class com.example.twolibs.TwoLibsTest \
+ * com.example.twolibs.tests/android.test.InstrumentationTestRunner
+ */
+public class TwoLibsTest extends ActivityInstrumentationTestCase<TwoLibs> {
+
+    public TwoLibsTest() {
+        super("com.example.twolibs", TwoLibs.class);
+    }
+
+}
diff --git a/ndk/sources/android/libportable/Android.mk b/ndk/sources/android/libportable/Android.mk
new file mode 100644
index 0000000..86b097c
--- /dev/null
+++ b/ndk/sources/android/libportable/Android.mk
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2012 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+#=====================================================================
+# Device Shared Library libportable
+#=====================================================================
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libportable
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+LOCAL_CFLAGS := -I $(LOCAL_PATH)/common/include
+
+ifeq ($(TARGET_ARCH),mips)
+libportable_arch_src_files += \
+			arch-mips/ioctl.c \
+			arch-mips/mmap.c \
+			arch-mips/resource.c \
+			arch-mips/stat.c \
+			arch-mips/statfs.c \
+			arch-mips/open.c \
+			arch-mips/poll.c \
+			arch-mips/socket.c \
+			arch-mips/sockopt.c \
+			arch-mips/fcntl.c \
+			arch-mips/epoll.c \
+			arch-mips/errno.c
+endif
+
+ifeq ($(TARGET_ARCH),arm)
+libportable_arch_src_files += \
+			arch-arm/stat.c \
+			arch-arm/socket.c \
+			arch-arm/sockopt.c \
+			arch-arm/epoll.c \
+			arch-arm/errno.c
+endif
+
+ifeq ($(TARGET_ARCH),x86)
+libportable_arch_src_files += \
+			arch-x86/ioctl.c \
+			arch-x86/stat.c \
+			arch-x86/open.c \
+			arch-x86/socket.c \
+			arch-x86/sockopt.c \
+			arch-x86/fcntl.c \
+			arch-x86/epoll.c \
+			arch-x86/errno.c
+endif
+
+LOCAL_SRC_FILES := \
+        $(libportable_common_src_files) \
+        $(libportable_arch_src_files)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/ndk/sources/android/libportable/arch-arm/epoll.c b/ndk/sources/android/libportable/arch-arm/epoll.c
new file mode 100644
index 0000000..f703ba1
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-arm/epoll.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012, 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 <sys/epoll.h>
+
+int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event)
+{
+    return epoll_ctl(epfd, op, fd, event);
+}
+
+int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout)
+{
+    return epoll_wait(epfd, events, max, timeout);
+}
+
diff --git a/ndk/sources/android/libportable/arch-arm/errno.c b/ndk/sources/android/libportable/arch-arm/errno.c
new file mode 100644
index 0000000..ffa5998
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-arm/errno.c
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+extern volatile int*   __errno(void);
+volatile int* __errno_portable()
+{
+  return __errno();
+}
diff --git a/ndk/sources/android/libportable/arch-arm/socket.c b/ndk/sources/android/libportable/arch-arm/socket.c
new file mode 100644
index 0000000..7e7ca9b
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-arm/socket.c
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2012, 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 <unistd.h>
+#include <sys/socket.h>
+#include <sys/linux-syscalls.h>
+
+int socket_portable(int domain, int type, int protocol) {
+    return socket(domain, type, protocol);
+}
diff --git a/ndk/sources/android/libportable/arch-arm/sockopt.c b/ndk/sources/android/libportable/arch-arm/sockopt.c
new file mode 100644
index 0000000..c86ded3
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-arm/sockopt.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012, 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 <sys/types.h>
+#include <sys/socket.h>
+
+extern int setsockopt(int, int, int, const void *, socklen_t);
+int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
+{
+    return setsockopt(s, level, optname, optval, optlen);
+}
+
+extern int getsockopt (int, int, int, void *, socklen_t *);
+int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
+{
+    return getsockopt(s, level, optname, optval, optlen);
+}
diff --git a/ndk/sources/android/libportable/arch-arm/stat.c b/ndk/sources/android/libportable/arch-arm/stat.c
new file mode 100644
index 0000000..20a34ad
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-arm/stat.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2012, 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 <stat_portable.h>
+
+/* Note: The Portable Header will define stat to stat_portable */
+int stat_portable(const char *path, struct stat_portable *s)
+{
+   return stat(path, s);
+}
+
+int fstat_portable(int fd, struct stat_portable *s)
+{
+    return fstat(fd, s);
+}   
+
+int lstat_portable(const char *path, struct stat_portable *s)
+{
+    return lstat(path, s);
+}
+
+int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
+{
+    return fstatat(dirfd, path, s, flags);
+}
diff --git a/ndk/sources/android/libportable/arch-mips/epoll.c b/ndk/sources/android/libportable/arch-mips/epoll.c
new file mode 100644
index 0000000..f703ba1
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/epoll.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012, 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 <sys/epoll.h>
+
+int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event)
+{
+    return epoll_ctl(epfd, op, fd, event);
+}
+
+int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout)
+{
+    return epoll_wait(epfd, events, max, timeout);
+}
+
diff --git a/ndk/sources/android/libportable/arch-mips/errno.c b/ndk/sources/android/libportable/arch-mips/errno.c
new file mode 100644
index 0000000..7372c67
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/errno.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2012, 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 <errno.h>
+#include <errno_portable.h>
+
+#if ENAMETOOLONG==ENAMETOOLONG_PORTABLE
+#error Bad build environment
+#endif
+
+static inline int mips_change_errno(int mips_errno)
+{
+    switch (mips_errno) {
+      case ENAMETOOLONG: return ENAMETOOLONG_PORTABLE;
+      case ENOLCK: return ENOLCK_PORTABLE;
+      case ENOSYS: return ENOSYS_PORTABLE;
+      case ENOTEMPTY: return ENOTEMPTY_PORTABLE;
+      case ELOOP: return ELOOP_PORTABLE;
+      case EWOULDBLOCK: return EWOULDBLOCK_PORTABLE;
+      case ENOMSG: return ENOMSG_PORTABLE;
+      case EIDRM: return EIDRM_PORTABLE;
+      case ECHRNG: return ECHRNG_PORTABLE;
+      case EL2NSYNC: return EL2NSYNC_PORTABLE;
+      case EL3HLT: return EL3HLT_PORTABLE;
+      case EL3RST: return EL3RST_PORTABLE;
+      case ELNRNG: return ELNRNG_PORTABLE;
+      case EUNATCH: return EUNATCH_PORTABLE;
+      case ENOCSI: return ENOCSI_PORTABLE;
+      case EL2HLT: return EL2HLT_PORTABLE;
+      case EBADE: return EBADE_PORTABLE;
+      case EBADR: return EBADR_PORTABLE;
+      case EXFULL: return EXFULL_PORTABLE;
+      case ENOANO: return ENOANO_PORTABLE;
+      case EBADRQC: return EBADRQC_PORTABLE;
+      case EBADSLT: return EBADSLT_PORTABLE;
+      case EDEADLOCK: return EDEADLOCK_PORTABLE;
+      case EBFONT: return EBFONT_PORTABLE;
+      case ENOSTR: return ENOSTR_PORTABLE;
+      case ENODATA: return ENODATA_PORTABLE;
+      case ETIME: return ETIME_PORTABLE;
+      case ENOSR: return ENOSR_PORTABLE;
+      case ENONET: return ENONET_PORTABLE;
+      case ENOPKG: return ENOPKG_PORTABLE;
+      case EREMOTE: return EREMOTE_PORTABLE;
+      case ENOLINK: return ENOLINK_PORTABLE;
+      case EADV: return EADV_PORTABLE;
+      case ESRMNT: return ESRMNT_PORTABLE;
+      case ECOMM: return ECOMM_PORTABLE;
+      case EPROTO: return EPROTO_PORTABLE;
+      case EMULTIHOP: return EMULTIHOP_PORTABLE;
+      case EDOTDOT: return EDOTDOT_PORTABLE;
+      case EBADMSG: return EBADMSG_PORTABLE;
+      case EOVERFLOW: return EOVERFLOW_PORTABLE;
+      case ENOTUNIQ: return ENOTUNIQ_PORTABLE;
+      case EBADFD: return EBADFD_PORTABLE;
+      case EREMCHG: return EREMCHG_PORTABLE;
+      case ELIBACC: return ELIBACC_PORTABLE;
+      case ELIBBAD: return ELIBBAD_PORTABLE;
+      case ELIBSCN: return ELIBSCN_PORTABLE;
+      case ELIBMAX: return ELIBMAX_PORTABLE;
+      case ELIBEXEC: return ELIBEXEC_PORTABLE;
+      case EILSEQ: return EILSEQ_PORTABLE;
+      case ERESTART: return ERESTART_PORTABLE;
+      case ESTRPIPE: return ESTRPIPE_PORTABLE;
+      case EUSERS: return EUSERS_PORTABLE;
+      case ENOTSOCK: return ENOTSOCK_PORTABLE;
+      case EDESTADDRREQ: return EDESTADDRREQ_PORTABLE;
+      case EMSGSIZE: return EMSGSIZE_PORTABLE;
+      case EPROTOTYPE: return EPROTOTYPE_PORTABLE;
+      case ENOPROTOOPT: return ENOPROTOOPT_PORTABLE;
+      case EPROTONOSUPPORT: return EPROTONOSUPPORT_PORTABLE;
+      case ESOCKTNOSUPPORT: return ESOCKTNOSUPPORT_PORTABLE;
+      case EOPNOTSUPP: return EOPNOTSUPP_PORTABLE;
+      case EPFNOSUPPORT: return EPFNOSUPPORT_PORTABLE;
+      case EAFNOSUPPORT: return EAFNOSUPPORT_PORTABLE;
+      case EADDRINUSE: return EADDRINUSE_PORTABLE;
+      case EADDRNOTAVAIL: return EADDRNOTAVAIL_PORTABLE;
+      case ENETDOWN: return ENETDOWN_PORTABLE;
+      case ENETUNREACH: return ENETUNREACH_PORTABLE;
+      case ENETRESET: return ENETRESET_PORTABLE;
+      case ECONNABORTED: return ECONNABORTED_PORTABLE;
+      case ECONNRESET: return ECONNRESET_PORTABLE;
+      case ENOBUFS: return ENOBUFS_PORTABLE;
+      case EISCONN: return EISCONN_PORTABLE;
+      case ENOTCONN: return ENOTCONN_PORTABLE;
+      case ESHUTDOWN: return ESHUTDOWN_PORTABLE;
+      case ETOOMANYREFS: return ETOOMANYREFS_PORTABLE;
+      case ETIMEDOUT: return ETIMEDOUT_PORTABLE;
+      case ECONNREFUSED: return ECONNREFUSED_PORTABLE;
+      case EHOSTDOWN: return EHOSTDOWN_PORTABLE;
+      case EHOSTUNREACH: return EHOSTUNREACH_PORTABLE;
+      case EALREADY: return EALREADY_PORTABLE;
+      case EINPROGRESS: return EINPROGRESS_PORTABLE;
+      case ESTALE: return ESTALE_PORTABLE;
+      case EUCLEAN: return EUCLEAN_PORTABLE;
+      case ENOTNAM: return ENOTNAM_PORTABLE;
+      case ENAVAIL: return ENAVAIL_PORTABLE;
+      case EISNAM: return EISNAM_PORTABLE;
+      case EREMOTEIO: return EREMOTEIO_PORTABLE;
+      case EDQUOT: return EDQUOT_PORTABLE;
+      case ENOMEDIUM: return ENOMEDIUM_PORTABLE;
+      case EMEDIUMTYPE: return EMEDIUMTYPE_PORTABLE;
+      case ECANCELED: return ECANCELED_PORTABLE;
+      case ENOKEY: return ENOKEY_PORTABLE;
+      case EKEYEXPIRED: return EKEYEXPIRED_PORTABLE;
+      case EKEYREVOKED: return EKEYREVOKED_PORTABLE;
+      case EKEYREJECTED: return EKEYREJECTED_PORTABLE;
+      case EOWNERDEAD: return EOWNERDEAD_PORTABLE;
+      case ENOTRECOVERABLE: return ENOTRECOVERABLE_PORTABLE;
+    }
+    return mips_errno;
+}
+
+extern volatile int*   __errno(void);
+volatile int* __errno_portable()
+{
+  /* Note that writing to static_errno will not affect the underlying system. */
+  static int static_errno;
+  static_errno = mips_change_errno(*__errno());
+  return &static_errno;
+}
diff --git a/ndk/sources/android/libportable/arch-mips/fcntl.c b/ndk/sources/android/libportable/arch-mips/fcntl.c
new file mode 100644
index 0000000..31874b5
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/fcntl.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012, 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 <fcntl.h>
+#include <stdarg.h>
+#include <fcntl_portable.h>
+
+#if F_GETLK_PORTABLE==F_GETLK
+#error Bad build environment
+#endif
+
+static inline int mips_change_cmd(int cmd)
+{
+    switch(cmd) {
+    case F_GETLK_PORTABLE:
+        return F_GETLK;
+    case F_SETLK_PORTABLE:
+        return F_SETLK;
+    case F_SETLKW_PORTABLE:
+        return F_SETLKW;
+    case F_SETOWN_PORTABLE:
+        return F_SETOWN;
+    case F_GETOWN_PORTABLE:
+        return F_GETOWN;
+    case F_GETLK64_PORTABLE:
+        return F_GETLK64;
+    case F_SETLK64_PORTABLE:
+        return F_SETLK64;
+    case F_SETLKW64_PORTABLE:
+        return F_SETLKW64;
+    }
+    return cmd;
+}
+
+extern int __fcntl64(int, int, void *);
+
+int fcntl_portable(int fd, int cmd, ...)
+{
+    va_list ap;
+    void * arg;
+
+    va_start(ap, cmd);
+    arg = va_arg(ap, void *);
+    va_end(ap);
+
+    return __fcntl64(fd, mips_change_cmd(cmd), arg);
+}
+
diff --git a/ndk/sources/android/libportable/arch-mips/ioctl.c b/ndk/sources/android/libportable/arch-mips/ioctl.c
new file mode 100644
index 0000000..cbd517f
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/ioctl.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2012, 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 <stdarg.h>
+#include <sys/ioctl.h>
+#include <ioctls_portable.h>
+#include <termios.h>
+#include <linux/sockios.h>
+
+#if FIONREAD_PORTABLE==FIONREAD
+#error Bad build environment
+#endif
+
+static inline int mips_change_request(int request)
+{
+    switch(request) {
+    case TCGETS_PORTABLE:
+        return TCGETS;
+    case TCSETS_PORTABLE:
+        return TCSETS;
+    case TCSETSW_PORTABLE:
+        return TCSETSW;
+    case TCSETSF_PORTABLE:
+        return TCSETSF;
+    case TCGETA_PORTABLE:
+        return TCGETA;
+    case TCSETA_PORTABLE:
+        return TCSETA;
+    case TCSETAW_PORTABLE:
+        return TCSETAW;
+    case TCSETAF_PORTABLE:
+        return TCSETAF;
+    case TCSBRK_PORTABLE:
+        return TCSBRK;
+    case TCXONC_PORTABLE:
+        return TCXONC;
+    case TCFLSH_PORTABLE:
+        return TCFLSH;
+    case TIOCEXCL_PORTABLE:
+        return TIOCEXCL;
+    case TIOCNXCL_PORTABLE:
+        return TIOCNXCL;
+    case TIOCSCTTY_PORTABLE:
+        return TIOCSCTTY;
+    case TIOCGPGRP_PORTABLE:
+        return TIOCGPGRP;
+    case TIOCSPGRP_PORTABLE:
+        return TIOCSPGRP;
+    case TIOCOUTQ_PORTABLE:
+        return TIOCOUTQ;
+    case TIOCSTI_PORTABLE:
+        return TIOCSTI;
+    case TIOCGWINSZ_PORTABLE:
+        return TIOCGWINSZ;
+    case TIOCSWINSZ_PORTABLE:
+        return TIOCSWINSZ;
+    case TIOCMGET_PORTABLE:
+        return TIOCMGET;
+    case TIOCMBIS_PORTABLE:
+        return TIOCMBIS;
+    case TIOCMBIC_PORTABLE:
+        return TIOCMBIC;
+    case TIOCMSET_PORTABLE:
+        return TIOCMSET;
+    case TIOCGSOFTCAR_PORTABLE:
+        return TIOCGSOFTCAR;
+    case TIOCSSOFTCAR_PORTABLE:
+        return TIOCSSOFTCAR;
+    case FIONREAD_PORTABLE:
+        return FIONREAD;
+    /* case TIOCINQ_PORTABLE: // same as FIONREAD_PORTABLE
+        return TIOCINQ; */
+    case TIOCLINUX_PORTABLE:
+        return TIOCLINUX;
+    case TIOCCONS_PORTABLE:
+        return TIOCCONS;
+    case TIOCGSERIAL_PORTABLE:
+        return TIOCGSERIAL;
+    case TIOCSSERIAL_PORTABLE:
+        return TIOCSSERIAL;
+    case TIOCPKT_PORTABLE:
+        return TIOCPKT;
+    case FIONBIO_PORTABLE:
+        return FIONBIO;
+    case TIOCNOTTY_PORTABLE:
+        return TIOCNOTTY;
+    case TIOCSETD_PORTABLE:
+        return TIOCSETD;
+    case TIOCGETD_PORTABLE:
+        return TIOCGETD;
+    case TCSBRKP_PORTABLE:
+        return TCSBRKP;
+    case TIOCSBRK_PORTABLE:
+        return TIOCSBRK;
+    case TIOCCBRK_PORTABLE:
+        return TIOCCBRK;
+    case TIOCGSID_PORTABLE:
+        return TIOCGSID;
+    case FIONCLEX_PORTABLE:
+        return FIONCLEX;
+    case FIOCLEX_PORTABLE:
+        return FIOCLEX;
+    case FIOASYNC_PORTABLE:
+        return FIOASYNC;
+    case TIOCSERCONFIG_PORTABLE:
+        return TIOCSERCONFIG;
+    case TIOCSERGWILD_PORTABLE:
+        return TIOCSERGWILD;
+    case TIOCSERSWILD_PORTABLE:
+        return TIOCSERSWILD;
+    case TIOCGLCKTRMIOS_PORTABLE:
+        return TIOCGLCKTRMIOS;
+    case TIOCSLCKTRMIOS_PORTABLE:
+        return TIOCSLCKTRMIOS;
+    case TIOCSERGSTRUCT_PORTABLE:
+        return TIOCSERGSTRUCT;
+    case TIOCSERGETLSR_PORTABLE:
+        return TIOCSERGETLSR;
+    case TIOCSERGETMULTI_PORTABLE:
+        return TIOCSERGETMULTI;
+    case TIOCSERSETMULTI_PORTABLE:
+        return TIOCSERSETMULTI;
+    case TIOCMIWAIT_PORTABLE:
+        return TIOCMIWAIT;
+    case TIOCGICOUNT_PORTABLE:
+        return TIOCGICOUNT;
+    case FIOQSIZE_PORTABLE:
+        return FIOQSIZE;
+    case TIOCPKT_DATA_PORTABLE:
+        return TIOCPKT_DATA;
+    case TIOCPKT_FLUSHREAD_PORTABLE:
+        return TIOCPKT_FLUSHREAD;
+    case TIOCPKT_FLUSHWRITE_PORTABLE:
+        return TIOCPKT_FLUSHWRITE;
+    case TIOCPKT_STOP_PORTABLE:
+        return TIOCPKT_STOP;
+    case TIOCPKT_START_PORTABLE:
+        return TIOCPKT_START;
+    case TIOCPKT_NOSTOP_PORTABLE:
+        return TIOCPKT_NOSTOP;
+    case TIOCPKT_DOSTOP_PORTABLE:
+        return TIOCPKT_DOSTOP;
+    /* case TIOCSER_TEMT_PORTABLE: // = 1 same as TIOCPKT_FLUSHREAD_PORTABLE
+        return TIOCSER_TEMT; */
+    case TIOCGPTN_PORTABLE:
+        return TIOCGPTN;
+    case TIOCSPTLCK_PORTABLE:
+        return TIOCSPTLCK;
+#ifdef USE_OLD_TTY
+    case TIOCGETD_PORTABLE:
+        return TIOCGETD;
+    case TIOCSETD_PORTABLE:
+        return TIOCSETD;
+#else
+    case OTIOCGETD_PORTABLE:
+        return OTIOCGETD;
+    case OTIOCSETD_PORTABLE:
+        return OTIOCSETD;
+#endif
+    case TIOCHPCL_PORTABLE:
+        return TIOCHPCL;
+    case TIOCGETP_PORTABLE:
+        return TIOCGETP;
+    case TIOCSETP_PORTABLE:
+        return TIOCSETP;
+    case TIOCSETN_PORTABLE:
+        return TIOCSETN;
+    case TIOCSETC_PORTABLE:
+        return TIOCSETC;
+    case TIOCGETC_PORTABLE:
+        return TIOCGETC;
+    case TIOCLBIS_PORTABLE:
+        return TIOCLBIS;
+    case TIOCLBIC_PORTABLE:
+        return TIOCLBIC;
+    case TIOCLSET_PORTABLE:
+        return TIOCLSET;
+    case TIOCLGET_PORTABLE:
+        return TIOCLGET;
+    case TIOCSLTC_PORTABLE:
+        return TIOCSLTC;
+    case TIOCGLTC_PORTABLE:
+        return TIOCGLTC;
+    case OTIOCCONS_PORTABLE:
+        return OTIOCCONS;
+    case FIOSETOWN_PORTABLE:
+        return FIOSETOWN;
+    case SIOCSPGRP_PORTABLE:
+        return SIOCSPGRP;
+    case FIOGETOWN_PORTABLE:
+        return FIOGETOWN;
+    case SIOCGPGRP_PORTABLE:
+        return SIOCGPGRP;
+    case SIOCATMARK_PORTABLE:
+        return SIOCATMARK;
+    case SIOCGSTAMP_PORTABLE:
+        return SIOCGSTAMP;
+    }
+    return request;
+}
+
+extern int __ioctl(int, int, void *);
+int ioctl_portable(int fd, int request, ...)
+{
+    va_list ap;
+    void * arg;
+
+    va_start(ap, request);
+    arg = va_arg(ap, void *);
+    va_end(ap);
+
+    return __ioctl(fd, mips_change_request(request), arg);
+}
diff --git a/ndk/sources/android/libportable/arch-mips/mmap.c b/ndk/sources/android/libportable/arch-mips/mmap.c
new file mode 100644
index 0000000..d165e2b
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/mmap.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2012, 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 <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <mman_portable.h>
+
+#if MAP_ANONYMOUS_PORTABLE==MAP_ANONYMOUS
+#error Bad build environment
+#endif
+
+static inline int mips_change_prot(int prot)
+{
+    /* Only PROT_SEM is different */
+    if (prot & PROT_SEM_PORTABLE) {
+        prot &= ~PROT_SEM_PORTABLE;
+        prot |= PROT_SEM;
+    }
+
+    return prot;
+}
+
+static inline int mips_change_flags(int flags)
+{
+    int mipsflags = 0;
+    if (flags & MAP_SHARED_PORTABLE)
+       mipsflags |= MAP_SHARED;
+    if (flags & MAP_PRIVATE_PORTABLE)
+       mipsflags |= MAP_PRIVATE;
+    if (flags & MAP_FIXED_PORTABLE)
+       mipsflags |= MAP_FIXED;
+    if (flags & MAP_ANONYMOUS_PORTABLE)
+       mipsflags |= MAP_ANONYMOUS;
+    if (flags & MAP_GROWSDOWN_PORTABLE)
+       mipsflags |= MAP_GROWSDOWN;
+    if (flags & MAP_DENYWRITE_PORTABLE)
+       mipsflags |= MAP_DENYWRITE;
+    if (flags & MAP_EXECUTABLE_PORTABLE)
+       mipsflags |= MAP_EXECUTABLE;
+    if (flags & MAP_LOCKED_PORTABLE)
+       mipsflags |= MAP_LOCKED;
+    if (flags & MAP_NORESERVE_PORTABLE)
+       mipsflags |= MAP_NORESERVE;
+    if (flags & MAP_POPULATE_PORTABLE)
+       mipsflags |= MAP_POPULATE;
+    if (flags & MAP_NONBLOCK_PORTABLE)
+       mipsflags |= MAP_NONBLOCK;
+
+    return mipsflags;
+}
+
+#define  MMAP2_SHIFT  12
+extern void *__mmap2(void *, size_t, int, int, int, size_t);
+void *mmap_portable(void *addr, size_t size, int prot, int flags, int fd, long offset)
+{
+    void *ret;
+    int mips_prot, mips_flags;
+
+    if (offset & ((1UL << MMAP2_SHIFT)-1)) {
+        errno = EINVAL;
+        return MAP_FAILED;
+    }
+
+    mips_prot = mips_change_prot(prot);
+    mips_flags = mips_change_flags(flags);
+    ret = __mmap2(addr, size, mips_prot, mips_flags, fd,
+                  (size_t)offset >> MMAP2_SHIFT);
+
+    if (ret && (mips_flags & (MAP_PRIVATE | MAP_ANONYMOUS)))
+            madvise(ret, size, MADV_MERGEABLE);
+
+    return ret;
+}
+
+extern int    mprotect(const void *, size_t, int);
+int mprotect_portable(const void *addr, size_t size, int prot)
+{
+    return mprotect(addr, size, mips_change_prot(prot));
+}
diff --git a/ndk/sources/android/libportable/arch-mips/open.c b/ndk/sources/android/libportable/arch-mips/open.c
new file mode 100644
index 0000000..2f4dcd7
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/open.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2012, 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 <unistd.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <fcntl_portable.h>
+
+
+#if O_CREAT_PORTABLE==O_CREAT
+#error Bad build environment
+#endif
+
+static inline int mips_change_flags(int flags)
+{
+    int mipsflags = flags & O_ACCMODE_PORTABLE;
+    if (flags & O_CREAT_PORTABLE)
+	mipsflags |= O_CREAT;
+    if (flags & O_EXCL_PORTABLE)
+	mipsflags |= O_EXCL;
+    if (flags & O_NOCTTY_PORTABLE)
+	mipsflags |= O_NOCTTY;
+    if (flags & O_TRUNC_PORTABLE)
+	mipsflags |= O_TRUNC;
+    if (flags & O_APPEND_PORTABLE)
+	mipsflags |= O_APPEND;
+    if (flags & O_NONBLOCK_PORTABLE)
+	mipsflags |= O_NONBLOCK;
+    if (flags & O_SYNC_PORTABLE)
+	mipsflags |= O_SYNC;
+    if (flags & FASYNC_PORTABLE)
+	mipsflags |= FASYNC;
+    if (flags & O_DIRECT_PORTABLE)
+	mipsflags |= O_DIRECT;
+    if (flags & O_LARGEFILE_PORTABLE)
+	mipsflags |= O_LARGEFILE;
+    if (flags & O_DIRECTORY_PORTABLE)
+	mipsflags |= O_DIRECTORY;
+    if (flags & O_NOFOLLOW_PORTABLE)
+	mipsflags |= O_NOFOLLOW;
+    if (flags & O_NOATIME_PORTABLE)
+	mipsflags |= O_NOATIME;
+    if (flags & O_NDELAY_PORTABLE)
+	mipsflags |= O_NDELAY;
+
+    return mipsflags;
+}
+
+extern int  __open(const char*, int, int);
+int open_portable(const char *pathname, int flags, ...)
+{
+    mode_t  mode = 0;
+    flags |= O_LARGEFILE_PORTABLE;
+
+    if (flags & O_CREAT_PORTABLE)
+    {
+        va_list  args;
+
+        va_start(args, flags);
+        mode = (mode_t) va_arg(args, int);
+        va_end(args);
+    }
+
+    return __open(pathname, mips_change_flags(flags), mode);
+}
+
+extern int  __openat(int, const char*, int, int);
+int openat_portable(int fd, const char *pathname, int flags, ...)
+{
+    mode_t  mode = 0;
+
+    flags |= O_LARGEFILE_PORTABLE;
+
+    if (flags & O_CREAT_PORTABLE)
+    {
+        va_list  args;
+
+        va_start(args, flags);
+        mode = (mode_t) va_arg(args, int);
+        va_end(args);
+    }
+
+    return __openat(fd, pathname, mips_change_flags(flags), mode);
+}
diff --git a/ndk/sources/android/libportable/arch-mips/poll.c b/ndk/sources/android/libportable/arch-mips/poll.c
new file mode 100644
index 0000000..955c094
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/poll.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2012, 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 <poll.h>
+#include <poll_portable.h>
+
+#if POLLWRNORM_PORTABLE==POLLWRNORM
+#error Bad build environment
+#endif
+
+static inline short mips_change_portable_events(short portable_events)
+{
+    /* MIPS has different POLLWRNORM and POLLWRBAND. */
+    if (portable_events & POLLWRNORM_PORTABLE) {
+        portable_events &= ~POLLWRNORM_PORTABLE;
+        portable_events |= POLLWRNORM;
+    }
+    if (portable_events & POLLWRBAND_PORTABLE) {
+        portable_events &= ~POLLWRBAND_PORTABLE;
+        portable_events |= POLLWRBAND;
+    }
+
+    return portable_events;
+}
+
+static inline short change_mips_events(short mips_events)
+{
+    /* MIPS POLLWRNORM equals POLLOUT that is the same as POLLOUT_PORTABLE, so we just update POLLWRBNAD_PORTABLE. */
+    if (mips_events & POLLWRBAND) {
+        mips_events &= ~POLLWRBAND;
+        mips_events |= POLLWRBAND_PORTABLE;
+    }
+
+    return mips_events;
+}
+
+extern int poll(struct pollfd *, nfds_t, long);
+
+int poll_portable(struct pollfd *fds, nfds_t nfds, long timeout)
+{
+  nfds_t i;
+  int ret;
+
+  for (i = 0; i < nfds; i++)
+      fds->events = mips_change_portable_events(fds->events);
+
+  ret = poll(fds, nfds, timeout);
+
+  for (i = 0; i < nfds; i++) {
+      fds->events = change_mips_events(fds->events);
+      fds->revents = change_mips_events(fds->revents);
+  }
+
+  return ret;
+}
diff --git a/ndk/sources/android/libportable/arch-mips/resource.c b/ndk/sources/android/libportable/arch-mips/resource.c
new file mode 100644
index 0000000..4119e79
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/resource.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2012, 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 <sys/resource.h>
+#include <resource_portable.h>
+
+#if RLIMIT_NOFILE_PORTABLE==RLIMIT_NOFILE
+#error Bad build environment
+#endif
+
+static inline int mips_change_resource(int resource)
+{
+    switch(resource) {
+    case RLIMIT_NOFILE_PORTABLE:
+        return RLIMIT_NOFILE;
+    case RLIMIT_AS_PORTABLE:
+        return RLIMIT_AS;
+    case RLIMIT_RSS_PORTABLE:
+        return RLIMIT_RSS;
+    case RLIMIT_NPROC_PORTABLE:
+        return RLIMIT_NPROC;
+    case RLIMIT_MEMLOCK_PORTABLE:
+        return RLIMIT_MEMLOCK;
+    }
+    return resource;
+}
+
+extern int getrlimit(int resource, struct rlimit *rlp);
+int getrlimit_portable(int resource, struct rlimit *rlp)
+{
+    return getrlimit(mips_change_resource(resource), rlp);
+}
+
+extern int setrlimit(int resource, const struct rlimit *rlp);
+int setrlimit_portable(int resource, const struct rlimit *rlp)
+{
+    return setrlimit(mips_change_resource(resource), rlp);
+}
diff --git a/ndk/sources/android/libportable/arch-mips/socket.c b/ndk/sources/android/libportable/arch-mips/socket.c
new file mode 100644
index 0000000..51b8db0
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/socket.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012, 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 <unistd.h>
+#include <sys/socket.h>
+#include <sys/linux-syscalls.h>
+#include <socket_portable.h>
+
+
+#if SOCK_STREAM==SOCK_STREAM_PORTABLE
+#error Bad build environment
+#endif
+
+static inline int mips_change_type(int type)
+{
+    switch (type) {
+      case SOCK_STREAM_PORTABLE: return SOCK_STREAM;
+      case SOCK_DGRAM_PORTABLE: return SOCK_DGRAM;
+      case SOCK_RAW_PORTABLE: return SOCK_RAW;
+      case SOCK_RDM_PORTABLE: return SOCK_RDM;
+      case SOCK_SEQPACKET_PORTABLE: return SOCK_SEQPACKET;
+      case SOCK_PACKET_PORTABLE: return SOCK_PACKET;
+    }
+    return type;
+}
+
+extern int socket(int, int, int);
+
+int socket_portable(int domain, int type, int protocol) {
+    return socket(domain, mips_change_type(type), protocol);
+}
diff --git a/ndk/sources/android/libportable/arch-mips/sockopt.c b/ndk/sources/android/libportable/arch-mips/sockopt.c
new file mode 100644
index 0000000..fda4049
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/sockopt.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2012, 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 <sys/types.h>
+#include <sys/socket.h>
+#include <socket_portable.h>
+
+
+#if SOL_SOCKET_PORTABLE==SOL_SOCKET
+#error Build environment
+#endif
+
+static inline int mips_change_level(int level)
+{
+    switch (level) {
+    case SOL_SOCKET_PORTABLE:
+	level = SOL_SOCKET;
+	break;
+    }
+    return level;
+}
+
+
+static inline int mips_change_optname(int optname)
+{
+    switch (optname) {
+    case SO_DEBUG_PORTABLE:
+	return SO_DEBUG;
+    case SO_REUSEADDR_PORTABLE:
+	return SO_REUSEADDR;
+    case SO_TYPE_PORTABLE:
+	return SO_TYPE;
+    case SO_ERROR_PORTABLE:
+	return SO_ERROR;
+    case SO_DONTROUTE_PORTABLE:
+	return SO_DONTROUTE;
+    case SO_BROADCAST_PORTABLE:
+	return SO_BROADCAST;
+    case SO_SNDBUF_PORTABLE:
+	return SO_SNDBUF;
+    case SO_RCVBUF_PORTABLE:
+	return SO_RCVBUF;
+    case SO_SNDBUFFORCE_PORTABLE:
+	return SO_SNDBUFFORCE;
+    case SO_RCVBUFFORCE_PORTABLE:
+	return SO_RCVBUFFORCE;
+    case SO_KEEPALIVE_PORTABLE:
+	return SO_KEEPALIVE;
+    case SO_OOBINLINE_PORTABLE:
+	return SO_OOBINLINE;
+    case SO_NO_CHECK_PORTABLE:
+	return SO_NO_CHECK;
+    case SO_PRIORITY_PORTABLE:
+	return SO_PRIORITY;
+    case SO_LINGER_PORTABLE:
+	return SO_LINGER;
+    case SO_BSDCOMPAT_PORTABLE:
+	return SO_BSDCOMPAT;
+    case SO_PASSCRED_PORTABLE:
+	return SO_PASSCRED;
+    case SO_PEERCRED_PORTABLE:
+	return SO_PEERCRED;
+    case SO_RCVLOWAT_PORTABLE:
+	return SO_RCVLOWAT;
+    case SO_SNDLOWAT_PORTABLE:
+	return SO_SNDLOWAT;
+    case SO_RCVTIMEO_PORTABLE:
+	return SO_RCVTIMEO;
+    case SO_SNDTIMEO_PORTABLE:
+	return SO_SNDTIMEO;
+    case SO_SECURITY_AUTHENTICATION_PORTABLE:
+	return SO_SECURITY_AUTHENTICATION;
+    case SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE:
+	return SO_SECURITY_ENCRYPTION_TRANSPORT;
+    case SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE:
+	return SO_SECURITY_ENCRYPTION_NETWORK;
+    case SO_BINDTODEVICE_PORTABLE:
+	return SO_BINDTODEVICE;
+    case SO_ATTACH_FILTER_PORTABLE:
+	return SO_ATTACH_FILTER;
+    case SO_DETACH_FILTER_PORTABLE:
+	return SO_DETACH_FILTER;
+    case SO_PEERNAME_PORTABLE:
+	return SO_PEERNAME;
+    case SO_TIMESTAMP_PORTABLE:
+	return SO_TIMESTAMP;
+    case SO_ACCEPTCONN_PORTABLE:
+	return SO_ACCEPTCONN;
+    case SO_PEERSEC_PORTABLE:
+	return SO_PEERSEC;
+    case SO_PASSSEC_PORTABLE:
+	return SO_PASSSEC;
+    }
+    return optname;
+}
+
+extern int setsockopt(int, int, int, const void *, socklen_t);
+int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
+{
+    return setsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
+}
+
+extern int getsockopt (int, int, int, void *, socklen_t *);
+int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
+{
+    return getsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
+}
diff --git a/ndk/sources/android/libportable/arch-mips/stat.c b/ndk/sources/android/libportable/arch-mips/stat.c
new file mode 100644
index 0000000..6af5eee
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/stat.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012, 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 <stat_portable.h>
+
+/* Note: The Portable Header will define stat to stat_portable */
+int stat_portable(const char *path, struct stat_portable *s)
+{
+    struct stat mips_stat;
+    int ret = stat(path, &mips_stat);
+    stat_ntop(&mips_stat, s);
+    return ret;
+}
+
+int fstat_portable(int fd, struct stat_portable *s)
+{
+    struct stat mips_stat;
+    int ret = fstat(fd, &mips_stat);
+    stat_ntop(&mips_stat, s);
+    return ret;
+}   
+
+int lstat_portable(const char *path, struct stat_portable *s)
+{
+    struct stat mips_stat;
+    int ret = lstat(path, &mips_stat);
+    stat_ntop(&mips_stat, s);
+    return ret;
+}
+
+int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
+{
+    struct stat mips_stat;
+    int ret = fstatat(dirfd, path, &mips_stat, flags);
+    stat_ntop(&mips_stat, s);
+    return ret;
+}
diff --git a/ndk/sources/android/libportable/arch-mips/statfs.c b/ndk/sources/android/libportable/arch-mips/statfs.c
new file mode 100644
index 0000000..cd8b5af
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/statfs.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012, 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 <statfs_portable.h>
+#include <string.h>
+
+static inline void statfs_ntop(struct statfs *n_statfs, struct statfs_portable *p_statfs)
+{
+    memset(p_statfs, '\0', sizeof(struct statfs_portable));
+    p_statfs->f_type = n_statfs->f_type;
+    p_statfs->f_bsize = n_statfs->f_bsize;
+    p_statfs->f_blocks = n_statfs->f_blocks;
+    p_statfs->f_bfree = n_statfs->f_bfree;
+    p_statfs->f_bavail = n_statfs->f_bavail;
+    p_statfs->f_files = n_statfs->f_files;
+    p_statfs->f_ffree = n_statfs->f_ffree;
+    p_statfs->f_fsid = n_statfs->f_fsid;
+    p_statfs->f_namelen = n_statfs->f_namelen;
+    p_statfs->f_frsize = n_statfs->f_frsize;
+}
+
+int statfs_portable(const char*  path, struct statfs_portable*  stat)
+{
+    struct statfs mips_stat;
+    int ret = statfs(path, &mips_stat);
+    statfs_ntop(&mips_stat, stat);
+    return ret;
+}
+
+int fstatfs_portable(int fd, struct statfs_portable*  stat)
+{
+    struct statfs mips_stat;
+    int ret = fstatfs(fd, &mips_stat);
+    statfs_ntop(&mips_stat, stat);
+    return ret;
+}
diff --git a/ndk/sources/android/libportable/arch-x86/epoll.c b/ndk/sources/android/libportable/arch-x86/epoll.c
new file mode 100644
index 0000000..e2f91f2
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/epoll.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2012, 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 <sys/epoll.h>
+#include <epoll_portable.h>
+
+int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event_portable *event)
+{
+    struct epoll_event x86_epoll_event;
+
+    x86_epoll_event.events = event->events;
+    x86_epoll_event.data = event->data;
+
+    return epoll_ctl(epfd, op, fd, &x86_epoll_event);
+}
+
+int epoll_wait_portable(int epfd, struct epoll_event_portable *events, int max, int timeout)
+{
+    struct epoll_event x86_epoll_event;
+    int ret = epoll_wait(epfd, &x86_epoll_event, max, timeout);
+
+    events->events = x86_epoll_event.events;
+    events->data = x86_epoll_event.data;
+
+    return ret;
+}
+
diff --git a/ndk/sources/android/libportable/arch-x86/errno.c b/ndk/sources/android/libportable/arch-x86/errno.c
new file mode 100644
index 0000000..ffa5998
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/errno.c
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+extern volatile int*   __errno(void);
+volatile int* __errno_portable()
+{
+  return __errno();
+}
diff --git a/ndk/sources/android/libportable/arch-x86/fcntl.c b/ndk/sources/android/libportable/arch-x86/fcntl.c
new file mode 100644
index 0000000..7561f85
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/fcntl.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012, 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 <fcntl.h>
+#include <stdarg.h>
+#include <fcntl_portable.h>
+
+extern int __fcntl64(int, int, void *);
+
+int fcntl_portable(int fd, int cmd, ...)
+{
+    va_list ap;
+    void * arg;
+
+    va_start(ap, cmd);
+    arg = va_arg(ap, void *);
+    va_end(ap);
+
+    if (cmd == F_GETLK64 || 
+        cmd == F_SETLK64 ||
+        cmd == F_SETLKW64) {
+        struct flock64 x86_flock64;
+        int result = __fcntl64(fd, cmd, (void *) &x86_flock64);
+
+        struct flock64_portable * flock64 = (struct flock64_portable *) arg;
+
+        flock64->l_type = x86_flock64.l_type;
+        flock64->l_whence = x86_flock64.l_whence;
+        flock64->l_start = x86_flock64.l_start;
+        flock64->l_len = x86_flock64.l_len;
+        flock64->l_pid = x86_flock64.l_pid;
+
+        return result;
+    }
+    else {
+        return __fcntl64(fd, cmd, arg);
+    }
+}
+
diff --git a/ndk/sources/android/libportable/arch-x86/ioctl.c b/ndk/sources/android/libportable/arch-x86/ioctl.c
new file mode 100644
index 0000000..ea88c30
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/ioctl.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012, 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 <stdarg.h>
+#include <sys/ioctl.h>
+#include <ioctls_portable.h>
+
+#if FIOQSIZE_PORTABLE == FIOQSIZE
+#error Bad build environment
+#endif
+
+static inline int x86_change_request(int request)
+{
+    if (request == FIOQSIZE_PORTABLE)
+        return FIOQSIZE;
+
+    return request;
+}
+
+extern int __ioctl(int, int, void *);
+int ioctl_portable(int fd, int request, ...)
+{
+    va_list ap;
+    void * arg;
+
+    va_start(ap, request);
+    arg = va_arg(ap, void *);
+    va_end(ap);
+
+    return __ioctl(fd, x86_change_request(request), arg);
+}
diff --git a/ndk/sources/android/libportable/arch-x86/open.c b/ndk/sources/android/libportable/arch-x86/open.c
new file mode 100644
index 0000000..a38f38c
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/open.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2012, 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 <unistd.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <fcntl_portable.h>
+
+
+static inline int x86_change_flags(int flags)
+{
+    int x86flags = flags & O_ACCMODE_PORTABLE;
+    if (flags & O_CREAT_PORTABLE)
+        x86flags |= O_CREAT;
+    if (flags & O_EXCL_PORTABLE)
+        x86flags |= O_EXCL;
+    if (flags & O_NOCTTY_PORTABLE)
+        x86flags |= O_NOCTTY;
+    if (flags & O_TRUNC_PORTABLE)
+        x86flags |= O_TRUNC;
+    if (flags & O_APPEND_PORTABLE)
+        x86flags |= O_APPEND;
+    if (flags & O_NONBLOCK_PORTABLE)
+        x86flags |= O_NONBLOCK;
+    if (flags & O_SYNC_PORTABLE)
+        x86flags |= O_SYNC;
+    if (flags & FASYNC_PORTABLE)
+        x86flags |= FASYNC;
+    if (flags & O_DIRECT_PORTABLE)
+        x86flags |= O_DIRECT;
+    if (flags & O_LARGEFILE_PORTABLE)
+        x86flags |= O_LARGEFILE;
+    if (flags & O_DIRECTORY_PORTABLE)
+        x86flags |= O_DIRECTORY;
+    if (flags & O_NOFOLLOW_PORTABLE)
+        x86flags |= O_NOFOLLOW;
+    if (flags & O_NOATIME_PORTABLE)
+        x86flags |= O_NOATIME;
+    if (flags & O_NDELAY_PORTABLE)
+        x86flags |= O_NDELAY;
+
+    return x86flags;
+}
+
+extern int  __open(const char*, int, int);
+int open_portable(const char *pathname, int flags, ...)
+{
+    mode_t  mode = 0;
+    flags |= O_LARGEFILE;
+
+    if (flags & O_CREAT)
+    {
+        va_list  args;
+
+        va_start(args, flags);
+        mode = (mode_t) va_arg(args, int);
+        va_end(args);
+    }
+
+    return __open(pathname, x86_change_flags(flags), mode);
+}
diff --git a/ndk/sources/android/libportable/arch-x86/socket.c b/ndk/sources/android/libportable/arch-x86/socket.c
new file mode 100644
index 0000000..7e7ca9b
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/socket.c
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2012, 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 <unistd.h>
+#include <sys/socket.h>
+#include <sys/linux-syscalls.h>
+
+int socket_portable(int domain, int type, int protocol) {
+    return socket(domain, type, protocol);
+}
diff --git a/ndk/sources/android/libportable/arch-x86/sockopt.c b/ndk/sources/android/libportable/arch-x86/sockopt.c
new file mode 100644
index 0000000..c86ded3
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/sockopt.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012, 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 <sys/types.h>
+#include <sys/socket.h>
+
+extern int setsockopt(int, int, int, const void *, socklen_t);
+int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
+{
+    return setsockopt(s, level, optname, optval, optlen);
+}
+
+extern int getsockopt (int, int, int, void *, socklen_t *);
+int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
+{
+    return getsockopt(s, level, optname, optval, optlen);
+}
diff --git a/ndk/sources/android/libportable/arch-x86/stat.c b/ndk/sources/android/libportable/arch-x86/stat.c
new file mode 100644
index 0000000..6b368c8
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/stat.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012, 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 <stat_portable.h>
+
+/* Note: The Portable Header will define stat to stat_portable */
+int stat_portable(const char *path, struct stat_portable *s)
+{
+    struct stat x86_stat;
+    int ret = stat(path, &x86_stat);
+    stat_ntop(&x86_stat, s);
+    return ret;
+}
+
+int fstat_portable(int fd, struct stat_portable *s)
+{
+    struct stat x86_stat;
+    int ret = fstat(fd, &x86_stat);
+    stat_ntop(&x86_stat, s);
+    return ret;
+}   
+
+int lstat_portable(const char *path, struct stat_portable *s)
+{
+    struct stat x86_stat;
+    int ret = lstat(path, &x86_stat);
+    stat_ntop(&x86_stat, s);
+    return ret;
+}
+
+int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
+{
+    struct stat x86_stat;
+    int ret = fstatat(dirfd, path, &x86_stat, flags);
+    stat_ntop(&x86_stat, s);
+    return ret;
+}
diff --git a/ndk/sources/android/libportable/common/include/epoll_portable.h b/ndk/sources/android/libportable/common/include/epoll_portable.h
new file mode 100644
index 0000000..9007ba6
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/epoll_portable.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2012, 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 _EPOLL_PORTABLE_H_
+#define _EPOLL_PORTABLE_H_
+
+/*
+ * GDK's compiler generates paddings to guarantee 8-byte alignment on
+ * struct and 64bit POD types. If compilers on your platform have no such
+ * alignment rule, please use the following struct and convert it into your
+ * native struct form.
+ */
+struct epoll_event_portable
+{
+  unsigned int events;
+  unsigned char __padding[4];
+  epoll_data_t data;
+};
+
+#endif /* _EPOLL_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/errno_portable.h b/ndk/sources/android/libportable/common/include/errno_portable.h
new file mode 100644
index 0000000..c2f6523
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/errno_portable.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2012, 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 _ERRNO_PORTABLE_H_
+#define _ERRNO_PORTABLE_H_
+
+/* Derived from development/ndk/platforms/android-3/include/asm-generic/errno.h */
+#define EDEADLK_PORTABLE 35
+#define ENAMETOOLONG_PORTABLE 36
+#define ENOLCK_PORTABLE 37
+#define ENOSYS_PORTABLE 38
+#define ENOTEMPTY_PORTABLE 39
+#define ELOOP_PORTABLE 40
+#define EWOULDBLOCK_PORTABLE 11 /* EAGAIN */
+#define ENOMSG_PORTABLE 42
+#define EIDRM_PORTABLE 43
+#define ECHRNG_PORTABLE 44
+#define EL2NSYNC_PORTABLE 45
+#define EL3HLT_PORTABLE 46
+#define EL3RST_PORTABLE 47
+#define ELNRNG_PORTABLE 48
+#define EUNATCH_PORTABLE 49
+#define ENOCSI_PORTABLE 50
+#define EL2HLT_PORTABLE 51
+#define EBADE_PORTABLE 52
+#define EBADR_PORTABLE 53
+#define EXFULL_PORTABLE 54
+#define ENOANO_PORTABLE 55
+#define EBADRQC_PORTABLE 56
+#define EBADSLT_PORTABLE 57
+
+#define EDEADLOCK_PORTABLE EDEADLK_PORTABLE
+
+#define EBFONT_PORTABLE 59
+#define ENOSTR_PORTABLE 60
+#define ENODATA_PORTABLE 61
+#define ETIME_PORTABLE 62
+#define ENOSR_PORTABLE 63
+#define ENONET_PORTABLE 64
+#define ENOPKG_PORTABLE 65
+#define EREMOTE_PORTABLE 66
+#define ENOLINK_PORTABLE 67
+#define EADV_PORTABLE 68
+#define ESRMNT_PORTABLE 69
+#define ECOMM_PORTABLE 70
+#define EPROTO_PORTABLE 71
+#define EMULTIHOP_PORTABLE 72
+#define EDOTDOT_PORTABLE 73
+#define EBADMSG_PORTABLE 74
+#define EOVERFLOW_PORTABLE 75
+#define ENOTUNIQ_PORTABLE 76
+#define EBADFD_PORTABLE 77
+#define EREMCHG_PORTABLE 78
+#define ELIBACC_PORTABLE 79
+#define ELIBBAD_PORTABLE 80
+#define ELIBSCN_PORTABLE 81
+#define ELIBMAX_PORTABLE 82
+#define ELIBEXEC_PORTABLE 83
+#define EILSEQ_PORTABLE 84
+#define ERESTART_PORTABLE 85
+#define ESTRPIPE_PORTABLE 86
+#define EUSERS_PORTABLE 87
+#define ENOTSOCK_PORTABLE 88
+#define EDESTADDRREQ_PORTABLE 89
+#define EMSGSIZE_PORTABLE 90
+#define EPROTOTYPE_PORTABLE 91
+#define ENOPROTOOPT_PORTABLE 92
+#define EPROTONOSUPPORT_PORTABLE 93
+#define ESOCKTNOSUPPORT_PORTABLE 94
+#define EOPNOTSUPP_PORTABLE 95
+#define EPFNOSUPPORT_PORTABLE 96
+#define EAFNOSUPPORT_PORTABLE 97
+#define EADDRINUSE_PORTABLE 98
+#define EADDRNOTAVAIL_PORTABLE 99
+#define ENETDOWN_PORTABLE 100
+#define ENETUNREACH_PORTABLE 101
+#define ENETRESET_PORTABLE 102
+#define ECONNABORTED_PORTABLE 103
+#define ECONNRESET_PORTABLE 104
+#define ENOBUFS_PORTABLE 105
+#define EISCONN_PORTABLE 106
+#define ENOTCONN_PORTABLE 107
+#define ESHUTDOWN_PORTABLE 108
+#define ETOOMANYREFS_PORTABLE 109
+#define ETIMEDOUT_PORTABLE 110
+#define ECONNREFUSED_PORTABLE 111
+#define EHOSTDOWN_PORTABLE 112
+#define EHOSTUNREACH_PORTABLE 113
+#define EALREADY_PORTABLE 114
+#define EINPROGRESS_PORTABLE 115
+#define ESTALE_PORTABLE 116
+#define EUCLEAN_PORTABLE 117
+#define ENOTNAM_PORTABLE 118
+#define ENAVAIL_PORTABLE 119
+#define EISNAM_PORTABLE 120
+#define EREMOTEIO_PORTABLE 121
+#define EDQUOT_PORTABLE 122
+
+#define ENOMEDIUM_PORTABLE 123
+#define EMEDIUMTYPE_PORTABLE 124
+#define ECANCELED_PORTABLE 125
+#define ENOKEY_PORTABLE 126
+#define EKEYEXPIRED_PORTABLE 127
+#define EKEYREVOKED_PORTABLE 128
+#define EKEYREJECTED_PORTABLE 129
+
+#define EOWNERDEAD_PORTABLE 130
+#define ENOTRECOVERABLE_PORTABLE 131
+
+#endif /* _ERRNO_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/fcntl_portable.h b/ndk/sources/android/libportable/common/include/fcntl_portable.h
new file mode 100644
index 0000000..7240ad3
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/fcntl_portable.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2012, 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 _FCNTL_PORTABLE_H_
+#define _FCNTL_PORTABLE_H_
+
+/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/fcntl.h */
+/* NB x86 does not have these and only uses the generic definitions */
+#define O_DIRECTORY_PORTABLE    040000
+#define O_NOFOLLOW_PORTABLE     0100000
+#define O_DIRECT_PORTABLE       0200000
+#define O_LARGEFILE_PORTABLE    0400000
+
+/* Derived from development/ndk/platforms/android-3/include/asm-generic/fcntl.h */
+#define O_ACCMODE_PORTABLE  00000003
+#define O_RDONLY_PORTABLE   00000000
+#define O_WRONLY_PORTABLE   00000001
+#define O_RDWR_PORTABLE     00000002
+#ifndef O_CREAT_PORTABLE
+#define O_CREAT_PORTABLE    00000100
+#endif
+#ifndef O_EXCL_PORTABLE
+#define O_EXCL_PORTABLE     00000200
+#endif
+#ifndef O_NOCTTY_PORTABLE
+#define O_NOCTTY_PORTABLE   00000400
+#endif
+#ifndef O_TRUNC_PORTABLE
+#define O_TRUNC_PORTABLE    00001000
+#endif
+#ifndef O_APPEND_PORTABLE
+#define O_APPEND_PORTABLE   00002000
+#endif
+#ifndef O_NONBLOCK_PORTABLE
+#define O_NONBLOCK_PORTABLE 00004000
+#endif
+#ifndef O_SYNC_PORTABLE
+#define O_SYNC_PORTABLE     00010000
+#endif
+#ifndef FASYNC_PORTABLE
+#define FASYNC_PORTABLE     00020000
+#endif
+#ifndef O_DIRECT_PORTABLE
+#define O_DIRECT_PORTABLE   00040000
+#endif
+#ifndef O_LARGEFILE_PORTABLE
+#define O_LARGEFILE_PORTABLE    00100000
+#endif
+#ifndef O_DIRECTORY_PORTABLE
+#define O_DIRECTORY_PORTABLE    00200000
+#endif
+#ifndef O_NOFOLLOW_PORTABLE
+#define O_NOFOLLOW_PORTABLE 00400000
+#endif
+#ifndef O_NOATIME_PORTABLE
+#define O_NOATIME_PORTABLE  01000000
+#endif
+#ifndef O_NDELAY_PORTABLE
+#define O_NDELAY_PORTABLE   O_NONBLOCK_PORTABLE
+#endif
+
+struct flock64_portable {
+   short l_type;
+   short l_whence;
+   unsigned char __padding[4];
+   loff_t l_start;
+   loff_t l_len;
+   pid_t l_pid;
+   __ARCH_FLOCK64_PAD
+};
+
+/*
+The X86 Version is
+
+struct flock64 {
+   short l_type;
+   short l_whence;
+   loff_t l_start;
+   loff_t l_len;
+   pid_t l_pid;
+   __ARCH_FLOCK64_PAD
+};
+*/
+
+#ifndef F_GETLK_PORTABLE
+#define F_GETLK_PORTABLE 5
+#define F_SETLK_PORTABLE 6
+#define F_SETLKW_PORTABLE 7
+#endif
+#ifndef F_SETOWN_PORTABLE
+#define F_SETOWN_PORTABLE 8
+#define F_GETOWN_PORTABLE 9
+#endif
+
+#ifndef F_GETLK64_PORTABLE
+#define F_GETLK64_PORTABLE 12
+#define F_SETLK64_PORTABLE 13
+#define F_SETLKW64_PORTABLE 14
+#endif
+
+#endif /* _FCNTL_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/ioctls_portable.h b/ndk/sources/android/libportable/common/include/ioctls_portable.h
new file mode 100644
index 0000000..e9e977c
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/ioctls_portable.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2012, 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 _IOCTLS_PORTABLE_H_
+#define _IOCTLS_PORTABLE_H_
+
+/* Derived from development/ndk/platforms/android-3/include/asm-generic/ioctl.h */
+
+#define _IOC_NRBITS_PORTABLE 8
+#define _IOC_TYPEBITS_PORTABLE 8
+#define _IOC_SIZEBITS_PORTABLE 14
+#define _IOC_DIRBITS_PORTABLE 2
+
+#define _IOC_NRMASK_PORTABLE ((1 << _IOC_NRBITS_PORTABLE)-1)
+#define _IOC_TYPEMASK_PORTABLE ((1 << _IOC_TYPEBITS_PORTABLE)-1)
+#define _IOC_SIZEMASK_PORTABLE ((1 << _IOC_SIZEBITS_PORTABLE)-1)
+#define _IOC_DIRMASK_PORTABLE ((1 << _IOC_DIRBITS_PORTABLE)-1)
+
+#define _IOC_NRSHIFT_PORTABLE 0
+#define _IOC_TYPESHIFT_PORTABLE (_IOC_NRSHIFT_PORTABLE+_IOC_NRBITS_PORTABLE)
+#define _IOC_SIZESHIFT_PORTABLE (_IOC_TYPESHIFT_PORTABLE+_IOC_TYPEBITS_PORTABLE)
+#define _IOC_DIRSHIFT_PORTABLE (_IOC_SIZESHIFT_PORTABLE+_IOC_SIZEBITS_PORTABLE)
+
+#define _IOC_NONE_PORTABLE 0U
+#define _IOC_WRITE_PORTABLE 1U
+#define _IOC_READ_PORTABLE 2U
+
+#define _IOC_PORTABLE(dir,type,nr,size)   (((dir) << _IOC_DIRSHIFT_PORTABLE) |   ((type) << _IOC_TYPESHIFT_PORTABLE) |   ((nr) << _IOC_NRSHIFT_PORTABLE) |   ((size) << _IOC_SIZESHIFT_PORTABLE))
+
+extern unsigned int __invalid_size_argument_for_IOC;
+#define _IOC_TYPECHECK_PORTABLE(t)   ((sizeof(t) == sizeof(t[1]) &&   sizeof(t) < (1 << _IOC_SIZEBITS_PORTABLE)) ?   sizeof(t) : __invalid_size_argument_for_IOC)
+
+#define _IO_PORTABLE(type,nr) _IOC_PORTABLE(_IOC_NONE_PORTABLE,(type),(nr),0)
+#define _IOR_PORTABLE(type,nr,size) _IOC_PORTABLE(_IOC_READ_PORTABLE,(type),(nr),(_IOC_TYPECHECK_PORTABLE(size)))
+#define _IOW_PORTABLE(type,nr,size) _IOC_PORTABLE(_IOC_WRITE_PORTABLE,(type),(nr),(_IOC_TYPECHECK_PORTABLE(size)))
+#define _IOWR_PORTABLE(type,nr,size) _IOC_PORTABLE(_IOC_READ_PORTABLE|_IOC_WRITE_PORTABLE,(type),(nr),(_IOC_TYPECHECK_PORTABLE(size)))
+
+/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/ioctls.h */
+
+#define TCGETS_PORTABLE     0x5401
+#define TCSETS_PORTABLE     0x5402
+#define TCSETSW_PORTABLE    0x5403
+#define TCSETSF_PORTABLE    0x5404
+#define TCGETA_PORTABLE     0x5405
+#define TCSETA_PORTABLE     0x5406
+#define TCSETAW_PORTABLE    0x5407
+#define TCSETAF_PORTABLE    0x5408
+#define TCSBRK_PORTABLE     0x5409
+#define TCXONC_PORTABLE     0x540A
+#define TCFLSH_PORTABLE     0x540B
+#define TIOCEXCL_PORTABLE   0x540C
+#define TIOCNXCL_PORTABLE   0x540D
+#define TIOCSCTTY_PORTABLE  0x540E
+#define TIOCGPGRP_PORTABLE  0x540F
+#define TIOCSPGRP_PORTABLE  0x5410
+#define TIOCOUTQ_PORTABLE   0x5411
+#define TIOCSTI_PORTABLE    0x5412
+#define TIOCGWINSZ_PORTABLE 0x5413
+#define TIOCSWINSZ_PORTABLE 0x5414
+#define TIOCMGET_PORTABLE   0x5415
+#define TIOCMBIS_PORTABLE   0x5416
+#define TIOCMBIC_PORTABLE   0x5417
+#define TIOCMSET_PORTABLE   0x5418
+#define TIOCGSOFTCAR_PORTABLE   0x5419
+#define TIOCSSOFTCAR_PORTABLE   0x541A
+#define FIONREAD_PORTABLE   0x541B
+#define TIOCINQ_PORTABLE    FIONREAD_PORTABLE
+#define TIOCLINUX_PORTABLE  0x541C
+#define TIOCCONS_PORTABLE   0x541D
+#define TIOCGSERIAL_PORTABLE    0x541E
+#define TIOCSSERIAL_PORTABLE    0x541F
+#define TIOCPKT_PORTABLE    0x5420
+#define FIONBIO_PORTABLE    0x5421
+#define TIOCNOTTY_PORTABLE  0x5422
+#define TIOCSETD_PORTABLE   0x5423
+#define TIOCGETD_PORTABLE   0x5424
+#define TCSBRKP_PORTABLE    0x5425
+#define TIOCSBRK_PORTABLE   0x5427
+#define TIOCCBRK_PORTABLE   0x5428
+#define TIOCGSID_PORTABLE   0x5429
+#define TIOCGPTN_PORTABLE _IOR_PORTABLE('T',0x30, unsigned int)
+#define TIOCSPTLCK_PORTABLE _IOW_PORTABLE('T',0x31, int)
+
+#define FIONCLEX_PORTABLE   0x5450
+#define FIOCLEX_PORTABLE    0x5451
+#define FIOASYNC_PORTABLE   0x5452
+#define TIOCSERCONFIG_PORTABLE  0x5453
+#define TIOCSERGWILD_PORTABLE   0x5454
+#define TIOCSERSWILD_PORTABLE   0x5455
+#define TIOCGLCKTRMIOS_PORTABLE 0x5456
+#define TIOCSLCKTRMIOS_PORTABLE 0x5457
+#define TIOCSERGSTRUCT_PORTABLE 0x5458
+#define TIOCSERGETLSR_PORTABLE  0x5459
+#define TIOCSERGETMULTI_PORTABLE 0x545A
+#define TIOCSERSETMULTI_PORTABLE 0x545B
+
+#define TIOCMIWAIT_PORTABLE     0x545C
+#define TIOCGICOUNT_PORTABLE    0x545D
+#define FIOQSIZE_PORTABLE       0x545E /* x86 differs here */
+
+#define TIOCPKT_DATA_PORTABLE       0
+#define TIOCPKT_FLUSHREAD_PORTABLE  1
+#define TIOCPKT_FLUSHWRITE_PORTABLE 2
+#define TIOCPKT_STOP_PORTABLE       4
+#define TIOCPKT_START_PORTABLE      8
+#define TIOCPKT_NOSTOP_PORTABLE     16
+#define TIOCPKT_DOSTOP_PORTABLE     32
+
+#define TIOCSER_TEMT_PORTABLE   0x01
+
+/* Derived from development/ndk/platforms/android-3/include/sys/ioctl_compat.h */
+
+struct tchars_portable {
+        char    t_intrc;        /* interrupt */
+        char    t_quitc;        /* quit */
+        char    t_startc;       /* start output */
+        char    t_stopc;        /* stop output */
+        char    t_eofc;         /* end-of-file */
+        char    t_brkc;         /* input delimiter (like nl) */
+};
+
+struct ltchars_portable {
+        char    t_suspc;        /* stop process signal */
+        char    t_dsuspc;       /* delayed stop process signal */
+        char    t_rprntc;       /* reprint line */
+        char    t_flushc;       /* flush output (toggles) */
+        char    t_werasc;       /* word erase */
+        char    t_lnextc;       /* literal next character */
+};
+
+struct sgttyb_portable {
+        char    sg_ispeed;              /* input speed */
+        char    sg_ospeed;              /* output speed */
+        char    sg_erase;               /* erase character */
+        char    sg_kill;                /* kill character */
+        short   sg_flags;               /* mode flags */
+};
+
+#ifdef USE_OLD_TTY
+# define TIOCGETD_PORTABLE   _IOR_PORTABLE('t', 0, int)       /* get line discipline */
+# define TIOCSETD_PORTABLE   _IOW_PORTABLE('t', 1, int)       /* set line discipline */
+#else
+# define OTIOCGETD_PORTABLE  _IOR_PORTABLE('t', 0, int)       /* get line discipline */
+# define OTIOCSETD_PORTABLE  _IOW_PORTABLE('t', 1, int)       /* set line discipline */
+#endif
+#define TIOCHPCL_PORTABLE    _IO_PORTABLE('t', 2)             /* hang up on last close */
+#define TIOCGETP_PORTABLE    _IOR_PORTABLE('t', 8,struct sgttyb_portable)/* get parameters -- gtty */
+#define TIOCSETP_PORTABLE    _IOW_PORTABLE('t', 9,struct sgttyb_portable)/* set parameters -- stty */
+#define TIOCSETN_PORTABLE    _IOW_PORTABLE('t',10,struct sgttyb_portable)/* as above, but no flushtty*/
+#define TIOCSETC_PORTABLE    _IOW_PORTABLE('t',17,struct tchars_portable)/* set special characters */
+#define TIOCGETC_PORTABLE    _IOR_PORTABLE('t',18,struct tchars_portable)/* get special characters */
+
+#define TIOCLBIS_PORTABLE    _IOW_PORTABLE('t', 127, int)     /* bis local mode bits */
+#define TIOCLBIC_PORTABLE    _IOW_PORTABLE('t', 126, int)     /* bic local mode bits */
+#define TIOCLSET_PORTABLE    _IOW_PORTABLE('t', 125, int)     /* set entire local mode word */
+#define TIOCLGET_PORTABLE    _IOR_PORTABLE('t', 124, int)     /* get local modes */
+#define TIOCSLTC_PORTABLE    _IOW_PORTABLE('t',117,struct ltchars_portable)/* set local special chars*/
+#define TIOCGLTC_PORTABLE    _IOR_PORTABLE('t',116,struct ltchars_portable)/* get local special chars*/
+#define OTIOCCONS_PORTABLE   _IO_PORTABLE('t', 98)    /* for hp300 -- sans int arg */
+
+/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/sockios.h */
+
+#define FIOSETOWN_PORTABLE 0x8901
+#define SIOCSPGRP_PORTABLE 0x8902
+#define FIOGETOWN_PORTABLE 0x8903
+#define SIOCGPGRP_PORTABLE 0x8904
+#define SIOCATMARK_PORTABLE 0x8905
+#define SIOCGSTAMP_PORTABLE 0x8906
+
+#endif /* _IOCTLS_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/mman_portable.h b/ndk/sources/android/libportable/common/include/mman_portable.h
new file mode 100644
index 0000000..a655cba
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/mman_portable.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012, 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 _MMAN_PORTABLE_H_
+#define _MMAN_PORTABLE_H_
+
+/* Derived from development/ndk/platforms/android-3/include/asm-generic/mman.h */
+#define PROT_READ_PORTABLE     0x1
+#define PROT_WRITE_PORTABLE    0x2
+#define PROT_EXEC_PORTABLE     0x4
+#define PROT_SEM_PORTABLE      0x8
+#define PROT_NONE_PORTABLE     0x0
+#define PROT_GROWSDOWN_PORTABLE 0x01000000
+#define PROT_GROWSUP_PORTABLE   0x02000000
+
+#define MAP_SHARED_PORTABLE    0x01
+#define MAP_PRIVATE_PORTABLE   0x02
+#define MAP_TYPE_PORTABLE      0x0f
+#define MAP_FIXED_PORTABLE     0x10
+#define MAP_ANONYMOUS_PORTABLE 0x20
+
+#define MS_ASYNC_PORTABLE      1
+#define MS_INVALIDATE_PORTABLE 2
+#define MS_SYNC_PORTABLE       4
+
+#define MADV_NORMAL_PORTABLE   0
+#define MADV_RANDOM_PORTABLE   1
+#define MADV_SEQUENTIAL_PORTABLE 2
+#define MADV_WILLNEED_PORTABLE 3
+#define MADV_DONTNEED_PORTABLE 4
+
+#define MADV_REMOVE_PORTABLE   9
+#define MADV_DONTFORK_PORTABLE 10
+#define MADV_DOFORK_PORTABLE   11
+
+#define MAP_ANON_PORTABLE      MAP_ANONYMOUS_PORTABLE
+#define MAP_FILE_PORTABLE      0
+
+/* Derived from development/ndk/platforms/android-3/include/asm-generic/mman.h */
+#define MAP_GROWSDOWN_PORTABLE 0x0100
+#define MAP_DENYWRITE_PORTABLE 0x0800
+#define MAP_EXECUTABLE_PORTABLE        0x1000
+#define MAP_LOCKED_PORTABLE    0x2000
+#define MAP_NORESERVE_PORTABLE 0x4000
+#define MAP_POPULATE_PORTABLE  0x8000
+#define MAP_NONBLOCK_PORTABLE  0x10000
+
+#define MCL_CURRENT_PORTABLE   1
+#define MCL_FUTURE_PORTABLE    2
+
+#endif /* _MMAN_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/poll_portable.h b/ndk/sources/android/libportable/common/include/poll_portable.h
new file mode 100644
index 0000000..4004d18
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/poll_portable.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012, 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 _POLL_PORTABLE_H_
+#define _POLL_PORTABLE_H_
+
+/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/poll.h */
+
+#define POLLIN_PORTABLE 0x0001
+#define POLLPRI_PORTABLE 0x0002
+#define POLLOUT_PORTABLE 0x0004
+#define POLLERR_PORTABLE 0x0008
+#define POLLHUP_PORTABLE 0x0010
+#define POLLNVAL_PORTABLE 0x0020
+
+#define POLLRDNORM_PORTABLE 0x0040
+#define POLLRDBAND_PORTABLE 0x0080
+#define POLLWRNORM_PORTABLE 0x0100
+#define POLLWRBAND_PORTABLE 0x0200
+#define POLLMSG_PORTABLE 0x0400
+#define POLLREMOVE_PORTABLE 0x1000
+#define POLLRDHUP_PORTABLE 0x2000
+
+#endif /* _POLL_PORTABLE_H_ */
diff --git a/ndk/sources/android/libportable/common/include/resource_portable.h b/ndk/sources/android/libportable/common/include/resource_portable.h
new file mode 100644
index 0000000..a0486d9
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/resource_portable.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2012, 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 _RESOURCE_PORTABLE_H_
+#define _RESOURCE_PORTABLE_H_
+
+/* Derived from development/ndk/platforms/android-3/include/asm-generic/resource.h */
+
+#define RLIMIT_CPU_PORTABLE 0
+#define RLIMIT_FSIZE_PORTABLE 1
+#define RLIMIT_DATA_PORTABLE 2
+#define RLIMIT_STACK_PORTABLE 3
+#define RLIMIT_CORE_PORTABLE 4
+
+#ifndef RLIMIT_RSS_PORTABLE
+#define RLIMIT_RSS_PORTABLE 5
+#endif
+
+#ifndef RLIMIT_NPROC_PORTABLE
+#define RLIMIT_NPROC_PORTABLE 6
+#endif
+
+#ifndef RLIMIT_NOFILE_PORTABLE
+#define RLIMIT_NOFILE_PORTABLE 7
+#endif
+
+#ifndef RLIMIT_MEMLOCK_PORTABLE
+#define RLIMIT_MEMLOCK_PORTABLE 8
+#endif
+
+#ifndef RLIMIT_AS_PORTABLE
+#define RLIMIT_AS_PORTABLE 9
+#endif
+
+#define RLIMIT_LOCKS_PORTABLE 10
+#define RLIMIT_SIGPENDING_PORTABLE 11
+#define RLIMIT_MSGQUEUE_PORTABLE 12
+#define RLIMIT_NICE_PORTABLE 13
+#define RLIMIT_RTPRIO_PORTABLE 14
+#define RLIMIT_RTTIME_PORTABLE 15
+
+#define RLIM_NLIMITS_PORTABLE 16
+
+#ifndef RLIM_INFINITY_PORTABLE
+#define RLIM_INFINITY_PORTABLE (~0UL)
+#endif
+
+#ifndef _STK_LIM_MAX_PORTABLE
+#define _STK_LIM_MAX_PORTABLE RLIM_INFINITY_PORTABLE
+#endif
+
+#endif /* _RESOURCE_PORTABLE_H_ */
diff --git a/ndk/sources/android/libportable/common/include/socket_portable.h b/ndk/sources/android/libportable/common/include/socket_portable.h
new file mode 100644
index 0000000..ff1f9c4
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/socket_portable.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2012, 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 _SOCKET_PORTABLE_H_
+#define _SOCKET_PORTABLE_H_
+
+/* Derived from development/ndk/platforms/android-3/include/sys/socket.h */
+#define SOCK_STREAM_PORTABLE    1
+#define SOCK_DGRAM_PORTABLE     2
+#define SOCK_RAW_PORTABLE       3
+#define SOCK_RDM_PORTABLE       4
+#define SOCK_SEQPACKET_PORTABLE 5
+#define SOCK_PACKET_PORTABLE    10
+
+
+/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/socket.h */
+
+#define SOL_SOCKET_PORTABLE     1
+
+#define SO_DEBUG_PORTABLE       1
+#define SO_REUSEADDR_PORTABLE   2
+#define SO_TYPE_PORTABLE        3
+#define SO_ERROR_PORTABLE       4
+#define SO_DONTROUTE_PORTABLE   5
+#define SO_BROADCAST_PORTABLE   6
+#define SO_SNDBUF_PORTABLE      7
+#define SO_RCVBUF_PORTABLE      8
+#define SO_SNDBUFFORCE_PORTABLE 32
+#define SO_RCVBUFFORCE_PORTABLE 33
+#define SO_KEEPALIVE_PORTABLE   9
+#define SO_OOBINLINE_PORTABLE   10
+#define SO_NO_CHECK_PORTABLE    11
+#define SO_PRIORITY_PORTABLE    12
+#define SO_LINGER_PORTABLE      13
+#define SO_BSDCOMPAT_PORTABLE   14
+
+#define SO_PASSCRED_PORTABLE    16
+#define SO_PEERCRED_PORTABLE    17
+#define SO_RCVLOWAT_PORTABLE    18
+#define SO_SNDLOWAT_PORTABLE    19
+#define SO_RCVTIMEO_PORTABLE    20
+#define SO_SNDTIMEO_PORTABLE    21
+
+#define SO_SECURITY_AUTHENTICATION_PORTABLE         22
+#define SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE   23
+#define SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE     24
+
+#define SO_BINDTODEVICE_PORTABLE    25
+
+#define SO_ATTACH_FILTER_PORTABLE   26
+#define SO_DETACH_FILTER_PORTABLE   27
+
+#define SO_PEERNAME_PORTABLE        28
+#define SO_TIMESTAMP_PORTABLE       29
+#define SCM_TIMESTAMP_PORTABLE SO_TIMESTAMP_PORTABLE
+
+#define SO_ACCEPTCONN_PORTABLE      30
+
+#define SO_PEERSEC_PORTABLE     31
+#define SO_PASSSEC_PORTABLE     34
+
+#endif /* _SOCKET_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/stat_portable.h b/ndk/sources/android/libportable/common/include/stat_portable.h
new file mode 100644
index 0000000..d50291d
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/stat_portable.h
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2012, 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 _STAT_PORTABLE_H_
+#define _STAT_PORTABLE_H_
+
+#include <sys/stat.h>
+#include <string.h>
+
+/* It's easy to change kernel to support stat */
+struct stat_portable {
+    unsigned long long  st_dev;
+    unsigned char       __pad0[4];
+
+    unsigned long       __st_ino;
+    unsigned int        st_mode;
+    unsigned int        st_nlink;
+
+    unsigned long       st_uid;
+    unsigned long       st_gid;
+
+    unsigned long long  st_rdev;
+    unsigned char       __pad3[4];
+
+    unsigned char       __pad4[4];
+    long long           st_size;
+    unsigned long       st_blksize;
+    unsigned char       __pad5[4];
+    unsigned long long  st_blocks;
+
+    unsigned long       st_atime;
+    unsigned long       st_atime_nsec;
+
+    unsigned long       st_mtime;
+    unsigned long       st_mtime_nsec;
+
+    unsigned long       st_ctime;
+    unsigned long       st_ctime_nsec;
+
+    unsigned long long  st_ino;
+};
+
+/*
+The X86 Version is
+struct stat {
+    unsigned long long  st_dev;
+    unsigned char       __pad0[4];
+
+    unsigned long       __st_ino;
+    unsigned int        st_mode;
+    unsigned int        st_nlink;
+
+    unsigned long       st_uid;
+    unsigned long       st_gid;
+
+    unsigned long long  st_rdev;
+    unsigned char       __pad3[4];
+
+    long long           st_size;
+    unsigned long       st_blksize;
+    unsigned long long  st_blocks;
+
+    unsigned long       st_atime;
+    unsigned long       st_atime_nsec;
+
+    unsigned long       st_mtime;
+    unsigned long       st_mtime_nsec;
+
+    unsigned long       st_ctime;
+    unsigned long       st_ctime_nsec;
+
+    unsigned long long  st_ino;
+};
+*/
+
+/*
+The MIPS Version is
+struct stat {
+    unsigned long       st_dev;
+    unsigned long       __pad0[3];
+
+    unsigned long long  st_ino;
+
+    unsigned int        st_mode;
+    unsigned int        st_nlink;
+
+    unsigned long       st_uid;
+    unsigned long       st_gid;
+
+    unsigned long       st_rdev;
+    unsigned long       __pad1[3];
+
+    long long           st_size;
+
+    unsigned long       st_atime;
+    unsigned long       st_atime_nsec;
+
+    unsigned long       st_mtime;
+    unsigned long       st_mtime_nsec;
+
+    unsigned long       st_ctime;
+    unsigned long       st_ctime_nsec;
+
+    unsigned long       st_blksize;
+    unsigned long       __pad2;
+
+    unsigned long long  st_blocks;
+};
+*/
+
+static inline void stat_ntop(struct stat *n_stat, struct stat_portable *p_stat)
+{
+    memset(p_stat, '\0', sizeof(struct stat_portable));
+    p_stat->st_dev        = n_stat->st_dev;
+#if defined(__mips__)
+    /* MIPS doesn't have __st_ino */
+    p_stat->__st_ino      = 0;
+#else
+    p_stat->__st_ino      = n_stat->__st_ino;
+#endif
+    p_stat->st_mode       = n_stat->st_mode;
+    p_stat->st_nlink      = n_stat->st_nlink;
+    p_stat->st_uid        = n_stat->st_uid;
+    p_stat->st_gid        = n_stat->st_gid;
+    p_stat->st_rdev       = n_stat->st_rdev;
+    p_stat->st_size       = n_stat->st_size;
+    p_stat->st_blksize    = n_stat->st_blksize;
+    p_stat->st_blocks     = n_stat->st_blocks;
+    p_stat->st_atime      = n_stat->st_atime;
+    p_stat->st_atime_nsec = n_stat->st_atime_nsec;
+    p_stat->st_mtime      = n_stat->st_mtime;
+    p_stat->st_mtime_nsec = n_stat->st_mtime_nsec;
+    p_stat->st_ctime      = n_stat->st_ctime;
+    p_stat->st_ctime_nsec = n_stat->st_ctime_nsec;
+    p_stat->st_ino        = n_stat->st_ino;
+}
+
+#endif /* _STAT_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/statfs_portable.h b/ndk/sources/android/libportable/common/include/statfs_portable.h
new file mode 100644
index 0000000..23451ea
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/statfs_portable.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012, 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 _STATFS_PORTABLE_H_
+#define _STATFS_PORTABLE_H_
+
+#include <sys/vfs.h>
+
+/* It's easy to change kernel to support statfs */
+struct statfs_portable {
+    uint32_t        f_type;
+    uint32_t        f_bsize;
+    uint64_t        f_blocks;
+    uint64_t        f_bfree;
+    uint64_t        f_bavail;
+    uint64_t        f_files;
+    uint64_t        f_ffree;
+    __kernel_fsid_t f_fsid;
+    uint32_t        f_namelen;
+    uint32_t        f_frsize;
+    uint32_t        f_spare[5];
+};
+
+/*
+The MIPS Version is
+struct statfs {
+    uint32_t        f_type;
+    uint32_t        f_bsize;
+    uint32_t        f_frsize;
+    uint32_t        __pad;
+    uint64_t        f_blocks;
+    uint64_t        f_bfree;
+    uint64_t        f_files;
+    uint64_t        f_ffree;
+    uint64_t        f_bavail;
+    __kernel_fsid_t f_fsid;
+    uint32_t        f_namelen;
+    uint32_t        f_spare[6];
+};
+*/
+#endif /* _STATFS_PORTABLE_H_ */
diff --git a/samples/ActionBarCompat/AndroidManifest.xml b/samples/ActionBarCompat/AndroidManifest.xml
index 1a48274..a78339b 100644
--- a/samples/ActionBarCompat/AndroidManifest.xml
+++ b/samples/ActionBarCompat/AndroidManifest.xml
@@ -20,6 +20,8 @@
     android:versionName="1.0">
 
     <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="14" />
+    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
+    <supports-screens android:largeScreens="true"/>
 
     <application android:label="@string/app_name"
         android:icon="@drawable/ic_launcher"
diff --git a/samples/ApiDemos/Android.mk b/samples/ApiDemos/Android.mk
index 7921120..066c497 100644
--- a/samples/ApiDemos/Android.mk
+++ b/samples/ApiDemos/Android.mk
@@ -10,6 +10,8 @@
         src/com/example/android/apis/app/IRemoteServiceCallback.aidl \
         src/com/example/android/apis/app/ISecondary.aidl \
 
+LOCAL_JAVA_LIBRARIES := telephony-common mms-common
+
 LOCAL_PACKAGE_NAME := ApiDemos
 
 LOCAL_SDK_VERSION := current
diff --git a/samples/ApiDemos/res/layout/linear_layout_5.xml b/samples/ApiDemos/res/layout/linear_layout_5.xml
index b5d45c0..a0ff63b 100644
--- a/samples/ApiDemos/res/layout/linear_layout_5.xml
+++ b/samples/ApiDemos/res/layout/linear_layout_5.xml
@@ -35,16 +35,10 @@
 
     <!--
         Followed by the EditText field...
-
-        Also give it a standard background (the "android:"
-        part in @android:drawable/editbox_background
-        means it is system resource rather than
-        an application resource.
     -->
     <EditText
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="@android:drawable/editbox_background"/>
+        android:layout_height="wrap_content"/>
 
     <!--
         Use a horizontal layout to hold the two buttons.
diff --git a/samples/ApiDemos/res/layout/relative_layout_2.xml b/samples/ApiDemos/res/layout/relative_layout_2.xml
index 083953a..87a5377 100644
--- a/samples/ApiDemos/res/layout/relative_layout_2.xml
+++ b/samples/ApiDemos/res/layout/relative_layout_2.xml
@@ -33,16 +33,11 @@
 
     <!--
         Put the EditText field under the TextView
-        Also give it a standard background (the "android:"
-        part in @android:drawable/editbox_background
-        means it is system resource rather than
-        an application resource.
     -->
     <EditText
         android:id="@+id/entry"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@android:drawable/editbox_background"
         android:layout_below="@id/label"/>
 
     <!--
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java b/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java
index 11c1bc2..df6752c 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java
@@ -52,7 +52,9 @@
 
     public void onRemoveTab(View v) {
         final ActionBar bar = getActionBar();
-        bar.removeTabAt(bar.getTabCount() - 1);
+        if (bar.getTabCount() > 0) {
+            bar.removeTabAt(bar.getTabCount() - 1);
+        }
     }
 
     public void onToggleTabs(View v) {
diff --git a/samples/BackupRestore/AndroidManifest.xml b/samples/BackupRestore/AndroidManifest.xml
index af86634..bccd4f7 100644
--- a/samples/BackupRestore/AndroidManifest.xml
+++ b/samples/BackupRestore/AndroidManifest.xml
@@ -26,6 +26,7 @@
 
     <!-- The backup/restore mechanism was introduced in API version 8 -->
     <uses-sdk android:minSdkVersion="8"/>
+    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
 
     <application android:label="Backup/Restore"
         android:backupAgent="ExampleAgent">
diff --git a/samples/CrossCompatibility/AndroidManifest.xml b/samples/CrossCompatibility/AndroidManifest.xml
index 1097a4d..43eb4ff 100644
--- a/samples/CrossCompatibility/AndroidManifest.xml
+++ b/samples/CrossCompatibility/AndroidManifest.xml
@@ -3,6 +3,11 @@
       package="com.example.android.touchexample"
       android:versionCode="1"
       android:versionName="1.0">
+
+    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8" />
+    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
+    <supports-screens android:largeScreens="true"/>
+
     <application android:icon="@drawable/icon" android:label="@string/app_name">
         <activity android:name=".TouchExampleActivity"
                   android:label="@string/app_name">
@@ -13,5 +18,5 @@
         </activity>
 
     </application>
-    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8" />
+
 </manifest>
diff --git a/samples/CrossCompatibility/src/com/example/android/touchexample/TouchExample b/samples/CrossCompatibility/src/com/example/android/touchexample/TouchExample
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/samples/CrossCompatibility/src/com/example/android/touchexample/TouchExample
diff --git a/samples/Snake/AndroidManifest.xml b/samples/Snake/AndroidManifest.xml
index 36a9939..757a2d6 100644
--- a/samples/Snake/AndroidManifest.xml
+++ b/samples/Snake/AndroidManifest.xml
@@ -14,22 +14,31 @@
      limitations under the License.
 -->
 
-<!-- Declare the contents of this Android application.  The namespace
-     attribute brings in the Android platform namespace, and the package
-     supplies a unique name for the application.  When writing your
-     own application, the package name must be changed from "com.example.*"
-     to come from a domain that you own or have control over. -->
+<!-- Declare the contents of this Android application. The namespace attribute 
+  brings in the Android platform namespace, and the package supplies a unique 
+  name for the application. When writing your own application, the package 
+  name must be changed from "com.example.*" to come from a domain that you 
+  own or have control over. -->
+
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.example.android.snake">
-    <application android:label="Snake on a Phone">
-      <activity android:name="Snake"
-        android:theme="@android:style/Theme.NoTitleBar"
-        android:screenOrientation="portrait"
-        android:configChanges="keyboardHidden|orientation">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-    </application>
-</manifest> 
+  package="com.example.android.snake">
+
+  <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="15" />
+  <!-- Declares that the app supports devices w/o touch, such as a Google TV device -->
+  <uses-feature android:name="android.hardware.touchscreen"
+    android:required="false" />
+
+  <supports-screens android:largeScreens="true" />
+
+  <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
+    <activity android:name="Snake" android:configChanges="keyboardHidden|orientation"
+      android:screenOrientation="nosensor" android:theme="@android:style/Theme.NoTitleBar">
+      <intent-filter>
+        <action android:name="android.intent.action.MAIN" />
+
+        <category android:name="android.intent.category.LAUNCHER" />
+      </intent-filter>
+    </activity>
+  </application>
+
+</manifest>
diff --git a/samples/Snake/res/drawable-hdpi/ic_launcher.png b/samples/Snake/res/drawable-hdpi/ic_launcher.png
new file mode 100755
index 0000000..b500381
--- /dev/null
+++ b/samples/Snake/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/samples/Snake/res/drawable-ldpi/ic_launcher.png b/samples/Snake/res/drawable-ldpi/ic_launcher.png
new file mode 100755
index 0000000..f0efb98
--- /dev/null
+++ b/samples/Snake/res/drawable-ldpi/ic_launcher.png
Binary files differ
diff --git a/samples/Snake/res/drawable-mdpi/dpad_down.xml b/samples/Snake/res/drawable-mdpi/dpad_down.xml
new file mode 100755
index 0000000..1b635a2
--- /dev/null
+++ b/samples/Snake/res/drawable-mdpi/dpad_down.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<rotate xmlns:android="http://schemas.android.com/apk/res/android"
+        android:fromDegrees="180"
+        android:toDegrees="180"
+        android:pivotX="50%"
+        android:pivotY="50%"
+        android:drawable="@drawable/dpad_up"/>
diff --git a/samples/Snake/res/drawable-mdpi/dpad_left.xml b/samples/Snake/res/drawable-mdpi/dpad_left.xml
new file mode 100755
index 0000000..b9f9648
--- /dev/null
+++ b/samples/Snake/res/drawable-mdpi/dpad_left.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<rotate xmlns:android="http://schemas.android.com/apk/res/android"
+        android:fromDegrees="-90"
+        android:toDegrees="-90"
+        android:pivotX="50%"
+        android:pivotY="50%"
+        android:drawable="@drawable/dpad_up"/>
diff --git a/samples/Snake/res/drawable-mdpi/dpad_right.xml b/samples/Snake/res/drawable-mdpi/dpad_right.xml
new file mode 100755
index 0000000..15b35d6
--- /dev/null
+++ b/samples/Snake/res/drawable-mdpi/dpad_right.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<rotate xmlns:android="http://schemas.android.com/apk/res/android"
+   android:fromDegrees="90"
+   android:toDegrees="90"
+   android:pivotX="50%"
+   android:pivotY="50%"
+   android:drawable="@drawable/dpad_up"/>
diff --git a/samples/Snake/res/drawable-mdpi/dpad_up.png b/samples/Snake/res/drawable-mdpi/dpad_up.png
new file mode 100755
index 0000000..01d6511
--- /dev/null
+++ b/samples/Snake/res/drawable-mdpi/dpad_up.png
Binary files differ
diff --git a/samples/Snake/res/drawable/greenstar.png b/samples/Snake/res/drawable-mdpi/greenstar.png
old mode 100644
new mode 100755
similarity index 100%
rename from samples/Snake/res/drawable/greenstar.png
rename to samples/Snake/res/drawable-mdpi/greenstar.png
Binary files differ
diff --git a/samples/Snake/res/drawable-mdpi/ic_launcher.png b/samples/Snake/res/drawable-mdpi/ic_launcher.png
new file mode 100755
index 0000000..31d5bbd
--- /dev/null
+++ b/samples/Snake/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/samples/Snake/res/drawable/redstar.png b/samples/Snake/res/drawable-mdpi/redstar.png
old mode 100644
new mode 100755
similarity index 100%
rename from samples/Snake/res/drawable/redstar.png
rename to samples/Snake/res/drawable-mdpi/redstar.png
Binary files differ
diff --git a/samples/Snake/res/drawable/yellowstar.png b/samples/Snake/res/drawable-mdpi/yellowstar.png
old mode 100644
new mode 100755
similarity index 100%
rename from samples/Snake/res/drawable/yellowstar.png
rename to samples/Snake/res/drawable-mdpi/yellowstar.png
Binary files differ
diff --git a/samples/Snake/res/drawable-xhdpi/ic_launcher.png b/samples/Snake/res/drawable-xhdpi/ic_launcher.png
new file mode 100755
index 0000000..46cfcbf
--- /dev/null
+++ b/samples/Snake/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/samples/Snake/res/layout/snake_layout.xml b/samples/Snake/res/layout/snake_layout.xml
old mode 100644
new mode 100755
index ef8abe3..fc35fb6
--- a/samples/Snake/res/layout/snake_layout.xml
+++ b/samples/Snake/res/layout/snake_layout.xml
@@ -4,9 +4,9 @@
      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.
@@ -14,30 +14,70 @@
      limitations under the License.
 -->
 
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-	android:layout_width="match_parent"
-	android:layout_height="match_parent">
-	
-	<com.example.android.snake.SnakeView
-	 android:id="@+id/snake"
-		android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                tileSize="24"
-                />
-	
-	<RelativeLayout
-		android:layout_width="match_parent"
-		android:layout_height="match_parent" >
-		
-		<TextView
-		 android:id="@+id/text"
-			android:text="@string/snake_layout_text_text"
-			android:visibility="visible"
-			android:layout_width="wrap_content"
-			android:layout_height="wrap_content"
-			android:layout_centerInParent="true"
-			android:gravity="center_horizontal"
-			android:textColor="#ff8888ff"
-			android:textSize="24sp"/>
-	</RelativeLayout>
-</FrameLayout>
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+  xmlns:app="http://schemas.android.com/apk/res/com.example.android.snake">
+
+  <com.example.android.snake.BackgroundView
+    android:id="@+id/background"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    app:colorSegmentOne="@color/muted_red"
+    app:colorSegmentTwo="@color/muted_yellow"
+    app:colorSegmentThree="@color/muted_blue"
+    app:colorSegmentFour="@color/muted_green"
+     />
+
+  <com.example.android.snake.SnakeView
+    android:id="@+id/snake"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    app:tileSize="24dp" />
+
+  <TextView android:id="@+id/text"
+  android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_gravity="center"
+    android:gravity="center"
+    android:textColor="@color/text_violet"
+    android:textSize="24sp"
+    android:visibility="visible" />
+
+  <RelativeLayout android:id="@+id/arrowContainer"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:visibility="gone">
+
+    <ImageView android:id="@+id/imageUp"
+    android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_alignParentTop="true"
+      android:layout_centerHorizontal="true"
+      android:padding="20dp"
+      android:src="@drawable/dpad_up" />
+
+    <ImageView android:id="@+id/imageLeft"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_alignParentLeft="true"
+      android:layout_centerVertical="true"
+      android:padding="20dp"
+      android:src="@drawable/dpad_left" />
+
+    <ImageView android:id="@+id/imageRight"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_alignParentRight="true"
+      android:layout_centerVertical="true"
+      android:padding="20dp"
+      android:src="@drawable/dpad_right" />
+
+    <ImageView android:id="@+id/imageDown"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_alignParentBottom="true"
+      android:layout_centerHorizontal="true"
+      android:padding="20dp"
+      android:src="@drawable/dpad_down" />
+  </RelativeLayout>
+
+</merge>
diff --git a/samples/Snake/res/values-nonav/strings.xml b/samples/Snake/res/values-nonav/strings.xml
new file mode 100755
index 0000000..5b63b12
--- /dev/null
+++ b/samples/Snake/res/values-nonav/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<resources>
+  <string name="app_name">Snake</string>
+  <string name="mode_ready">Snake\nTouch Screen To Play</string>
+  <string name="mode_pause">Paused\nTouch Screen To Resume</string>
+  <string name="mode_lose">Game Over\nScore: %1$d \nTouch Screen To Play</string>
+</resources>
diff --git a/samples/Snake/res/values/attrs.xml b/samples/Snake/res/values/attrs.xml
old mode 100644
new mode 100755
index c846864..6f1d1b4
--- a/samples/Snake/res/values/attrs.xml
+++ b/samples/Snake/res/values/attrs.xml
@@ -4,9 +4,9 @@
      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.
@@ -15,8 +15,16 @@
 -->
 
 <resources>
-  <declare-styleable name="TileView">
-    <attr name="tileSize" format="integer" />
-  </declare-styleable>
-</resources>
 
+  <declare-styleable name="TileView">
+    <attr name="tileSize" format="dimension" />
+  </declare-styleable>
+  <declare-styleable name="BackgroundView">
+  <!-- Defining properties to use four different colors in 4 segments of BackgroundView -->
+    <attr name="colorSegmentOne" format="color" />
+    <attr name="colorSegmentTwo" format="color" />
+    <attr name="colorSegmentThree" format="color" />
+    <attr name="colorSegmentFour" format="color" />
+  </declare-styleable>
+
+</resources>
diff --git a/samples/Snake/res/values/colors.xml b/samples/Snake/res/values/colors.xml
new file mode 100755
index 0000000..e5d90bf
--- /dev/null
+++ b/samples/Snake/res/values/colors.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<resources>
+  <color name="muted_red">#ff400010</color>
+  <color name="muted_yellow">#ff404000</color>
+  <color name="muted_blue">#ff100050</color>
+  <color name="muted_green">#ff004000</color>
+  <color name="text_violet">#ff8888ff</color>
+  </resources>
diff --git a/samples/Snake/res/values/strings.xml b/samples/Snake/res/values/strings.xml
old mode 100644
new mode 100755
index 3c4a89d..f95ef4c
--- a/samples/Snake/res/values/strings.xml
+++ b/samples/Snake/res/values/strings.xml
@@ -4,9 +4,9 @@
      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.
@@ -15,10 +15,8 @@
 -->
 
 <resources>
+  <string name="app_name">Snake</string>
   <string name="mode_ready">Snake\nPress Up To Play</string>
   <string name="mode_pause">Paused\nPress Up To Resume</string>
-  <string name="mode_lose_prefix">Game Over\nScore: </string>
-  <string name="mode_lose_suffix">\nPress Up To Play</string>
-
-    <string name="snake_layout_text_text"></string>
+  <string name="mode_lose">Game Over\nScore: %1$d \nPress Up To Play</string>
 </resources>
diff --git a/samples/Snake/src/com/example/android/snake/BackgroundView.java b/samples/Snake/src/com/example/android/snake/BackgroundView.java
new file mode 100755
index 0000000..bda571e
--- /dev/null
+++ b/samples/Snake/src/com/example/android/snake/BackgroundView.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+package com.example.android.snake;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.view.View;
+
+import java.util.Arrays;
+
+/**
+ * Background View: Draw 4 full-screen RGBY triangles
+ */
+public class BackgroundView extends View {
+
+    private int[] mColors = new int[4];
+
+    private final short[] mIndices =
+            { 0, 1, 2, 0, 3, 4, 0, 1, 4 // Corner points for triangles (with offset = 2)
+    };
+
+    private float[] mVertexPoints = null;
+
+    public BackgroundView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        setFocusable(true);
+
+        // retrieve colors for 4 segments from styleable properties
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BackgroundView);
+        mColors[0] = a.getColor(R.styleable.BackgroundView_colorSegmentOne, Color.RED);
+        mColors[1] = a.getColor(R.styleable.BackgroundView_colorSegmentTwo, Color.YELLOW);
+        mColors[2] = a.getColor(R.styleable.BackgroundView_colorSegmentThree, Color.BLUE);
+        mColors[3] = a.getColor(R.styleable.BackgroundView_colorSegmentFour, Color.GREEN);
+
+        a.recycle();
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        assert(mVertexPoints != null);
+
+        // Colors for each vertex
+        int[] mFillColors = new int[mVertexPoints.length];
+
+        for (int triangle = 0; triangle < mColors.length; triangle++) {
+            // Set color for all vertex points to current triangle color
+            Arrays.fill(mFillColors, mColors[triangle]);
+
+            // Draw one triangle
+            canvas.drawVertices(Canvas.VertexMode.TRIANGLES, mVertexPoints.length, mVertexPoints,
+                    0, null, 0, // No Textures
+                    mFillColors, 0, mIndices,
+                    triangle * 2, 3, // Use 3 vertices via Index Array with offset 2
+                    new Paint());
+        }
+    }
+
+    @Override
+    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+        super.onSizeChanged(w, h, oldw, oldh);
+
+     // Construct our center and four corners
+        mVertexPoints = new float[] {
+                w / 2, h / 2,
+                0, 0,
+                w, 0,
+                w, h,
+                0, h
+        };
+    }
+
+}
diff --git a/samples/Snake/src/com/example/android/snake/Snake.java b/samples/Snake/src/com/example/android/snake/Snake.java
old mode 100644
new mode 100755
index 6306693..ddf0c3c
--- a/samples/Snake/src/com/example/android/snake/Snake.java
+++ b/samples/Snake/src/com/example/android/snake/Snake.java
@@ -18,27 +18,38 @@
 
 import android.app.Activity;
 import android.os.Bundle;
-import android.view.Window;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnTouchListener;
 import android.widget.TextView;
 
 /**
  * Snake: a simple game that everyone can enjoy.
  * 
- * This is an implementation of the classic Game "Snake", in which you control a
- * serpent roaming around the garden looking for apples. Be careful, though,
- * because when you catch one, not only will you become longer, but you'll move
- * faster. Running into yourself or the walls will end the game.
+ * This is an implementation of the classic Game "Snake", in which you control a serpent roaming
+ * around the garden looking for apples. Be careful, though, because when you catch one, not only
+ * will you become longer, but you'll move faster. Running into yourself or the walls will end the
+ * game.
  * 
  */
 public class Snake extends Activity {
 
-    private SnakeView mSnakeView;
-    
+    /**
+     * Constants for desired direction of moving the snake
+     */
+    public static int MOVE_LEFT = 0;
+    public static int MOVE_UP = 1;
+    public static int MOVE_DOWN = 2;
+    public static int MOVE_RIGHT = 3;
+
     private static String ICICLE_KEY = "snake-view";
 
+    private SnakeView mSnakeView;
+
     /**
-     * Called when Activity is first created. Turns off the title bar, sets up
-     * the content views, and fires up the SnakeView.
+     * Called when Activity is first created. Turns off the title bar, sets up the content views,
+     * and fires up the SnakeView.
      * 
      */
     @Override
@@ -48,7 +59,8 @@
         setContentView(R.layout.snake_layout);
 
         mSnakeView = (SnakeView) findViewById(R.id.snake);
-        mSnakeView.setTextView((TextView) findViewById(R.id.text));
+        mSnakeView.setDependentViews((TextView) findViewById(R.id.text),
+                findViewById(R.id.arrowContainer), findViewById(R.id.background));
 
         if (savedInstanceState == null) {
             // We were just launched -- set up a new game
@@ -62,6 +74,31 @@
                 mSnakeView.setMode(SnakeView.PAUSE);
             }
         }
+        mSnakeView.setOnTouchListener(new OnTouchListener() {
+
+            @Override
+            public boolean onTouch(View v, MotionEvent event) {
+                if (mSnakeView.getGameState() == SnakeView.RUNNING) {
+                    // Normalize x,y between 0 and 1
+                    float x = event.getX() / v.getWidth();
+                    float y = event.getY() / v.getHeight();
+
+                    // Direction will be [0,1,2,3] depending on quadrant
+                    int direction = 0;
+                    direction = (x > y) ? 1 : 0;
+                    direction |= (x > 1 - y) ? 2 : 0;
+
+                    // Direction is same as the quadrant which was clicked
+                    mSnakeView.moveSnake(direction);
+
+                } else {
+                    // If the game is not running then on touching any part of the screen
+                    // we start the game by sending MOVE_UP signal to SnakeView
+                    mSnakeView.moveSnake(MOVE_UP);
+                }
+                return false;
+            }
+        });
     }
 
     @Override
@@ -73,8 +110,34 @@
 
     @Override
     public void onSaveInstanceState(Bundle outState) {
-        //Store the game state
+        // Store the game state
         outState.putBundle(ICICLE_KEY, mSnakeView.saveState());
     }
 
+    /**
+     * Handles key events in the game. Update the direction our snake is traveling based on the
+     * DPAD.
+     *
+     */
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent msg) {
+
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_DPAD_UP:
+                mSnakeView.moveSnake(MOVE_UP);
+                break;
+            case KeyEvent.KEYCODE_DPAD_RIGHT:
+                mSnakeView.moveSnake(MOVE_RIGHT);
+                break;
+            case KeyEvent.KEYCODE_DPAD_DOWN:
+                mSnakeView.moveSnake(MOVE_DOWN);
+                break;
+            case KeyEvent.KEYCODE_DPAD_LEFT:
+                mSnakeView.moveSnake(MOVE_LEFT);
+                break;
+        }
+
+        return super.onKeyDown(keyCode, msg);
+    }
+
 }
diff --git a/samples/Snake/src/com/example/android/snake/SnakeView.java b/samples/Snake/src/com/example/android/snake/SnakeView.java
old mode 100644
new mode 100755
index 8dd0232..a8e654f
--- a/samples/Snake/src/com/example/android/snake/SnakeView.java
+++ b/samples/Snake/src/com/example/android/snake/SnakeView.java
@@ -16,33 +16,29 @@
 
 package com.example.android.snake;
 
-import java.util.ArrayList;
-import java.util.Random;
-
 import android.content.Context;
 import android.content.res.Resources;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
 import android.util.AttributeSet;
-import android.os.Bundle;
 import android.util.Log;
-import android.view.KeyEvent;
 import android.view.View;
 import android.widget.TextView;
 
+import java.util.ArrayList;
+import java.util.Random;
+
 /**
  * SnakeView: implementation of a simple game of Snake
- * 
- * 
  */
 public class SnakeView extends TileView {
 
     private static final String TAG = "SnakeView";
 
     /**
-     * Current mode of application: READY to run, RUNNING, or you have already
-     * lost. static final ints are used instead of an enum for performance
-     * reasons.
+     * Current mode of application: READY to run, RUNNING, or you have already lost. static final
+     * ints are used instead of an enum for performance reasons.
      */
     private int mMode = READY;
     public static final int PAUSE = 0;
@@ -68,26 +64,36 @@
     private static final int GREEN_STAR = 3;
 
     /**
-     * mScore: used to track the number of apples captured mMoveDelay: number of
-     * milliseconds between snake movements. This will decrease as apples are
-     * captured.
+     * mScore: Used to track the number of apples captured mMoveDelay: number of milliseconds
+     * between snake movements. This will decrease as apples are captured.
      */
     private long mScore = 0;
     private long mMoveDelay = 600;
     /**
-     * mLastMove: tracks the absolute time when the snake last moved, and is used
-     * to determine if a move should be made based on mMoveDelay.
+     * mLastMove: Tracks the absolute time when the snake last moved, and is used to determine if a
+     * move should be made based on mMoveDelay.
      */
     private long mLastMove;
-    
+
     /**
-     * mStatusText: text shows to the user in some run states
+     * mStatusText: Text shows to the user in some run states
      */
     private TextView mStatusText;
 
     /**
-     * mSnakeTrail: a list of Coordinates that make up the snake's body
-     * mAppleList: the secret location of the juicy apples the snake craves.
+     * mArrowsView: View which shows 4 arrows to signify 4 directions in which the snake can move
+     */
+    private View mArrowsView;
+
+    /**
+     * mBackgroundView: Background View which shows 4 different colored triangles pressing which
+     * moves the snake
+     */
+    private View mBackgroundView;
+
+    /**
+     * mSnakeTrail: A list of Coordinates that make up the snake's body mAppleList: The secret
+     * location of the juicy apples the snake craves.
      */
     private ArrayList<Coordinate> mSnakeTrail = new ArrayList<Coordinate>();
     private ArrayList<Coordinate> mAppleList = new ArrayList<Coordinate>();
@@ -98,10 +104,11 @@
     private static final Random RNG = new Random();
 
     /**
-     * Create a simple handler that we can use to cause animation to happen.  We
-     * set ourselves as a target and we can use the sleep()
-     * function to cause an update/invalidate to occur at a later date.
+     * Create a simple handler that we can use to cause animation to happen. We set ourselves as a
+     * target and we can use the sleep() function to cause an update/invalidate to occur at a later
+     * date.
      */
+
     private RefreshHandler mRedrawHandler = new RefreshHandler();
 
     class RefreshHandler extends Handler {
@@ -113,12 +120,11 @@
         }
 
         public void sleep(long delayMillis) {
-        	this.removeMessages(0);
+            this.removeMessages(0);
             sendMessageDelayed(obtainMessage(0), delayMillis);
         }
     };
 
-
     /**
      * Constructs a SnakeView based on inflation from XML
      * 
@@ -127,26 +133,26 @@
      */
     public SnakeView(Context context, AttributeSet attrs) {
         super(context, attrs);
-        initSnakeView();
-   }
-
-    public SnakeView(Context context, AttributeSet attrs, int defStyle) {
-    	super(context, attrs, defStyle);
-    	initSnakeView();
+        initSnakeView(context);
     }
 
-    private void initSnakeView() {
+    public SnakeView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+        initSnakeView(context);
+    }
+
+    private void initSnakeView(Context context) {
+
         setFocusable(true);
 
         Resources r = this.getContext().getResources();
-        
+
         resetTiles(4);
         loadTile(RED_STAR, r.getDrawable(R.drawable.redstar));
         loadTile(YELLOW_STAR, r.getDrawable(R.drawable.yellowstar));
         loadTile(GREEN_STAR, r.getDrawable(R.drawable.greenstar));
-    	
+
     }
-    
 
     private void initNewGame() {
         mSnakeTrail.clear();
@@ -155,7 +161,6 @@
         // For now we're just going to load up a short default eastbound snake
         // that's just turned north
 
-        
         mSnakeTrail.add(new Coordinate(7, 7));
         mSnakeTrail.add(new Coordinate(6, 7));
         mSnakeTrail.add(new Coordinate(5, 7));
@@ -172,30 +177,29 @@
         mScore = 0;
     }
 
-
     /**
-     * Given a ArrayList of coordinates, we need to flatten them into an array of
-     * ints before we can stuff them into a map for flattening and storage.
+     * Given a ArrayList of coordinates, we need to flatten them into an array of ints before we can
+     * stuff them into a map for flattening and storage.
      * 
      * @param cvec : a ArrayList of Coordinate objects
-     * @return : a simple array containing the x/y values of the coordinates
-     * as [x1,y1,x2,y2,x3,y3...]
+     * @return : a simple array containing the x/y values of the coordinates as
+     *         [x1,y1,x2,y2,x3,y3...]
      */
     private int[] coordArrayListToArray(ArrayList<Coordinate> cvec) {
-        int count = cvec.size();
-        int[] rawArray = new int[count * 2];
-        for (int index = 0; index < count; index++) {
-            Coordinate c = cvec.get(index);
-            rawArray[2 * index] = c.x;
-            rawArray[2 * index + 1] = c.y;
+        int[] rawArray = new int[cvec.size() * 2];
+
+        int i = 0;
+        for (Coordinate c : cvec) {
+            rawArray[i++] = c.x;
+            rawArray[i++] = c.y;
         }
+
         return rawArray;
     }
 
     /**
-     * Save game state so that the user does not lose anything
-     * if the game process is killed while we are in the 
-     * background.
+     * Save game state so that the user does not lose anything if the game process is killed while
+     * we are in the background.
      * 
      * @return a Bundle with this view's state
      */
@@ -213,8 +217,8 @@
     }
 
     /**
-     * Given a flattened array of ordinate pairs, we reconstitute them into a
-     * ArrayList of Coordinate objects
+     * Given a flattened array of ordinate pairs, we reconstitute them into a ArrayList of
+     * Coordinate objects
      * 
      * @param rawArray : [x1,y1,x2,y2,...]
      * @return a ArrayList of Coordinates
@@ -246,83 +250,79 @@
         mSnakeTrail = coordArrayToArrayList(icicle.getIntArray("mSnakeTrail"));
     }
 
-    /*
-     * handles key events in the game. Update the direction our snake is traveling
-     * based on the DPAD. Ignore events that would cause the snake to immediately
-     * turn back on itself.
-     * 
-     * (non-Javadoc)
-     * 
-     * @see android.view.View#onKeyDown(int, android.os.KeyEvent)
+    /**
+     * Handles snake movement triggers from Snake Activity and moves the snake accordingly. Ignore
+     * events that would cause the snake to immediately turn back on itself.
+     *
+     * @param direction The desired direction of movement
      */
-    @Override
-    public boolean onKeyDown(int keyCode, KeyEvent msg) {
+    public void moveSnake(int direction) {
 
-        if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
+        if (direction == Snake.MOVE_UP) {
             if (mMode == READY | mMode == LOSE) {
                 /*
                  * At the beginning of the game, or the end of a previous one,
-                 * we should start a new game.
+                 * we should start a new game if UP key is clicked.
                  */
                 initNewGame();
                 setMode(RUNNING);
                 update();
-                return (true);
+                return;
             }
 
             if (mMode == PAUSE) {
                 /*
-                 * If the game is merely paused, we should just continue where
-                 * we left off.
+                 * If the game is merely paused, we should just continue where we left off.
                  */
                 setMode(RUNNING);
                 update();
-                return (true);
+                return;
             }
 
             if (mDirection != SOUTH) {
                 mNextDirection = NORTH;
             }
-            return (true);
+            return;
         }
 
-        if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
+        if (direction == Snake.MOVE_DOWN) {
             if (mDirection != NORTH) {
                 mNextDirection = SOUTH;
             }
-            return (true);
+            return;
         }
 
-        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
+        if (direction == Snake.MOVE_LEFT) {
             if (mDirection != EAST) {
                 mNextDirection = WEST;
             }
-            return (true);
+            return;
         }
 
-        if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
+        if (direction == Snake.MOVE_RIGHT) {
             if (mDirection != WEST) {
                 mNextDirection = EAST;
             }
-            return (true);
+            return;
         }
 
-        return super.onKeyDown(keyCode, msg);
     }
 
     /**
-     * Sets the TextView that will be used to give information (such as "Game
-     * Over" to the user.
+     * Sets the Dependent views that will be used to give information (such as "Game Over" to the
+     * user and also to handle touch events for making movements
      * 
      * @param newView
      */
-    public void setTextView(TextView newView) {
-        mStatusText = newView;
+    public void setDependentViews(TextView msgView, View arrowView, View backgroundView) {
+        mStatusText = msgView;
+        mArrowsView = arrowView;
+        mBackgroundView = backgroundView;
     }
 
     /**
-     * Updates the current mode of the application (RUNNING or PAUSED or the like)
-     * as well as sets the visibility of textview for notification
+     * Updates the current mode of the application (RUNNING or PAUSED or the like) as well as sets
+     * the visibility of textview for notification
      * 
      * @param newMode
      */
@@ -330,23 +330,33 @@
         int oldMode = mMode;
         mMode = newMode;
 
-        if (newMode == RUNNING & oldMode != RUNNING) {
+        if (newMode == RUNNING && oldMode != RUNNING) {
+            // hide the game instructions
             mStatusText.setVisibility(View.INVISIBLE);
             update();
+            // make the background and arrows visible as soon the snake starts moving
+            mArrowsView.setVisibility(View.VISIBLE);
+            mBackgroundView.setVisibility(View.VISIBLE);
             return;
         }
 
         Resources res = getContext().getResources();
         CharSequence str = "";
         if (newMode == PAUSE) {
+            mArrowsView.setVisibility(View.GONE);
+            mBackgroundView.setVisibility(View.GONE);
             str = res.getText(R.string.mode_pause);
         }
         if (newMode == READY) {
+            mArrowsView.setVisibility(View.GONE);
+            mBackgroundView.setVisibility(View.GONE);
+
             str = res.getText(R.string.mode_ready);
         }
         if (newMode == LOSE) {
-            str = res.getString(R.string.mode_lose_prefix) + mScore
-                  + res.getString(R.string.mode_lose_suffix);
+            mArrowsView.setVisibility(View.GONE);
+            mBackgroundView.setVisibility(View.GONE);
+            str = res.getString(R.string.mode_lose, mScore);
         }
 
         mStatusText.setText(str);
@@ -354,11 +364,16 @@
     }
 
     /**
-     * Selects a random location within the garden that is not currently covered
-     * by the snake. Currently _could_ go into an infinite loop if the snake
-     * currently fills the garden, but we'll leave discovery of this prize to a
-     * truly excellent snake-player.
-     * 
+     * @return the Game state as Running, Ready, Paused, Lose
+     */
+    public int getGameState() {
+        return mMode;
+    }
+
+    /**
+     * Selects a random location within the garden that is not currently covered by the snake.
+     * Currently _could_ go into an infinite loop if the snake currently fills the garden, but we'll
+     * leave discovery of this prize to a truly excellent snake-player.
      */
     private void addRandomApple() {
         Coordinate newCoord = null;
@@ -388,10 +403,9 @@
         mAppleList.add(newCoord);
     }
 
-
     /**
-     * Handles the basic update loop, checking to see if we are in the running
-     * state, determining if a move should be made, updating the snake's location.
+     * Handles the basic update loop, checking to see if we are in the running state, determining if
+     * a move should be made, updating the snake's location.
      */
     public void update() {
         if (mMode == RUNNING) {
@@ -411,7 +425,6 @@
 
     /**
      * Draws some walls.
-     * 
      */
     private void updateWalls() {
         for (int x = 0; x < mXTileCount; x++) {
@@ -426,7 +439,6 @@
 
     /**
      * Draws some apples.
-     * 
      */
     private void updateApples() {
         for (Coordinate c : mAppleList) {
@@ -435,38 +447,36 @@
     }
 
     /**
-     * Figure out which way the snake is going, see if he's run into anything (the
-     * walls, himself, or an apple). If he's not going to die, we then add to the
-     * front and subtract from the rear in order to simulate motion. If we want to
-     * grow him, we don't subtract from the rear.
-     * 
+     * Figure out which way the snake is going, see if he's run into anything (the walls, himself,
+     * or an apple). If he's not going to die, we then add to the front and subtract from the rear
+     * in order to simulate motion. If we want to grow him, we don't subtract from the rear.
      */
     private void updateSnake() {
         boolean growSnake = false;
 
-        // grab the snake by the head
+        // Grab the snake by the head
         Coordinate head = mSnakeTrail.get(0);
         Coordinate newHead = new Coordinate(1, 1);
 
         mDirection = mNextDirection;
 
         switch (mDirection) {
-        case EAST: {
-            newHead = new Coordinate(head.x + 1, head.y);
-            break;
-        }
-        case WEST: {
-            newHead = new Coordinate(head.x - 1, head.y);
-            break;
-        }
-        case NORTH: {
-            newHead = new Coordinate(head.x, head.y - 1);
-            break;
-        }
-        case SOUTH: {
-            newHead = new Coordinate(head.x, head.y + 1);
-            break;
-        }
+            case EAST: {
+                newHead = new Coordinate(head.x + 1, head.y);
+                break;
+            }
+            case WEST: {
+                newHead = new Coordinate(head.x - 1, head.y);
+                break;
+            }
+            case NORTH: {
+                newHead = new Coordinate(head.x, head.y - 1);
+                break;
+            }
+            case SOUTH: {
+                newHead = new Coordinate(head.x, head.y + 1);
+                break;
+            }
         }
 
         // Collision detection
@@ -495,7 +505,7 @@
             if (c.equals(newHead)) {
                 mAppleList.remove(c);
                 addRandomApple();
-                
+
                 mScore++;
                 mMoveDelay *= 0.9;
 
@@ -523,10 +533,8 @@
     }
 
     /**
-     * Simple class containing two integer values and a comparison function.
-     * There's probably something I should use instead, but this was quick and
-     * easy to build.
-     * 
+     * Simple class containing two integer values and a comparison function. There's probably
+     * something I should use instead, but this was quick and easy to build.
      */
     private class Coordinate {
         public int x;
@@ -549,5 +557,5 @@
             return "Coordinate: [" + x + "," + y + "]";
         }
     }
-    
+
 }
diff --git a/samples/Snake/src/com/example/android/snake/TileView.java b/samples/Snake/src/com/example/android/snake/TileView.java
old mode 100644
new mode 100755
index a912c53..a25e922
--- a/samples/Snake/src/com/example/android/snake/TileView.java
+++ b/samples/Snake/src/com/example/android/snake/TileView.java
@@ -25,18 +25,16 @@
 import android.util.AttributeSet;
 import android.view.View;
 
-
 /**
- * TileView: a View-variant designed for handling arrays of "icons" or other
- * drawables.
+ * TileView: a View-variant designed for handling arrays of "icons" or other drawables.
  * 
  */
 public class TileView extends View {
 
     /**
-     * Parameters controlling the size of the tiles and their range within view.
-     * Width/Height are in pixels, and Drawables will be scaled to fit to these
-     * dimensions. X/Y Tile Counts are the number of tiles that will be drawn.
+     * Parameters controlling the size of the tiles and their range within view. Width/Height are in
+     * pixels, and Drawables will be scaled to fit to these dimensions. X/Y Tile Counts are the
+     * number of tiles that will be drawn.
      */
 
     protected static int mTileSize;
@@ -47,81 +45,37 @@
     private static int mXOffset;
     private static int mYOffset;
 
-
-    /**
-     * A hash that maps integer handles specified by the subclasser to the
-     * drawable that will be used for that reference
-     */
-    private Bitmap[] mTileArray; 
-
-    /**
-     * A two-dimensional array of integers in which the number represents the
-     * index of the tile that should be drawn at that locations
-     */
-    private int[][] mTileGrid;
-
     private final Paint mPaint = new Paint();
 
-    public TileView(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
+    /**
+     * A hash that maps integer handles specified by the subclasser to the drawable that will be
+     * used for that reference
+     */
+    private Bitmap[] mTileArray;
 
-        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TileView);
-
-        mTileSize = a.getInt(R.styleable.TileView_tileSize, 12);
-        
-        a.recycle();
-    }
+    /**
+     * A two-dimensional array of integers in which the number represents the index of the tile that
+     * should be drawn at that locations
+     */
+    private int[][] mTileGrid;
 
     public TileView(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TileView);
+        mTileSize = a.getDimensionPixelSize(R.styleable.TileView_tileSize, 12);
 
-        mTileSize = a.getInt(R.styleable.TileView_tileSize, 12);
-        
         a.recycle();
     }
 
-    
-    
-    /**
-     * Rests the internal array of Bitmaps used for drawing tiles, and
-     * sets the maximum index of tiles to be inserted
-     * 
-     * @param tilecount
-     */
-    
-    public void resetTiles(int tilecount) {
-    	mTileArray = new Bitmap[tilecount];
-    }
+    public TileView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
 
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TileView);
+        mTileSize = a.getDimensionPixelSize(R.styleable.TileView_tileSize, 12);
 
-    @Override
-    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
-        mXTileCount = (int) Math.floor(w / mTileSize);
-        mYTileCount = (int) Math.floor(h / mTileSize);
+        a.recycle();
 
-        mXOffset = ((w - (mTileSize * mXTileCount)) / 2);
-        mYOffset = ((h - (mTileSize * mYTileCount)) / 2);
-
-        mTileGrid = new int[mXTileCount][mYTileCount];
-        clearTiles();
-    }
-
-    /**
-     * Function to set the specified Drawable as the tile for a particular
-     * integer key.
-     * 
-     * @param key
-     * @param tile
-     */
-    public void loadTile(int key, Drawable tile) {
-        Bitmap bitmap = Bitmap.createBitmap(mTileSize, mTileSize, Bitmap.Config.ARGB_8888);
-        Canvas canvas = new Canvas(bitmap);
-        tile.setBounds(0, 0, mTileSize, mTileSize);
-        tile.draw(canvas);
-        
-        mTileArray[key] = bitmap;
     }
 
     /**
@@ -137,9 +91,48 @@
     }
 
     /**
-     * Used to indicate that a particular tile (set with loadTile and referenced
-     * by an integer) should be drawn at the given x/y coordinates during the
-     * next invalidate/draw cycle.
+     * Function to set the specified Drawable as the tile for a particular integer key.
+     *
+     * @param key
+     * @param tile
+     */
+    public void loadTile(int key, Drawable tile) {
+        Bitmap bitmap = Bitmap.createBitmap(mTileSize, mTileSize, Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(bitmap);
+        tile.setBounds(0, 0, mTileSize, mTileSize);
+        tile.draw(canvas);
+
+        mTileArray[key] = bitmap;
+    }
+
+    @Override
+    public void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+        for (int x = 0; x < mXTileCount; x += 1) {
+            for (int y = 0; y < mYTileCount; y += 1) {
+                if (mTileGrid[x][y] > 0) {
+                    canvas.drawBitmap(mTileArray[mTileGrid[x][y]], mXOffset + x * mTileSize,
+                            mYOffset + y * mTileSize, mPaint);
+                }
+            }
+        }
+
+    }
+
+    /**
+     * Rests the internal array of Bitmaps used for drawing tiles, and sets the maximum index of
+     * tiles to be inserted
+     *
+     * @param tilecount
+     */
+
+    public void resetTiles(int tilecount) {
+        mTileArray = new Bitmap[tilecount];
+    }
+
+    /**
+     * Used to indicate that a particular tile (set with loadTile and referenced by an integer)
+     * should be drawn at the given x/y coordinates during the next invalidate/draw cycle.
      * 
      * @param tileindex
      * @param x
@@ -149,21 +142,16 @@
         mTileGrid[x][y] = tileindex;
     }
 
-
     @Override
-    public void onDraw(Canvas canvas) {
-        super.onDraw(canvas);
-        for (int x = 0; x < mXTileCount; x += 1) {
-            for (int y = 0; y < mYTileCount; y += 1) {
-                if (mTileGrid[x][y] > 0) {
-                    canvas.drawBitmap(mTileArray[mTileGrid[x][y]], 
-                    		mXOffset + x * mTileSize,
-                    		mYOffset + y * mTileSize,
-                    		mPaint);
-                }
-            }
-        }
+    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+        mXTileCount = (int) Math.floor(w / mTileSize);
+        mYTileCount = (int) Math.floor(h / mTileSize);
 
+        mXOffset = ((w - (mTileSize * mXTileCount)) / 2);
+        mYOffset = ((h - (mTileSize * mYTileCount)) / 2);
+
+        mTileGrid = new int[mXTileCount][mYTileCount];
+        clearTiles();
     }
 
 }
diff --git a/sdk/images_mips_source.prop_template b/sdk/images_mips_source.prop_template
new file mode 100644
index 0000000..30bfda1
--- /dev/null
+++ b/sdk/images_mips_source.prop_template
@@ -0,0 +1,6 @@
+Pkg.Desc=Android SDK Platform ${PLATFORM_VERSION}
+Pkg.UserSrc=false
+Pkg.Revision=1
+AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
+AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
+SystemImage.Abi=mips
diff --git a/sdk/usbdriver_source.properties b/sdk/usbdriver_source.properties
index 73ddf74..bff71f9 100755
--- a/sdk/usbdriver_source.properties
+++ b/sdk/usbdriver_source.properties
@@ -1,4 +1,4 @@
-Pkg.Revision=6

+Pkg.Revision=7

 Archive.Os=WINDOWS

 Archive.Arch=ANY

 Extra.Path=usb_driver

diff --git a/testrunner/test_defs.xml b/testrunner/test_defs.xml
index ada90d2..801e35d 100644
--- a/testrunner/test_defs.xml
+++ b/testrunner/test_defs.xml
@@ -68,7 +68,7 @@
     continuous="true" />
 
 <test name="frameworks-telephony"
-    build_path="frameworks/base/telephony/tests/telephonytests"
+    build_path="frameworks/opt/telephony/tests/telephonytests"
     package="com.android.frameworks.telephonytests"
     coverage_target="framework"
     continuous="true" />
@@ -94,7 +94,6 @@
 <test name="keystore-unit"
     build_path="frameworks/base/keystore/tests"
     package="android.security.tests"
-    runner=".KeyStoreTestRunner"
     coverage_target="framework"
     continuous="true" />
 
diff --git a/tools/emulator/opengl/Android.mk b/tools/emulator/opengl/Android.mk
new file mode 100644
index 0000000..3a23395
--- /dev/null
+++ b/tools/emulator/opengl/Android.mk
@@ -0,0 +1,66 @@
+# This is the top-level build file for the Android HW OpenGL ES emulation
+# in Android.
+#
+# You must define BUILD_EMULATOR_OPENGL to 'true' in your environment to
+# build the following files.
+#
+# Also define BUILD_EMULATOR_OPENGL_DRIVER to 'true' to build the gralloc
+# stuff as well.
+#
+ifeq (true,$(BUILD_EMULATOR_OPENGL))
+
+# Top-level for all modules
+EMUGL_PATH := $(call my-dir)
+
+# Directory containing common headers used by several modules
+# This is always set to a module's LOCAL_C_INCLUDES
+# See the definition of emugl-begin-module in common.mk
+#
+EMUGL_COMMON_INCLUDES := $(EMUGL_PATH)/host/include/libOpenglRender
+
+# common cflags used by several modules
+# This is always set to a module's LOCAL_CFLAGS
+# See the definition of emugl-begin-module in common.mk
+#
+EMUGL_COMMON_CFLAGS := -DWITH_GLES2
+
+# Uncomment the following line if you want to enable debug traces
+# in the GLES emulation libraries.
+# EMUGL_COMMON_CFLAGS += -DEMUGL_DEBUG=1
+
+# Include common definitions used by all the modules included later
+# in this build file. This contains the definition of all useful
+# emugl-xxxx functions.
+#
+include $(EMUGL_PATH)/common.mk
+
+# IMPORTANT: ORDER IS CRUCIAL HERE
+#
+# For the import/export feature to work properly, you must include
+# modules below in correct order. That is, if module B depends on
+# module A, then it must be included after module A below.
+#
+# This ensures that anything exported by module A will be correctly
+# be imported by module B when it is declared.
+#
+# Note that the build system will complain if you try to import a
+# module that hasn't been declared yet anyway.
+#
+
+include $(EMUGL_PATH)/shared/OpenglOsUtils/Android.mk
+include $(EMUGL_PATH)/shared/OpenglCodecCommon/Android.mk
+
+# System static libraries
+include $(EMUGL_PATH)/system/GLESv1_enc/Android.mk
+include $(EMUGL_PATH)/system/GLESv2_enc/Android.mk
+include $(EMUGL_PATH)/system/renderControl_enc/Android.mk
+include $(EMUGL_PATH)/system/OpenglSystemCommon/Android.mk
+
+# System shared libraries
+include $(EMUGL_PATH)/system/GLESv1/Android.mk
+include $(EMUGL_PATH)/system/GLESv2/Android.mk
+
+include $(EMUGL_PATH)/system/gralloc/Android.mk
+include $(EMUGL_PATH)/system/egl/Android.mk
+
+endif # BUILD_EMULATOR_OPENGL == true
diff --git a/tools/emulator/opengl/README b/tools/emulator/opengl/README
new file mode 100644
index 0000000..91050ed
--- /dev/null
+++ b/tools/emulator/opengl/README
@@ -0,0 +1,3 @@
+This directory contains Android-side modules related to hardware OpenGL ES
+emulation. The host-side modules and documentation are in
+$ANDROID_BUILD_TOP/sdk/emulator/opengl.
diff --git a/tools/emulator/opengl/common.mk b/tools/emulator/opengl/common.mk
new file mode 100644
index 0000000..8f31e17
--- /dev/null
+++ b/tools/emulator/opengl/common.mk
@@ -0,0 +1,242 @@
+# This top-level build file is included by all modules that implement
+# the hardware OpenGL ES emulation for Android.
+#
+# We use it to ensure that all sub-Makefiles are included in the right
+# order for various variable definitions and usage to happen in the correct
+# order.
+#
+
+# The following macros are used to start a new GLES emulation module.
+#
+# This will define LOCAL_MODULE as $1, plus a few other variables
+# needed by the build system (e.g. LOCAL_MODULE_TAGS, LOCAL_MODULE_CLASS...)
+#
+# NOTE: You still need to define LOCAL_PATH before this
+#
+# Usage example:
+#
+#   $(call emugl-begin-static-library,<name>)
+#       LOCAL_SRC_FILES := ....
+#       LOCAL_C_INCLUDES += ....
+#   $(call emugl-end-module)
+#
+emugl-begin-static-library = $(call emugl-begin-module,$1,STATIC_LIBRARY)
+emugl-begin-shared-library = $(call emugl-begin-module,$1,SHARED_LIBRARY)
+
+# Internal list of all declared modules (used for sanity checking)
+_emugl_modules :=
+_emugl_HOST_modules :=
+
+# do not use directly, see functions above instead
+emugl-begin-module = \
+    $(eval include $(CLEAR_VARS)) \
+    $(eval LOCAL_MODULE := $1) \
+    $(eval LOCAL_MODULE_TAGS := debug) \
+    $(eval LOCAL_MODULE_CLASS := $(patsubst HOST_%,%,$(patsubst %EXECUTABLE,%EXECUTABLES,$(patsubst %LIBRARY,%LIBRARIES,$2)))) \
+    $(eval LOCAL_IS_HOST_MODULE := $(if $3,true,))\
+    $(eval LOCAL_C_INCLUDES := $(EMUGL_COMMON_INCLUDES)) \
+    $(eval LOCAL_CFLAGS := $(EMUGL_COMMON_CFLAGS)) \
+    $(eval LOCAL_PRELINK_MODULE := false)\
+    $(eval _EMUGL_INCLUDE_TYPE := $(BUILD_$2)) \
+    $(call _emugl-init-module,$1,$2,$3)
+
+# Used to end a module definition, see function definitions above
+emugl-end-module = \
+    $(eval include $(_EMUGL_INCLUDE_TYPE))\
+    $(eval _EMUGL_INCLUDE_TYPE :=) \
+    $(eval _emugl_$(_emugl_HOST)modules += $(_emugl_MODULE))\
+    $(if $(EMUGL_DEBUG),$(call emugl-dump-module))
+
+# Managing module exports and imports.
+#
+# A module can 'import' another module, by calling emugl-import. This will
+# make the current LOCAL_MODULE inherit various definitions exported from
+# the imported module.
+#
+# Module exports are defined by calling emugl-export. Here is an example:
+#
+#      $(call emugl-begin-static-library,foo)
+#      LOCAL_SRC_FILES := foo.c
+#      $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+#      $(call emugl-export,SHARED_LIBRARIES,libcutils)
+#      $(call emugl-end-module)
+#
+#      $(call emugl-begin-shared-library,bar)
+#      LOCAL_SRC_FILES := bar.cpp
+#      $(call emugl-import,foo)
+#      $(call emugl-end-module)
+#
+# Here, we define a static library named 'foo' which exports an include
+# path and a shared library requirement, and a shared library 'bar' which
+# imports it.
+#
+# What this means is that:
+#
+#    - 'bar' will automatically inherit foo's LOCAL_PATH in its LOCAL_C_INCLUDES
+#    - 'bar' will automatically inherit libcutils in its own LOCAL_SHARED_LIBRARIES
+#
+# Note that order of declaration matters. If 'foo' is defined after 'bar' in
+# the example above, nothing will work correctly because dependencies are
+# computed at import time.
+#
+#
+# IMPORTANT: Imports are transitive, i.e. when module A imports B,
+#            it automatically imports anything imported by B too.
+
+# This is the list of recognized export types we support for now.
+EMUGL_EXPORT_TYPES := \
+    CFLAGS \
+    LDLIBS \
+    LDFLAGS \
+    C_INCLUDES \
+    SHARED_LIBRARIES \
+    STATIC_LIBRARIES \
+    ADDITIONAL_DEPENDENCIES
+
+# Initialize a module in our database
+# $1: Module name
+# $2: Module type
+# $3: "HOST" for a host module, empty for a target one.
+_emugl-init-module = \
+    $(eval _emugl_HOST := $(if $3,HOST_,))\
+    $(eval _emugl_MODULE := $(_emugl_HOST)$1)\
+    $(if $(filter $(_emugl_$(_emugl_HOST)modules),$(_emugl_MODULE)),\
+        $(error There is already a $(if $3,host,) module named $1!)\
+    )\
+    $(eval _mod = $(_emugl_MODULE)) \
+    $(eval _emugl.$(_mod).type := $(patsubst HOST_%,%,$2))\
+    $(eval _emugl.$(_mod).imports :=) \
+    $(eval _emugl,$(_mod).moved :=) \
+    $(foreach _type,$(EMUGL_EXPORT_TYPES),\
+        $(eval _emugl.$(_mod).export.$(_type) :=)\
+    )
+
+# Called to indicate that a module exports a given local variable for its
+# users. This also adds this to LOCAL_$1
+# $1: Local variable type (e.g. CFLAGS, LDLIBS, etc...)
+# $2: Value(s) to append to the export
+emugl-export = \
+    $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)\
+    $(eval LOCAL_$1 := $2 $(LOCAL_$1))
+
+emugl-export-outer = \
+    $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)
+
+# Called to indicate that a module imports the exports of another module
+# $1: list of modules to import
+#
+emugl-import = \
+    $(foreach _imod,$1,\
+        $(call _emugl-module-import,$(_emugl_HOST)$(_imod))\
+    )
+
+_emugl-module-import = \
+    $(eval _mod := $(_emugl_MODULE))\
+    $(if $(filter-out $(_emugl_$(_emugl_HOST)modules),$1),\
+        $(info Unknown imported emugles module: $1)\
+        $(if $(_emugl_HOST),\
+            $(eval _names := $(patsubst HOST_%,%,$(_emugl_HOST_modules))),\
+            $(eval _names := $(_emugl_modules))\
+        )\
+        $(info Please one of the following names: $(_names))\
+        $(error Aborting)\
+    )\
+    $(if $(filter-out $(_emugl.$(_mod).imports),$1),\
+        $(eval _emugl.$(_mod).imports += $1)\
+        $(foreach _sub,$(_emugl.$1.imports),\
+            $(call _emugl-module-import,$(_sub))\
+        )\
+        $(foreach _type,$(EMUGL_EXPORT_TYPES),\
+            $(eval LOCAL_$(_type) := $(_emugl.$1.export.$(_type)) $(LOCAL_$(_type)))\
+        )\
+        $(if $(filter EXECUTABLE SHARED_LIBRARY,$(_emugl.$(_emugl_MODULE).type)),\
+            $(if $(filter STATIC_LIBRARY,$(_emugl.$1.type)),\
+                $(eval LOCAL_STATIC_LIBRARIES := $(1:HOST_%=%) $(LOCAL_STATIC_LIBRARIES))\
+            )\
+            $(if $(filter SHARED_LIBRARY,$(_emugl.$1.type)),\
+                $(if $(_emugl.$1.moved),,\
+                  $(eval LOCAL_SHARED_LIBRARIES := $(1:HOST_%=%) $(LOCAL_SHARED_LIBRARIES))\
+                )\
+            )\
+        )\
+    )
+
+_emugl-dump-list = \
+    $(foreach _list_item,$(strip $1),$(info .    $(_list_item)))
+
+emugl-dump-module = \
+    $(info MODULE=$(_emugl_MODULE))\
+    $(info .  HOST=$(_emugl_HOST))\
+    $(info .  TYPE=$(_emugl.$(_emugl_MODULE).type))\
+    $(info .  IMPORTS=$(_emugl.$(_emugl_MODULE).imports))\
+    $(foreach _type,$(EMUGL_EXPORT_TYPES),\
+        $(if $(filter C_INCLUDES ADDITIONAL_DEPENDENCIES,$(_type)),\
+            $(info .  EXPORT.$(_type) :=)\
+            $(call _emugl-dump-list,$(_emugl.$(_emugl_MODULE).export.$(_type)))\
+            $(info .  LOCAL_$(_type)  :=)\
+            $(call _emugl-dump-list,$(LOCAL_$(_type)))\
+        ,\
+            $(info .  EXPORT.$(_type) := $(strip $(_emugl.$(_emugl_MODULE).export.$(_type))))\
+            $(info .  LOCAL_$(_type)  := $(strip $(LOCAL_$(_type))))\
+        )\
+    )\
+    $(info .  LOCAL_SRC_FILES := $(LOCAL_SRC_FILES))\
+
+# This function can be called to generate the wrapper source files.
+# LOCAL_MODULE and LOCAL_MODULE_CLASS must be defined or the build will abort.
+# Source files will be stored in the local intermediates directory that will
+# be automatically added to your LOCAL_C_INCLUDES.
+# Usage:
+#    $(call emugl-gen-wrapper,<input-dir>,<basename>)
+#
+emugl-gen-wrapper = \
+    $(eval _emugl_out := $(call local-intermediates-dir)) \
+    $(call emugl-gen-wrapper-generic,$(_emugl_out),$1,$2) \
+    $(call emugl-export,C_INCLUDES,$(_emugl_out))
+
+# DO NOT CALL DIRECTLY, USE emugl-gen-wrapper instead.
+#
+# The following function can be called to generate GL library wrapper
+# Usage is:
+#
+#  $(call emugl-gen-wrapper-generic,<dst-dir>,<src-dir>,<basename>)
+#
+#  <dst-dir> is the destination directory where the generated sources are stored
+#  <src-dir> is the source directory where to find <basename>.attrib, etc..
+#  <basename> is the emugen basename (see host/tools/emugen/README)
+#
+emugl-gen-wrapper-generic = $(eval $(emugl-gen-wrapper-generic-ev))
+
+define emugl-gen-wrapper-generic-ev
+_emugl_wrap := $$1/$$3
+_emugl_src  := $$2/$$3
+GEN := $$(_emugl_wrap)_wrapper_entry.cpp \
+       $$(_emugl_wrap)_wrapper_context.cpp \
+       $$(_emugl_wrap)_wrapper_context.h \
+       $$(_emugl_wrap)_wrapper_proc.h
+
+$$(GEN): PRIVATE_PATH := $$(LOCAL_PATH)
+$$(GEN): PRIVATE_CUSTOM_TOOL := $$(EMUGL_EMUGEN) -W $$1 -i $$2 $$3
+$$(GEN): $$(EMUGL_EMUGEN) $$(_emugl_src).attrib $$(_emugl_src).in $$(_emugl_src).types
+	$$(transform-generated-source)
+
+$$(call emugl-export,ADDITIONAL_DEPENDENCIES,$$(GEN))
+LOCAL_GENERATED_SOURCES += $$(GEN)
+LOCAL_C_INCLUDES += $$1
+
+#ifneq ($$(HOST_OS),windows)
+$$(call emugl-export,LDFLAGS,-ldl)
+#endif
+
+endef
+
+# Call this function when your shared library must be placed in a non-standard
+# library path (i.e. not under /system/lib
+# $1: library sub-path,relative to /system/lib
+# For example: $(call emugl-set-shared-library-subpath,egl)
+emugl-set-shared-library-subpath = \
+    $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$1)\
+    $(eval LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$1)\
+    $(eval _emugl.$(LOCAL_MODULE).moved := true)\
+    $(call emugl-export-outer,ADDITIONAL_DEPENDENCIES,$(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)$(TARGET_SHLIB_SUFFIX))
+
diff --git a/tools/emulator/opengl/host/include/libOpenglRender/IOStream.h b/tools/emulator/opengl/host/include/libOpenglRender/IOStream.h
new file mode 100644
index 0000000..445ec17
--- /dev/null
+++ b/tools/emulator/opengl/host/include/libOpenglRender/IOStream.h
@@ -0,0 +1,102 @@
+/*
+* 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 const unsigned char *read( void *buf, size_t *inout_len) = 0;
+    virtual int writeFully(const 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;
+};
+
+//
+// When a client opens a connection to the renderer, it should
+// send unsigned int value indicating the "clientFlags".
+// The following are the bitmask of the clientFlags.
+// currently only one bit is used which flags the server
+// it should exit.
+//
+#define IOSTREAM_CLIENT_EXIT_SERVER      1
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/Android.mk b/tools/emulator/opengl/shared/OpenglCodecCommon/Android.mk
new file mode 100644
index 0000000..df9b39a
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/Android.mk
@@ -0,0 +1,23 @@
+# This build script corresponds to a library containing many definitions
+# common to both the guest and the host. They relate to
+#
+LOCAL_PATH := $(call my-dir)
+
+commonSources := \
+        GLClientState.cpp \
+        GLSharedGroup.cpp \
+        glUtils.cpp \
+        SocketStream.cpp \
+        TcpStream.cpp \
+        TimeUtils.cpp
+
+### CodecCommon  guest ##############################################
+$(call emugl-begin-static-library,libOpenglCodecCommon)
+
+LOCAL_SRC_FILES := $(commonSources)
+
+LOCAL_CFLAGS += -DLOG_TAG=\"eglCodecCommon\"
+
+$(call emugl-export,SHARED_LIBRARIES,libcutils libutils)
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+$(call emugl-end-module)
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h b/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
new file mode 100644
index 0000000..6f41fd7
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.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 _ERROR_LOG_H_
+#define _ERROR_LOG_H_
+
+#if (HAVE_ANDROID_OS == 1)
+#    include <cutils/log.h>
+#    define ERR(...)    ALOGE(__VA_ARGS__)
+#    ifdef EMUGL_DEBUG
+#        define DBG(...)    ALOGD(__VA_ARGS__)
+#    else
+#        define DBG(...)    ((void)0)
+#    endif
+#else
+#     include <stdio.h>
+#    define ERR(...)    fprintf(stderr, __VA_ARGS__)
+#    ifdef EMUGL_DEBUG
+#        define DBG(...)    fprintf(stderr, __VA_ARGS__)
+#    else
+#        define DBG(...)    ((void)0)
+#    endif
+#endif
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h b/tools/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h
new file mode 100644
index 0000000..30b9a80
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h
@@ -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.
+*/
+#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() {
+        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/shared/OpenglCodecCommon/GLClientState.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp
new file mode 100644
index 0000000..9795490
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp
@@ -0,0 +1,417 @@
+/*
+* 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 <string.h>
+#include "glUtils.h"
+#include <cutils/log.h>
+
+#ifndef MAX
+#define MAX(a, b) ((a) < (b) ? (b) : (a))
+#endif
+
+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_states[MATRIXINDEX_LOCATION].glConst = GL_MATRIX_INDEX_ARRAY_OES;
+    m_states[WEIGHT_LOCATION].glConst = GL_WEIGHT_ARRAY_OES;
+    m_activeTexture = 0;
+    m_currentProgram = 0;
+
+    m_pixelStore.unpack_alignment = 4;
+    m_pixelStore.pack_alignment = 4;
+
+    memset(m_tex.unit, 0, sizeof(m_tex.unit));
+    m_tex.activeUnit = &m_tex.unit[0];
+    m_tex.textures = NULL;
+    m_tex.numTextures = 0;
+    m_tex.allocTextures = 0;
+}
+
+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, GLboolean normalized, GLsizei stride, const 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 = (void*)data;
+    m_states[location].bufferObject = m_currentArrayVbo;
+    m_states[location].elementSize = glSizeof(type) * size;
+    m_states[location].normalized = normalized;
+}
+
+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;
+    case GL_MATRIX_INDEX_ARRAY_OES:
+        retval = int (MATRIXINDEX_LOCATION);
+        break;
+    case GL_WEIGHT_ARRAY_OES:
+        retval = int (WEIGHT_LOCATION);
+        break;
+    default:
+        retval = loc;
+    }
+    return retval;
+}
+
+void GLClientState::getClientStatePointer(GLenum pname, GLvoid** params)
+{
+    const GLClientState::VertexAttribState *state = NULL;
+    switch (pname) {
+    case GL_VERTEX_ARRAY_POINTER: {
+        state = getState(GLClientState::VERTEX_LOCATION);
+        break;
+        }
+    case GL_NORMAL_ARRAY_POINTER: {
+        state = getState(GLClientState::NORMAL_LOCATION);
+        break;
+        }
+    case GL_COLOR_ARRAY_POINTER: {
+        state = getState(GLClientState::COLOR_LOCATION);
+        break;
+        }
+    case GL_TEXTURE_COORD_ARRAY_POINTER: {
+        state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION);
+        break;
+        }
+    case GL_POINT_SIZE_ARRAY_POINTER_OES: {
+        state = getState(GLClientState::POINTSIZE_LOCATION);
+        break;
+        }
+    case GL_MATRIX_INDEX_ARRAY_POINTER_OES: {
+        state = getState(GLClientState::MATRIXINDEX_LOCATION);
+        break;
+        }
+    case GL_WEIGHT_ARRAY_POINTER_OES: {
+        state = getState(GLClientState::WEIGHT_LOCATION);
+        break;
+        }
+    }
+    if (state && params)
+        *params = state->data;
+}
+
+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) const
+{
+    int pixelsize = glUtilsPixelBitSize(format, type) >> 3;
+
+    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;
+}
+
+GLenum GLClientState::setActiveTextureUnit(GLenum texture)
+{
+    GLuint unit = texture - GL_TEXTURE0;
+    if (unit >= MAX_TEXTURE_UNITS) {
+        return GL_INVALID_OPERATION;
+    }
+    m_tex.activeUnit = &m_tex.unit[unit];
+    return GL_NO_ERROR;
+}
+
+GLenum GLClientState::getActiveTextureUnit() const
+{
+    return GL_TEXTURE0 + (m_tex.activeUnit - &m_tex.unit[0]);
+}
+
+void GLClientState::enableTextureTarget(GLenum target)
+{
+    switch (target) {
+    case GL_TEXTURE_2D:
+        m_tex.activeUnit->enables |= (1u << TEXTURE_2D);
+        break;
+    case GL_TEXTURE_EXTERNAL_OES:
+        m_tex.activeUnit->enables |= (1u << TEXTURE_EXTERNAL);
+        break;
+    }
+}
+
+void GLClientState::disableTextureTarget(GLenum target)
+{
+    switch (target) {
+    case GL_TEXTURE_2D:
+        m_tex.activeUnit->enables &= ~(1u << TEXTURE_2D);
+        break;
+    case GL_TEXTURE_EXTERNAL_OES:
+        m_tex.activeUnit->enables &= ~(1u << TEXTURE_EXTERNAL);
+        break;
+    }
+}
+
+GLenum GLClientState::getPriorityEnabledTarget(GLenum allDisabled) const
+{
+    unsigned int enables = m_tex.activeUnit->enables;
+    if (enables & (1u << TEXTURE_EXTERNAL)) {
+        return GL_TEXTURE_EXTERNAL_OES;
+    } else if (enables & (1u << TEXTURE_2D)) {
+        return GL_TEXTURE_2D;
+    } else {
+        return allDisabled;
+    }
+}
+
+int GLClientState::compareTexId(const void* pid, const void* prec)
+{
+    const GLuint* id = (const GLuint*)pid;
+    const TextureRec* rec = (const TextureRec*)prec;
+    return (GLint)(*id) - (GLint)rec->id;
+}
+
+GLenum GLClientState::bindTexture(GLenum target, GLuint texture,
+        GLboolean* firstUse)
+{
+    GLboolean first = GL_FALSE;
+    TextureRec* texrec = NULL;
+    if (texture != 0) {
+        if (m_tex.textures) {
+            texrec = (TextureRec*)bsearch(&texture, m_tex.textures,
+                    m_tex.numTextures, sizeof(TextureRec), compareTexId);
+        }
+        if (!texrec) {
+            if (!(texrec = addTextureRec(texture, target))) {
+                return GL_OUT_OF_MEMORY;
+            }
+            first = GL_TRUE;
+        }
+        if (target != texrec->target) {
+            return GL_INVALID_OPERATION;
+        }
+    }
+
+    switch (target) {
+    case GL_TEXTURE_2D:
+        m_tex.activeUnit->texture[TEXTURE_2D] = texture;
+        break;
+    case GL_TEXTURE_EXTERNAL_OES:
+        m_tex.activeUnit->texture[TEXTURE_EXTERNAL] = texture;
+        break;
+    }
+
+    if (firstUse) {
+        *firstUse = first;
+    }
+
+    return GL_NO_ERROR;
+}
+
+GLClientState::TextureRec* GLClientState::addTextureRec(GLuint id,
+        GLenum target)
+{
+    if (m_tex.numTextures == m_tex.allocTextures) {
+        const GLuint MAX_TEXTURES = 0xFFFFFFFFu;
+
+        GLuint newAlloc;
+        if (MAX_TEXTURES - m_tex.allocTextures >= m_tex.allocTextures) {
+            newAlloc = MAX(4, 2 * m_tex.allocTextures);
+        } else {
+            if (m_tex.allocTextures == MAX_TEXTURES) {
+                return NULL;
+            }
+            newAlloc = MAX_TEXTURES;
+        }
+
+        TextureRec* newTextures = (TextureRec*)realloc(m_tex.textures,
+                newAlloc * sizeof(TextureRec));
+        if (!newTextures) {
+            return NULL;
+        }
+
+        m_tex.textures = newTextures;
+        m_tex.allocTextures = newAlloc;
+    }
+
+    TextureRec* tex = m_tex.textures + m_tex.numTextures;
+    TextureRec* prev = tex - 1;
+    while (tex != m_tex.textures && id < prev->id) {
+        *tex-- = *prev--;
+    }
+    tex->id = id;
+    tex->target = target;
+    m_tex.numTextures++;
+
+    return tex;
+}
+
+GLuint GLClientState::getBoundTexture(GLenum target) const
+{
+    switch (target) {
+    case GL_TEXTURE_2D:
+        return m_tex.activeUnit->texture[TEXTURE_2D];
+    case GL_TEXTURE_EXTERNAL_OES:
+        return m_tex.activeUnit->texture[TEXTURE_EXTERNAL];
+    default:
+        return 0;
+    }
+}
+
+void GLClientState::deleteTextures(GLsizei n, const GLuint* textures)
+{
+    // Updating the textures array could be made more efficient when deleting
+    // several textures:
+    // - compacting the array could be done in a single pass once the deleted
+    //   textures are marked, or
+    // - could swap deleted textures to the end and re-sort.
+    TextureRec* texrec;
+    for (const GLuint* texture = textures; texture != textures + n; texture++) {
+        texrec = (TextureRec*)bsearch(texture, m_tex.textures,
+                m_tex.numTextures, sizeof(TextureRec), compareTexId);
+        if (texrec) {
+            const TextureRec* end = m_tex.textures + m_tex.numTextures;
+            memmove(texrec, texrec + 1,
+                    (end - texrec - 1) * sizeof(TextureRec));
+            m_tex.numTextures--;
+
+            for (TextureUnit* unit = m_tex.unit;
+                 unit != m_tex.unit + MAX_TEXTURE_UNITS;
+                 unit++)
+            {
+                if (unit->texture[TEXTURE_2D] == *texture) {
+                    unit->texture[TEXTURE_2D] = 0;
+                } else if (unit->texture[TEXTURE_EXTERNAL] == *texture) {
+                    unit->texture[TEXTURE_EXTERNAL] = 0;
+                }
+            }
+        }
+    }
+}
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
new file mode 100644
index 0000000..c86329b
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
@@ -0,0 +1,441 @@
+/*
+* 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 <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "ErrorLog.h"
+#include "codec_defs.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,
+        MATRIXINDEX_LOCATION = 12,
+        WEIGHT_LOCATION = 13,
+        LAST_LOCATION = 14
+    } 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
+        bool normalized;
+    } VertexAttribState;
+
+    typedef struct {
+        int unpack_alignment;
+        int pack_alignment;
+    } PixelStoreState;
+
+    enum {
+        MAX_TEXTURE_UNITS = 32,
+    };
+
+public:
+    GLClientState(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES);
+    ~GLClientState();
+    int nLocations() { return m_nLocations; }
+    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, GLboolean normalized, GLsizei stride, const 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;
+    }
+
+    int getBuffer(GLenum target)
+    {
+      int ret=0;
+      switch (target) {
+      case GL_ARRAY_BUFFER:
+          ret = m_currentArrayVbo;
+          break;
+      case GL_ELEMENT_ARRAY_BUFFER:
+          ret = m_currentIndexVbo;
+          break;
+      default:
+          ret = -1;
+      }
+      return ret;
+    }
+    size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const;
+
+    void setCurrentProgram(GLint program) { m_currentProgram = program; }
+    GLint currentProgram() const { return m_currentProgram; }
+
+    /* OES_EGL_image_external
+     *
+     * These functions manipulate GL state which interacts with the
+     * OES_EGL_image_external extension, to support client-side emulation on
+     * top of host implementations that don't have it.
+     *
+     * Most of these calls should only be used with TEXTURE_2D or
+     * TEXTURE_EXTERNAL_OES texture targets; TEXTURE_CUBE_MAP or other extension
+     * targets should bypass this. An exception is bindTexture(), which should
+     * see all glBindTexture() calls for any target.
+     */
+
+    // glActiveTexture(GL_TEXTURE0 + i)
+    // Sets the active texture unit. Up to MAX_TEXTURE_UNITS are supported.
+    GLenum setActiveTextureUnit(GLenum texture);
+    GLenum getActiveTextureUnit() const;
+
+    // glEnable(GL_TEXTURE_(2D|EXTERNAL_OES))
+    void enableTextureTarget(GLenum target);
+
+    // glDisable(GL_TEXTURE_(2D|EXTERNAL_OES))
+    void disableTextureTarget(GLenum target);
+
+    // Implements the target priority logic:
+    // * Return GL_TEXTURE_EXTERNAL_OES if enabled, else
+    // * Return GL_TEXTURE_2D if enabled, else
+    // * Return the allDisabled value.
+    // For some cases passing GL_TEXTURE_2D for allDisabled makes callee code
+    // simpler; for other cases passing a recognizable enum like GL_ZERO or
+    // GL_INVALID_ENUM is appropriate.
+    GLenum getPriorityEnabledTarget(GLenum allDisabled) const;
+
+    // glBindTexture(GL_TEXTURE_*, ...)
+    // Set the target binding of the active texture unit to texture. Returns
+    // GL_NO_ERROR on success or GL_INVALID_OPERATION if the texture has
+    // previously been bound to a different target. If firstUse is not NULL,
+    // it is set to indicate whether this is the first use of the texture.
+    // For accurate error detection, bindTexture should be called for *all*
+    // targets, not just 2D and EXTERNAL_OES.
+    GLenum bindTexture(GLenum target, GLuint texture, GLboolean* firstUse);
+
+    // Return the texture currently bound to GL_TEXTURE_(2D|EXTERNAL_OES).
+    GLuint getBoundTexture(GLenum target) const;
+
+    // glDeleteTextures(...)
+    // Remove references to the to-be-deleted textures.
+    void deleteTextures(GLsizei n, const GLuint* textures);
+
+private:
+    PixelStoreState m_pixelStore;
+    VertexAttribState *m_states;
+    int m_nLocations;
+    GLuint m_currentArrayVbo;
+    GLuint m_currentIndexVbo;
+    int m_activeTexture;
+    GLint m_currentProgram;
+
+    bool validLocation(int location) { return (location >= 0 && location < m_nLocations); }
+
+    enum TextureTarget {
+        TEXTURE_2D = 0,
+        TEXTURE_EXTERNAL = 1,
+        TEXTURE_TARGET_COUNT
+    };
+    struct TextureUnit {
+        unsigned int enables;
+        GLuint texture[TEXTURE_TARGET_COUNT];
+    };
+    struct TextureRec {
+        GLuint id;
+        GLenum target;
+    };
+    struct TextureState {
+        TextureUnit unit[MAX_TEXTURE_UNITS];
+        TextureUnit* activeUnit;
+        TextureRec* textures;
+        GLuint numTextures;
+        GLuint allocTextures;
+    };
+    TextureState m_tex;
+
+    static int compareTexId(const void* pid, const void* prec);
+    TextureRec* addTextureRec(GLuint id, GLenum target);
+
+public:
+    void getClientStatePointer(GLenum pname, GLvoid** params);
+
+    template <class T>
+    int getVertexAttribParameter(GLuint index, GLenum param, T *ptr)
+    {
+        bool handled = true;
+        const VertexAttribState *vertexAttrib = getState(index);
+        if (vertexAttrib == NULL) {
+            ERR("getVeterxAttriParameter for non existant index %d\n", index);
+            // set gl error;
+            return handled;
+        }
+
+        switch(param) {
+        case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
+            *ptr = (T)(vertexAttrib->bufferObject);
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
+            *ptr = (T)(vertexAttrib->enabled);
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_SIZE:
+            *ptr = (T)(vertexAttrib->size);
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
+            *ptr = (T)(vertexAttrib->stride);
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_TYPE:
+            *ptr = (T)(vertexAttrib->type);
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
+            *ptr = (T)(vertexAttrib->normalized);
+            break;
+        case GL_CURRENT_VERTEX_ATTRIB:
+            handled = false;
+            break;
+        default:
+            handled = false;
+            ERR("unknown vertex-attrib parameter param %d\n", param);
+        }
+        return handled;
+    }
+
+    template <class T>
+    bool getClientStateParameter(GLenum param, T* ptr)
+    {
+        bool isClientStateParam = false;
+        switch (param) {
+        case GL_CLIENT_ACTIVE_TEXTURE: {
+            GLint tex = getActiveTexture() + GL_TEXTURE0;
+            *ptr = tex;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_VERTEX_ARRAY_SIZE: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION);
+            *ptr = state->size;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_VERTEX_ARRAY_TYPE: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION);
+            *ptr = state->type;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_VERTEX_ARRAY_STRIDE: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION);
+            *ptr = state->stride;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_COLOR_ARRAY_SIZE: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION);
+            *ptr = state->size;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_COLOR_ARRAY_TYPE: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION);
+            *ptr = state->type;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_COLOR_ARRAY_STRIDE: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION);
+            *ptr = state->stride;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_NORMAL_ARRAY_TYPE: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION);
+            *ptr = state->type;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_NORMAL_ARRAY_STRIDE: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION);
+            *ptr = state->stride;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_TEXTURE_COORD_ARRAY_SIZE: {
+            const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION);
+            *ptr = state->size;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_TEXTURE_COORD_ARRAY_TYPE: {
+            const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION);
+            *ptr = state->type;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_TEXTURE_COORD_ARRAY_STRIDE: {
+            const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION);
+            *ptr = state->stride;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_POINT_SIZE_ARRAY_TYPE_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION);
+            *ptr = state->type;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_POINT_SIZE_ARRAY_STRIDE_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION);
+            *ptr = state->stride;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_MATRIX_INDEX_ARRAY_SIZE_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION);
+            *ptr = state->size;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_MATRIX_INDEX_ARRAY_TYPE_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION);
+            *ptr = state->type;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_MATRIX_INDEX_ARRAY_STRIDE_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION);
+            *ptr = state->stride;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_WEIGHT_ARRAY_SIZE_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION);
+            *ptr = state->size;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_WEIGHT_ARRAY_TYPE_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION);
+            *ptr = state->type;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_WEIGHT_ARRAY_STRIDE_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION);
+            *ptr = state->stride;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_VERTEX_ARRAY_BUFFER_BINDING: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION);
+            *ptr = state->bufferObject;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_NORMAL_ARRAY_BUFFER_BINDING: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION);
+            *ptr = state->bufferObject;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_COLOR_ARRAY_BUFFER_BINDING: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION);
+            *ptr = state->bufferObject;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: {
+            const GLClientState::VertexAttribState *state = getState(getActiveTexture()+GLClientState::TEXCOORD0_LOCATION);
+            *ptr = state->bufferObject;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION);
+            *ptr = state->bufferObject;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION);
+            *ptr = state->bufferObject;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES: {
+            const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION);
+            *ptr = state->bufferObject;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_ARRAY_BUFFER_BINDING: {
+            int buffer = getBuffer(GL_ARRAY_BUFFER);
+            *ptr = buffer;
+            isClientStateParam = true;
+            break;
+            }
+        case GL_ELEMENT_ARRAY_BUFFER_BINDING: {
+            int buffer = getBuffer(GL_ELEMENT_ARRAY_BUFFER);
+            *ptr = buffer;
+            isClientStateParam = true;
+            break;
+            }
+        }
+        return isClientStateParam;
+    }
+
+};
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h
new file mode 100644
index 0000000..23785ae
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h
@@ -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.
+*/
+#ifndef _GL_DECODER_CONTEXT_DATA_H_
+#define _GL_DECODER_CONTEXT_DATA_H_
+
+#include <assert.h>
+#include <string.h>
+#include "FixedBuffer.h"
+#include "codec_defs.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,
+        MATRIXINDEX_LOCATION = 12,
+        WEIGHT_LOCATION = 13,
+        LAST_LOCATION = 14
+    } PointerDataLocation;
+
+    GLDecoderContextData(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES) :
+        m_nLocations(nLocations)
+    {
+        m_pointerData = new FixedBuffer[m_nLocations];
+    }
+
+    ~GLDecoderContextData() {
+        delete [] m_pointerData;
+    }
+
+    void storePointerData(unsigned int loc, void *data, size_t len) {
+
+        assert(loc < m_nLocations);
+        m_pointerData[loc].alloc(len);
+        memcpy(m_pointerData[loc].ptr(), data, len);
+    }
+    void *pointerData(unsigned int loc) {
+        assert(loc < m_nLocations);
+        return m_pointerData[loc].ptr();
+    }
+private:
+    FixedBuffer *m_pointerData;
+    int m_nLocations;
+};
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h
new file mode 100644
index 0000000..5654aea
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h
@@ -0,0 +1,34 @@
+/*
+* Copyright 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_ERROR_LOG_H__
+#define __GL_ERROR_LOG_H__
+
+#include "ErrorLog.h"
+
+#ifdef CHECK_GL_ERROR
+void dbg(){}
+#define GET_GL_ERROR(gl)  \
+    {   \
+        int err = gl.glGetError();    \
+        if (err) { dbg(); ERR("Error: 0x%X in %s (%s:%d)\n", err, __FUNCTION__, __FILE__, __LINE__); }  \
+    }
+
+#else
+#define GET_GL_ERROR(gl)
+#endif
+
+#endif //__GL_ERROR_LOG_H__
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
new file mode 100644
index 0000000..8504f7f
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
@@ -0,0 +1,469 @@
+/*
+* 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 "GLSharedGroup.h"
+
+/**** BufferData ****/
+
+BufferData::BufferData() : m_size(0) {};
+BufferData::BufferData(GLsizeiptr size, void * data) : m_size(size) 
+{
+    void * buffer = NULL;
+    if (size>0) buffer = m_fixedBuffer.alloc(size);
+    if (data) memcpy(buffer, data, size);
+}
+
+/**** ProgramData ****/
+ProgramData::ProgramData() : m_numIndexes(0),
+                             m_initialized(false),
+                             m_locShiftWAR(false)
+{
+    m_Indexes = NULL;
+}
+
+void ProgramData::initProgramData(GLuint numIndexes)
+{
+    m_initialized = true;
+    m_numIndexes = numIndexes;
+    delete[] m_Indexes;
+    m_Indexes = new IndexInfo[numIndexes];
+    m_locShiftWAR = false;
+}
+
+bool ProgramData::isInitialized()
+{
+    return m_initialized;
+}
+
+ProgramData::~ProgramData()
+{
+    delete[] m_Indexes;
+    m_Indexes = NULL;
+}
+
+void ProgramData::setIndexInfo(GLuint index, GLint base, GLint size, GLenum type)
+{   
+    if (index>=m_numIndexes)
+        return;
+    m_Indexes[index].base = base;
+    m_Indexes[index].size = size;
+    m_Indexes[index].type = type;
+    if (index > 0) {
+        m_Indexes[index].appBase = m_Indexes[index-1].appBase +
+                                   m_Indexes[index-1].size;
+    }
+    else {
+        m_Indexes[index].appBase = 0;
+    }
+    m_Indexes[index].hostLocsPerElement = 1;
+    m_Indexes[index].flags = 0;
+    m_Indexes[index].samplerValue = 0;
+}
+
+void ProgramData::setIndexFlags(GLuint index, GLuint flags)
+{
+    if (index >= m_numIndexes)
+        return;
+    m_Indexes[index].flags |= flags;
+}
+
+GLuint ProgramData::getIndexForLocation(GLint location)
+{
+    GLuint index = m_numIndexes;
+    GLint minDist = -1;
+    for (GLuint i=0;i<m_numIndexes;++i)
+    {
+        GLint dist = location - m_Indexes[i].base;
+        if (dist >= 0 && 
+            (minDist < 0 || dist < minDist)) {
+            index = i;
+            minDist = dist;
+        }
+    }
+    return index;
+}
+
+GLenum ProgramData::getTypeForLocation(GLint location)
+{
+    GLuint index = getIndexForLocation(location);
+    if (index<m_numIndexes) {
+        return m_Indexes[index].type;
+    }
+    return 0;
+}
+
+void ProgramData::setupLocationShiftWAR()
+{
+    m_locShiftWAR = false;
+    for (GLuint i=0; i<m_numIndexes; i++) {
+        if (0 != (m_Indexes[i].base & 0xffff)) {
+            return;
+        }
+    }
+    // if we have one uniform at location 0, we do not need the WAR.
+    if (m_numIndexes > 1) {
+        m_locShiftWAR = true;
+    }
+}
+
+GLint ProgramData::locationWARHostToApp(GLint hostLoc, GLint arrIndex)
+{
+    if (!m_locShiftWAR) return hostLoc;
+
+    GLuint index = getIndexForLocation(hostLoc);
+    if (index<m_numIndexes) {
+        if (arrIndex > 0) {
+            m_Indexes[index].hostLocsPerElement = 
+                              (hostLoc - m_Indexes[index].base) / arrIndex;
+        }
+        return m_Indexes[index].appBase + arrIndex;
+    }
+    return -1;
+}
+
+GLint ProgramData::locationWARAppToHost(GLint appLoc)
+{
+    if (!m_locShiftWAR) return appLoc;
+
+    for(GLuint i=0; i<m_numIndexes; i++) {
+        GLint elemIndex = appLoc - m_Indexes[i].appBase;
+        if (elemIndex >= 0 && elemIndex < m_Indexes[i].size) {
+            return m_Indexes[i].base +
+                   elemIndex * m_Indexes[i].hostLocsPerElement;
+        }
+    }
+    return -1;
+}
+
+GLint ProgramData::getNextSamplerUniform(GLint index, GLint* val, GLenum* target)
+{
+    for (GLint i = index + 1; i >= 0 && i < (GLint)m_numIndexes; i++) {
+        if (m_Indexes[i].type == GL_SAMPLER_2D) {
+            if (val) *val = m_Indexes[i].samplerValue;
+            if (target) {
+                if (m_Indexes[i].flags & INDEX_FLAG_SAMPLER_EXTERNAL) {
+                    *target = GL_TEXTURE_EXTERNAL_OES;
+                } else {
+                    *target = GL_TEXTURE_2D;
+                }
+            }
+            return i;
+        }
+    }
+    return -1;
+}
+
+bool ProgramData::setSamplerUniform(GLint appLoc, GLint val, GLenum* target)
+{
+    for (GLuint i = 0; i < m_numIndexes; i++) {
+        GLint elemIndex = appLoc - m_Indexes[i].appBase;
+        if (elemIndex >= 0 && elemIndex < m_Indexes[i].size) {
+            if (m_Indexes[i].type == GL_TEXTURE_2D) {
+                m_Indexes[i].samplerValue = val;
+                if (target) {
+                    if (m_Indexes[i].flags & INDEX_FLAG_SAMPLER_EXTERNAL) {
+                        *target = GL_TEXTURE_EXTERNAL_OES;
+                    } else {
+                        *target = GL_TEXTURE_2D;
+                    }
+                }
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+bool ProgramData::attachShader(GLuint shader)
+{
+    size_t n = m_shaders.size();
+    for (size_t i = 0; i < n; i++) {
+        if (m_shaders[i] == shader) {
+            return false;
+        }
+    }
+    // AKA m_shaders.push_back(), but that has an ambiguous call to insertAt()
+    // due to the default parameters. This is the desired insertAt() overload.
+    m_shaders.insertAt(shader, m_shaders.size(), 1);
+    return true;
+}
+
+bool ProgramData::detachShader(GLuint shader)
+{
+    size_t n = m_shaders.size();
+    for (size_t i = 0; i < n; i++) {
+        if (m_shaders[i] == shader) {
+            m_shaders.removeAt(i);
+            return true;
+        }
+    }
+    return false;
+}
+
+/***** GLSharedGroup ****/
+
+GLSharedGroup::GLSharedGroup() :
+    m_buffers(android::DefaultKeyedVector<GLuint, BufferData*>(NULL)),
+    m_programs(android::DefaultKeyedVector<GLuint, ProgramData*>(NULL)),
+    m_shaders(android::DefaultKeyedVector<GLuint, ShaderData*>(NULL))
+{
+}
+
+GLSharedGroup::~GLSharedGroup()
+{
+    m_buffers.clear();
+    m_programs.clear();
+}
+
+BufferData * GLSharedGroup::getBufferData(GLuint bufferId)
+{
+    android::AutoMutex _lock(m_lock);
+    return m_buffers.valueFor(bufferId);    
+}
+
+void GLSharedGroup::addBufferData(GLuint bufferId, GLsizeiptr size, void * data)
+{
+    android::AutoMutex _lock(m_lock);
+    m_buffers.add(bufferId, new BufferData(size, data));
+}
+
+void GLSharedGroup::updateBufferData(GLuint bufferId, GLsizeiptr size, void * data)
+{
+    android::AutoMutex _lock(m_lock);
+    m_buffers.replaceValueFor(bufferId, new BufferData(size, data));
+}
+
+GLenum GLSharedGroup::subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsizeiptr size, void * data)
+{
+    android::AutoMutex _lock(m_lock);
+    BufferData * buf = m_buffers.valueFor(bufferId);
+    if ((!buf) || (buf->m_size < offset+size) || (offset < 0) || (size<0)) return GL_INVALID_VALUE; 
+
+    //it's safe to update now
+    memcpy((char*)buf->m_fixedBuffer.ptr() + offset, data, size);
+    return GL_NO_ERROR; 
+}
+
+void GLSharedGroup::deleteBufferData(GLuint bufferId)
+{
+    android::AutoMutex _lock(m_lock);
+    m_buffers.removeItem(bufferId);
+}
+
+void GLSharedGroup::addProgramData(GLuint program)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData *pData = m_programs.valueFor(program);
+    if (pData) 
+    {   
+        m_programs.removeItem(program);
+        delete pData;
+    }
+
+    m_programs.add(program,new ProgramData());
+}
+
+void GLSharedGroup::initProgramData(GLuint program, GLuint numIndexes)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData *pData = m_programs.valueFor(program);
+    if (pData)
+    {
+        pData->initProgramData(numIndexes);
+    }
+}
+
+bool GLSharedGroup::isProgramInitialized(GLuint program)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    if (pData) 
+    {
+        return pData->isInitialized();
+    }
+    return false;
+}
+
+void GLSharedGroup::deleteProgramData(GLuint program)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData *pData = m_programs.valueFor(program);
+    if (pData)
+        delete pData;
+    m_programs.removeItem(program); 
+}
+
+void GLSharedGroup::attachShader(GLuint program, GLuint shader)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* programData = m_programs.valueFor(program);
+    ssize_t idx = m_shaders.indexOfKey(shader);
+    if (programData && idx >= 0) {
+        if (programData->attachShader(shader)) {
+            refShaderDataLocked(idx);
+        }
+    }
+}
+
+void GLSharedGroup::detachShader(GLuint program, GLuint shader)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* programData = m_programs.valueFor(program);
+    ssize_t idx = m_shaders.indexOfKey(shader);
+    if (programData && idx >= 0) {
+        if (programData->detachShader(shader)) {
+            unrefShaderDataLocked(idx);
+        }
+    }
+}
+
+void GLSharedGroup::setProgramIndexInfo(GLuint program, GLuint index, GLint base, GLint size, GLenum type, const char* name)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    if (pData)
+    {
+        pData->setIndexInfo(index,base,size,type);
+
+        if (type == GL_SAMPLER_2D) {
+            size_t n = pData->getNumShaders();
+            for (size_t i = 0; i < n; i++) {
+                GLuint shaderId = pData->getShader(i);
+                ShaderData* shader = m_shaders.valueFor(shaderId);
+                if (!shader) continue;
+                ShaderData::StringList::iterator nameIter = shader->samplerExternalNames.begin();
+                ShaderData::StringList::iterator nameEnd  = shader->samplerExternalNames.end();
+                while (nameIter != nameEnd) {
+                    if (*nameIter == name) {
+                        pData->setIndexFlags(index, ProgramData::INDEX_FLAG_SAMPLER_EXTERNAL);
+                        break;
+                    }
+                    ++nameIter;
+                }
+            }
+        }
+    }
+}
+
+GLenum GLSharedGroup::getProgramUniformType(GLuint program, GLint location)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    GLenum type=0;
+    if (pData) 
+    {
+        type = pData->getTypeForLocation(location);
+    }
+    return type;
+}
+
+bool  GLSharedGroup::isProgram(GLuint program)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    return (pData!=NULL);
+}
+
+void GLSharedGroup::setupLocationShiftWAR(GLuint program)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    if (pData) pData->setupLocationShiftWAR();
+}
+
+GLint GLSharedGroup::locationWARHostToApp(GLuint program, GLint hostLoc, GLint arrIndex)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    if (pData) return pData->locationWARHostToApp(hostLoc, arrIndex);
+    else return hostLoc;
+}
+
+GLint GLSharedGroup::locationWARAppToHost(GLuint program, GLint appLoc)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    if (pData) return pData->locationWARAppToHost(appLoc);
+    else return appLoc;
+}
+
+bool GLSharedGroup::needUniformLocationWAR(GLuint program)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    if (pData) return pData->needUniformLocationWAR();
+    return false;
+}
+
+GLint GLSharedGroup::getNextSamplerUniform(GLuint program, GLint index, GLint* val, GLenum* target) const
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    return pData ? pData->getNextSamplerUniform(index, val, target) : -1;
+}
+
+bool GLSharedGroup::setSamplerUniform(GLuint program, GLint appLoc, GLint val, GLenum* target)
+{
+    android::AutoMutex _lock(m_lock);
+    ProgramData* pData = m_programs.valueFor(program);
+    return pData ? pData->setSamplerUniform(appLoc, val, target) : false;
+}
+
+bool GLSharedGroup::addShaderData(GLuint shader)
+{
+    android::AutoMutex _lock(m_lock);
+    ShaderData* data = new ShaderData;
+    if (data) {
+        if (m_shaders.add(shader, data) < 0) {
+            delete data;
+            data = NULL;
+        }
+        data->refcount = 1;
+    }
+    return data != NULL;
+}
+
+ShaderData* GLSharedGroup::getShaderData(GLuint shader)
+{
+    android::AutoMutex _lock(m_lock);
+    return m_shaders.valueFor(shader);
+}
+
+void GLSharedGroup::unrefShaderData(GLuint shader)
+{
+    android::AutoMutex _lock(m_lock);
+    ssize_t idx = m_shaders.indexOfKey(shader);
+    if (idx >= 0) {
+        unrefShaderDataLocked(idx);
+    }
+}
+
+void GLSharedGroup::refShaderDataLocked(ssize_t shaderIdx)
+{
+    assert(shaderIdx >= 0 && shaderIdx <= m_shaders.size());
+    ShaderData* data = m_shaders.valueAt(shaderIdx);
+    data->refcount++;
+}
+
+void GLSharedGroup::unrefShaderDataLocked(ssize_t shaderIdx)
+{
+    assert(shaderIdx >= 0 && shaderIdx <= m_shaders.size());
+    ShaderData* data = m_shaders.valueAt(shaderIdx);
+    if (--data->refcount == 0) {
+        delete data;
+        m_shaders.removeItemsAt(shaderIdx);
+    }
+}
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h
new file mode 100644
index 0000000..61b8f00
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h
@@ -0,0 +1,143 @@
+/*
+* 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_SHARED_GROUP_H_
+#define _GL_SHARED_GROUP_H_
+
+#define GL_API
+#ifndef ANDROID
+#define GL_APIENTRY
+#define GL_APIENTRYP
+#endif
+
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "ErrorLog.h"
+#include <utils/KeyedVector.h>
+#include <utils/List.h>
+#include <utils/String8.h>
+#include <utils/threads.h>
+#include "FixedBuffer.h"
+#include "SmartPtr.h"
+
+struct BufferData {
+    BufferData();
+    BufferData(GLsizeiptr size, void * data);
+    GLsizeiptr  m_size;
+    FixedBuffer m_fixedBuffer;    
+};
+
+class ProgramData {
+private:
+    typedef struct _IndexInfo {
+        GLint base;
+        GLint size;
+        GLenum type;
+        GLint appBase;
+        GLint hostLocsPerElement;
+        GLuint flags;
+        GLint samplerValue; // only set for sampler uniforms
+    } IndexInfo;
+
+    GLuint m_numIndexes;
+    IndexInfo* m_Indexes;
+    bool m_initialized;
+    bool m_locShiftWAR;
+
+    android::Vector<GLuint> m_shaders;
+
+public:
+    enum {
+        INDEX_FLAG_SAMPLER_EXTERNAL = 0x00000001,
+    };
+
+    ProgramData();
+    void initProgramData(GLuint numIndexes);
+    bool isInitialized();
+    virtual ~ProgramData();
+    void setIndexInfo(GLuint index, GLint base, GLint size, GLenum type);
+    void setIndexFlags(GLuint index, GLuint flags);
+    GLuint getIndexForLocation(GLint location);
+    GLenum getTypeForLocation(GLint location);
+
+    bool needUniformLocationWAR() const { return m_locShiftWAR; }
+    void setupLocationShiftWAR();
+    GLint locationWARHostToApp(GLint hostLoc, GLint arrIndex);
+    GLint locationWARAppToHost(GLint appLoc);
+
+    GLint getNextSamplerUniform(GLint index, GLint* val, GLenum* target);
+    bool setSamplerUniform(GLint appLoc, GLint val, GLenum* target);
+
+    bool attachShader(GLuint shader);
+    bool detachShader(GLuint shader);
+    size_t getNumShaders() const { return m_shaders.size(); }
+    GLuint getShader(size_t i) const { return m_shaders[i]; }
+};
+
+struct ShaderData {
+    typedef android::List<android::String8> StringList;
+    StringList samplerExternalNames;
+    int refcount;
+};
+
+class GLSharedGroup {
+private:
+    android::DefaultKeyedVector<GLuint, BufferData*> m_buffers;
+    android::DefaultKeyedVector<GLuint, ProgramData*> m_programs;
+    android::DefaultKeyedVector<GLuint, ShaderData*> m_shaders;
+    mutable android::Mutex m_lock;
+
+    void refShaderDataLocked(ssize_t shaderIdx);
+    void unrefShaderDataLocked(ssize_t shaderIdx);
+
+public:
+    GLSharedGroup();
+    ~GLSharedGroup();
+    BufferData * getBufferData(GLuint bufferId);
+    void    addBufferData(GLuint bufferId, GLsizeiptr size, void * data);
+    void    updateBufferData(GLuint bufferId, GLsizeiptr size, void * data);
+    GLenum  subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsizeiptr size, void * data);
+    void    deleteBufferData(GLuint);
+
+    bool    isProgram(GLuint program);
+    bool    isProgramInitialized(GLuint program);
+    void    addProgramData(GLuint program); 
+    void    initProgramData(GLuint program, GLuint numIndexes);
+    void    attachShader(GLuint program, GLuint shader);
+    void    detachShader(GLuint program, GLuint shader);
+    void    deleteProgramData(GLuint program);
+    void    setProgramIndexInfo(GLuint program, GLuint index, GLint base, GLint size, GLenum type, const char* name);
+    GLenum  getProgramUniformType(GLuint program, GLint location);
+    void    setupLocationShiftWAR(GLuint program);
+    GLint   locationWARHostToApp(GLuint program, GLint hostLoc, GLint arrIndex);
+    GLint   locationWARAppToHost(GLuint program, GLint appLoc);
+    bool    needUniformLocationWAR(GLuint program);
+    GLint   getNextSamplerUniform(GLuint program, GLint index, GLint* val, GLenum* target) const;
+    bool    setSamplerUniform(GLuint program, GLint appLoc, GLint val, GLenum* target);
+
+    bool    addShaderData(GLuint shader);
+    // caller must hold a reference to the shader as long as it holds the pointer
+    ShaderData* getShaderData(GLuint shader);
+    void    unrefShaderData(GLuint shader);
+};
+
+typedef SmartPtr<GLSharedGroup> GLSharedGroupPtr; 
+
+#endif //_GL_SHARED_GROUP_H_
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/Makefile b/tools/emulator/opengl/shared/OpenglCodecCommon/Makefile
new file mode 100644
index 0000000..e8bf431
--- /dev/null
+++ b/tools/emulator/opengl/shared/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/shared/OpenglCodecCommon/SmartPtr.h b/tools/emulator/opengl/shared/OpenglCodecCommon/SmartPtr.h
new file mode 100644
index 0000000..4bdfbe4
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/SmartPtr.h
@@ -0,0 +1,167 @@
+/*
+* 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 __SMART_PTR_H
+#define __SMART_PTR_H
+
+#include <cutils/threads.h>
+#include <cutils/atomic.h>
+
+template <class T, bool threadSafe = false>
+class SmartPtr
+{
+public:
+    explicit SmartPtr(T* ptr = (T*)NULL) {
+        if (threadSafe) {
+            m_lock = new mutex_t;
+            mutex_init(m_lock);
+        }
+        else m_lock = NULL;
+
+        m_ptr = ptr;
+        if (ptr)
+           m_pRefCount = new int32_t(1);
+        else
+           m_pRefCount = NULL;
+    }
+
+    SmartPtr<T,threadSafe>(const SmartPtr<T,false>& rhs) {
+        if (threadSafe) {
+            m_lock = new mutex_t;
+            mutex_init(m_lock);
+        }
+        else m_lock = NULL;
+
+        m_pRefCount = rhs.m_pRefCount;
+        m_ptr       = rhs.m_ptr;
+        use();
+    }
+
+    SmartPtr<T,threadSafe>(SmartPtr<T,true>& rhs) {
+        if (threadSafe) {
+            m_lock = new mutex_t;
+            mutex_init(m_lock);
+        }
+        else m_lock = NULL;
+
+        if (rhs.m_lock) mutex_lock(rhs.m_lock);
+        m_pRefCount = rhs.m_pRefCount;
+        m_ptr       = rhs.m_ptr;
+        use();
+        if (rhs.m_lock) mutex_unlock(rhs.m_lock);
+    }
+
+    ~SmartPtr() {
+        if (m_lock) mutex_lock(m_lock);
+        release();
+        if (m_lock)
+        {
+            mutex_unlock(m_lock);
+            mutex_destroy(m_lock);
+            delete m_lock;
+        }
+    }
+
+    T* Ptr() const {
+        return m_ptr;
+    }
+
+    const T* constPtr() const
+    {
+        return m_ptr;
+    }
+
+    T* operator->() const {
+        return m_ptr;
+    }
+
+    T& operator*() const {
+        return *m_ptr;
+    }
+
+    operator void*() const {
+        return (void *)m_ptr;
+    }
+
+    // This gives STL lists something to compare.
+    bool operator <(const SmartPtr<T>& t1) const {
+        return m_ptr < t1.m_ptr;
+    }
+
+    SmartPtr<T,threadSafe>& operator=(const SmartPtr<T,false>& rhs)
+    {
+        if (m_ptr == rhs.m_ptr)
+            return *this;
+
+        if (m_lock) mutex_lock(m_lock);
+        release();
+        m_pRefCount = rhs.m_pRefCount;
+        m_ptr       = rhs.m_ptr;
+        use();
+        if (m_lock) mutex_unlock(m_lock);
+
+        return *this;
+    }
+
+    SmartPtr<T,threadSafe>& operator=(SmartPtr<T,true>& rhs)
+    {
+        if (m_ptr == rhs.m_ptr)
+            return *this;
+
+        if (m_lock) mutex_lock(m_lock);
+        release();
+        if (rhs.m_lock) mutex_lock(rhs.m_lock);
+        m_pRefCount = rhs.m_pRefCount;
+        m_ptr       = rhs.m_ptr;
+        use();
+        if (rhs.m_lock) mutex_unlock(rhs.m_lock);
+        if (m_lock) mutex_unlock(m_lock);
+
+        return *this;
+    }
+
+private:
+    int32_t  *m_pRefCount;
+    mutex_t  *m_lock;
+    T* m_ptr;
+
+    // Increment the reference count on this pointer by 1.
+    int use() {
+        if (!m_pRefCount) return 0;
+        return android_atomic_inc(m_pRefCount) + 1;
+    }
+
+    // Decrement the reference count on the pointer by 1.
+    // If the reference count goes to (or below) 0, the pointer is deleted.
+    int release() {
+        if (!m_pRefCount) return 0;
+
+        int iVal = android_atomic_dec(m_pRefCount);
+        if (iVal > 1)
+            return iVal - 1;
+
+        delete m_pRefCount;
+        m_pRefCount = NULL;
+
+        if (m_ptr) {
+            delete m_ptr;
+            m_ptr = NULL;
+        }
+        return 0;
+    }
+
+};
+
+#endif // of  __SMART_PTR_H
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp
new file mode 100644
index 0000000..f7a2314
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp
@@ -0,0 +1,168 @@
+/*
+* 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 "SocketStream.h"
+#include <cutils/sockets.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifndef _WIN32
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/un.h>
+#else
+#include <ws2tcpip.h>
+#endif
+
+SocketStream::SocketStream(size_t bufSize) :
+    IOStream(bufSize),
+    m_sock(-1),
+    m_bufsize(bufSize),
+    m_buf(NULL)
+{
+}
+
+SocketStream::SocketStream(int sock, size_t bufSize) :
+    IOStream(bufSize),
+    m_sock(sock),
+    m_bufsize(bufSize),
+    m_buf(NULL)
+{
+}
+
+SocketStream::~SocketStream()
+{
+    if (m_sock >= 0) {
+#ifdef _WIN32
+        closesocket(m_sock);
+#else
+        ::close(m_sock);
+#endif
+    }
+    if (m_buf != NULL) {
+        free(m_buf);
+        m_buf = NULL;
+    }
+}
+
+
+void *SocketStream::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("%s: realloc (%zu) failed\n", __FUNCTION__, allocSize);
+            free(m_buf);
+            m_buf = NULL;
+            m_bufsize = 0;
+        }
+    }
+
+    return m_buf;
+};
+
+int SocketStream::commitBuffer(size_t size)
+{
+    return writeFully(m_buf, size);
+}
+
+int SocketStream::writeFully(const void* buffer, size_t size)
+{
+    if (!valid()) return -1;
+
+    size_t res = size;
+    int retval = 0;
+
+    while (res > 0) {
+        ssize_t stat = ::send(m_sock, (const char *)buffer + (size - res), res, 0);
+        if (stat < 0) {
+            if (errno != EINTR) {
+                retval =  stat;
+                ERR("%s: failed: %s\n", __FUNCTION__, strerror(errno));
+                break;
+            }
+        } else {
+            res -= stat;
+        }
+    }
+    return retval;
+}
+
+const unsigned char *SocketStream::readFully(void *buf, size_t len)
+{
+    const unsigned char* ret = NULL;
+    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, (char *)(buf) + len - res, res, 0);
+        if (stat > 0) {
+            res -= stat;
+            continue;
+        }
+        if (stat == 0 || errno != EINTR) { // client shutdown or error
+            return NULL;
+        }
+    }
+    return (const unsigned char *)buf;
+}
+
+const unsigned char *SocketStream::read( void *buf, size_t *inout_len)
+{
+    if (!valid()) return NULL;
+    if (!buf) {
+      return NULL;  // do not allow NULL buf in that implementation
+    }
+
+    int n;
+    do {
+        n = recv(buf, *inout_len);
+    } while( n < 0 && errno == EINTR );
+
+    if (n > 0) {
+        *inout_len = n;
+        return (const unsigned char *)buf;
+    }
+
+    return NULL;
+}
+
+int SocketStream::recv(void *buf, size_t len)
+{
+    if (!valid()) return int(ERR_INVALID_SOCKET);
+    int res = 0;
+    while(true) {
+        res = ::recv(m_sock, (char *)buf, len, 0);
+        if (res < 0) {
+            if (errno == EINTR) {
+                continue;
+            }
+        }
+        break;
+    }
+    return res;
+}
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/SocketStream.h b/tools/emulator/opengl/shared/OpenglCodecCommon/SocketStream.h
new file mode 100644
index 0000000..3a501b4
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/SocketStream.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 __SOCKET_STREAM_H
+#define __SOCKET_STREAM_H
+
+#include <stdlib.h>
+#include "IOStream.h"
+
+class SocketStream : public IOStream {
+public:
+    typedef enum { ERR_INVALID_SOCKET = -1000 } SocketStreamError;
+
+    explicit SocketStream(size_t bufsize = 10000);
+    virtual ~SocketStream();
+
+    virtual int listen(unsigned short port) = 0;
+    virtual SocketStream *accept() = 0;
+    virtual int connect(unsigned short port) = 0;
+
+    virtual void *allocBuffer(size_t minSize);
+    virtual int commitBuffer(size_t size);
+    virtual const unsigned char *readFully(void *buf, size_t len);
+    virtual const unsigned char *read(void *buf, size_t *inout_len);
+
+    bool valid() { return m_sock >= 0; }
+    virtual int recv(void *buf, size_t len);
+    virtual int writeFully(const void *buf, size_t len);
+
+protected:
+    int            m_sock;
+    size_t         m_bufsize;
+    unsigned char *m_buf;
+
+    SocketStream(int sock, size_t bufSize);
+};
+
+#endif /* __SOCKET_STREAM_H */
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
new file mode 100644
index 0000000..4da2cec
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.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 "TcpStream.h"
+#include <cutils/sockets.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifndef _WIN32
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#else
+#include <ws2tcpip.h>
+#endif
+
+TcpStream::TcpStream(size_t bufSize) :
+    SocketStream(bufSize)
+{
+}
+
+TcpStream::TcpStream(int sock, size_t bufSize) :
+    SocketStream(sock, bufSize)
+{
+    // disable Nagle algorithm to improve bandwidth of small
+    // packets which are quite common in our implementation.
+#ifdef _WIN32
+    DWORD  flag;
+#else
+    int    flag;
+#endif
+    flag = 1;
+    setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&flag, sizeof(flag) );
+}
+
+int TcpStream::listen(unsigned short port)
+{
+    m_sock = socket_loopback_server(port, SOCK_STREAM);
+    if (!valid()) return int(ERR_INVALID_SOCKET);
+
+    return 0;
+}
+
+SocketStream * 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(unsigned short port)
+{
+    return connect("127.0.0.1",port);
+}
+
+int TcpStream::connect(const char* hostname, unsigned short port)
+{
+    m_sock = socket_network_client(hostname, port, SOCK_STREAM);
+    if (!valid()) return -1;
+    return 0;
+}
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.h b/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.h
new file mode 100644
index 0000000..811a871
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.h
@@ -0,0 +1,32 @@
+/*
+* 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 "SocketStream.h"
+
+class TcpStream : public SocketStream {
+public:
+    explicit TcpStream(size_t bufsize = 10000);
+    virtual int listen(unsigned short port);
+    virtual SocketStream *accept();
+    virtual int connect(unsigned short port);
+    int connect(const char* hostname, unsigned short port);
+private:
+    TcpStream(int sock, size_t bufSize);
+};
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.cpp
new file mode 100644
index 0000000..50aeb03
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.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 "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>
+#include <unistd.h>
+#else
+#include <sys/time.h>
+#include <unistd.h>
+#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 /* Others, e.g. OS X */
+
+    struct timeval now;
+    gettimeofday(&now, NULL);
+    long long iDiff = (now.tv_sec * 1000LL) + now.tv_usec/1000LL;
+    return iDiff;
+
+#endif
+}
+
+void TimeSleepMS(int p_mili)
+{
+#ifdef _WIN32
+    Sleep(p_mili);
+#else
+    usleep(p_mili * 1000);
+#endif
+}
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.h b/tools/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.h
new file mode 100644
index 0000000..bc4fd1c
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.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 _TIME_UTILS_H
+#define _TIME_UTILS_H
+
+long long GetCurrentTimeMS();
+void TimeSleepMS(int p_mili);
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp
new file mode 100644
index 0000000..8e463a3
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp
@@ -0,0 +1,137 @@
+/*
+* 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 "UnixStream.h"
+#include <cutils/sockets.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+
+/* Not all systems define PATH_MAX, those who don't generally don't
+ * have a limit on the maximum path size, so use a value that is
+ * large enough for our very limited needs.
+ */
+#ifndef PATH_MAX
+#define PATH_MAX   128
+#endif
+
+UnixStream::UnixStream(size_t bufSize) :
+    SocketStream(bufSize)
+{
+}
+
+UnixStream::UnixStream(int sock, size_t bufSize) :
+    SocketStream(sock, bufSize)
+{
+}
+
+/* Initialize a sockaddr_un with the appropriate values corresponding
+ * to a given 'virtual port'. Returns 0 on success, -1 on error.
+ */
+static int
+make_unix_path(char *path, size_t  pathlen, int port_number)
+{
+    char  tmp[PATH_MAX];  // temp directory
+    int   ret = 0;
+
+    // First, create user-specific temp directory if needed
+    const char* user = getenv("USER");
+    if (user != NULL) {
+        struct stat  st;
+        snprintf(tmp, sizeof(tmp), "/tmp/android-%s", user);
+        do {
+            ret = ::lstat(tmp, &st);
+        } while (ret < 0 && errno == EINTR);
+
+        if (ret < 0 && errno == ENOENT) {
+            do {
+                ret = ::mkdir(tmp, 0766);
+            } while (ret < 0 && errno == EINTR);
+            if (ret < 0) {
+                ERR("Could not create temp directory: %s", tmp);
+                user = NULL;  // will fall-back to /tmp
+            }
+        }
+        else if (ret < 0) {
+            user = NULL;  // will fallback to /tmp
+        }
+    }
+
+    if (user == NULL) {  // fallback to /tmp in case of error
+        snprintf(tmp, sizeof(tmp), "/tmp");
+    }
+
+    // Now, initialize it properly
+    snprintf(path, pathlen, "%s/qemu-gles-%d", tmp, port_number);
+    return 0;
+}
+
+
+int UnixStream::listen(unsigned short port)
+{
+    char  path[PATH_MAX];
+
+    if (make_unix_path(path, sizeof(path), port) < 0) {
+        return -1;
+    }
+
+    m_sock = socket_local_server(path, ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM);
+    if (!valid()) return int(ERR_INVALID_SOCKET);
+
+    return 0;
+}
+
+SocketStream * UnixStream::accept()
+{
+    int clientSock = -1;
+
+    while (true) {
+        struct sockaddr_un addr;
+        socklen_t len = sizeof(addr);
+        clientSock = ::accept(m_sock, (sockaddr *)&addr, &len);
+
+        if (clientSock < 0 && errno == EINTR) {
+            continue;
+        }
+        break;
+    }
+
+    UnixStream *clientStream = NULL;
+
+    if (clientSock >= 0) {
+        clientStream =  new UnixStream(clientSock, m_bufsize);
+    }
+    return clientStream;
+}
+
+int UnixStream::connect(unsigned short port)
+{
+    char  path[PATH_MAX];
+
+    if (make_unix_path(path, sizeof(path), port) < 0)
+        return -1;
+
+    m_sock = socket_local_client(path, ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM);
+    if (!valid()) return -1;
+
+    return 0;
+}
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.h b/tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.h
new file mode 100644
index 0000000..c184b19
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.h
@@ -0,0 +1,31 @@
+/*
+* 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 __UNIX_STREAM_H
+#define __UNIX_STREAM_H
+
+#include "SocketStream.h"
+
+class UnixStream : public SocketStream {
+public:
+    explicit UnixStream(size_t bufsize = 10000);
+    virtual int listen(unsigned short port);
+    virtual SocketStream *accept();
+    virtual int connect(unsigned short port);
+private:
+    UnixStream(int sock, size_t bufSize);
+};
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp
new file mode 100644
index 0000000..e1a0b9b
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp
@@ -0,0 +1,239 @@
+/*
+* 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 "Win32PipeStream.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <windows.h>
+
+#ifndef _WIN32
+#error ONLY BUILD THIS SOURCE FILE FOR WINDOWS!
+#endif
+
+/* The official documentation states that the name of a given named
+ * pipe cannot be more than 256 characters long.
+ */
+#define NAMED_PIPE_MAX 256
+
+Win32PipeStream::Win32PipeStream(size_t bufSize) :
+    SocketStream(bufSize),
+    m_pipe(INVALID_HANDLE_VALUE)
+{
+}
+
+Win32PipeStream::Win32PipeStream(HANDLE pipe, size_t bufSize) :
+    SocketStream(-1, bufSize),
+    m_pipe(pipe)
+{
+}
+
+Win32PipeStream::~Win32PipeStream()
+{
+    if (m_pipe != INVALID_HANDLE_VALUE) {
+        CloseHandle(m_pipe);
+        m_pipe = INVALID_HANDLE_VALUE;
+    }
+}
+
+/* Initialize the pipe name corresponding to a given port
+ */
+static void
+make_pipe_name(char *path, size_t  pathlen, int port_number)
+{
+    snprintf(path, pathlen, "\\\\.\\pipe\\qemu-gles-%d", port_number);
+}
+
+
+/* Technical note: Named pipes work differently from BSD Sockets.
+ * One does not create/bind a pipe, and collect a new handle each
+ * time a client connects with accept().
+ *
+ * Instead, the server creates a new pipe instance each time it wants
+ * to get a new client connection, then calls ConnectNamedPipe() to
+ * wait for a connection.
+ *
+ * So listen() is a no-op, and accept() really creates the pipe handle.
+ *
+ * Also, connect() must create a pipe handle with CreateFile() and
+ * wait for a server instance with WaitNamedPipe()
+ */
+int Win32PipeStream::listen(unsigned short port)
+{
+    // just save the port number for accept()
+    m_port = port;
+    return 0;
+}
+
+SocketStream * Win32PipeStream::accept()
+{
+    char path[NAMED_PIPE_MAX+1];
+    SocketStream*  clientStream;
+    HANDLE pipe;
+
+    make_pipe_name(path, sizeof(path), m_port);
+
+    pipe = ::CreateNamedPipe(
+                path,                // pipe name
+                PIPE_ACCESS_DUPLEX,  // read-write access
+                PIPE_TYPE_BYTE |     // byte-oriented writes
+                PIPE_READMODE_BYTE | // byte-oriented reads
+                PIPE_WAIT,           // blocking operations
+                PIPE_UNLIMITED_INSTANCES, // no limit on clients
+                4096,                // input buffer size
+                4096,                // output buffer size
+                0,                   // client time-out
+                NULL);               // default security attributes
+
+    if (pipe == INVALID_HANDLE_VALUE) {
+        ERR("%s: CreateNamedPipe failed %d\n", __FUNCTION__, (int)GetLastError());
+        return NULL;
+    }
+
+    // Stupid Win32 API design: If a client is already connected, then
+    // ConnectNamedPipe will return 0, and GetLastError() will return
+    // ERROR_PIPE_CONNECTED. This is not an error! It just means that the
+    // function didn't have to wait.
+    //
+    if (::ConnectNamedPipe(pipe, NULL) == 0 && GetLastError() != ERROR_PIPE_CONNECTED) {
+        ERR("%s: ConnectNamedPipe failed: %d\n", __FUNCTION__, (int)GetLastError());
+        CloseHandle(pipe);
+        return NULL;
+    }
+
+    clientStream = new Win32PipeStream(pipe, m_bufsize);
+    return clientStream;
+}
+
+int Win32PipeStream::connect(unsigned short port)
+{
+    char   path[NAMED_PIPE_MAX+1];
+    HANDLE pipe;
+    int    tries = 10;
+
+    make_pipe_name(path, sizeof(path), port);
+
+    /* We're going to loop in order to wait for the pipe server to
+     * be setup properly.
+     */
+    for (; tries > 0; tries--) {
+        pipe = ::CreateFile(
+                    path,                          // pipe name
+                    GENERIC_READ | GENERIC_WRITE,  // read & write
+                    0,                             // no sharing
+                    NULL,                          // default security attrs
+                    OPEN_EXISTING,                 // open existing pipe
+                    0,                             // default attributes
+                    NULL);                         // no template file
+
+        /* If we have a valid pipe handle, break from the loop */
+        if (pipe != INVALID_HANDLE_VALUE) {
+            break;
+        }
+
+        /* We can get here if the pipe is busy, i.e. if the server hasn't
+         * create a new pipe instance to service our request. In which case
+         * GetLastError() will return ERROR_PIPE_BUSY.
+         *
+         * If so, then use WaitNamedPipe() to wait for a decent time
+         * to try again.
+         */
+        if (GetLastError() != ERROR_PIPE_BUSY) {
+            /* Not ERROR_PIPE_BUSY */
+            ERR("%s: CreateFile failed: %d\n", __FUNCTION__, (int)GetLastError());
+            errno = EINVAL;
+            return -1;
+        }
+
+        /* Wait for 5 seconds */
+        if ( !WaitNamedPipe(path, 5000) ) {
+            ERR("%s: WaitNamedPipe failed: %d\n", __FUNCTION__, (int)GetLastError());
+            errno = EINVAL;
+            return -1;
+        }
+    }
+
+    m_pipe = pipe;
+    return 0;
+}
+
+/* Special buffer methods, since we can't use socket functions here */
+
+int Win32PipeStream::commitBuffer(size_t size)
+{
+    if (m_pipe == INVALID_HANDLE_VALUE)
+        return -1;
+
+    size_t res = size;
+    int retval = 0;
+
+    while (res > 0) {
+        DWORD  written;
+        if (! ::WriteFile(m_pipe, (const char *)m_buf + (size - res), res, &written, NULL)) {
+            retval =  -1;
+            ERR("%s: failed: %d\n", __FUNCTION__, (int)GetLastError());
+            break;
+        }
+        res -= written;
+    }
+    return retval;
+}
+
+const unsigned char *Win32PipeStream::readFully(void *buf, size_t len)
+{
+    const unsigned char* ret = NULL;
+
+    if (m_pipe == INVALID_HANDLE_VALUE)
+        return NULL;
+
+    if (!buf) {
+        return NULL;  // do not allow NULL buf in that implementation
+    }
+
+    size_t res = len;
+    while (res > 0) {
+        DWORD  readcount = 0;
+        if (! ::ReadFile(m_pipe, (char *)buf + (len - res), res, &readcount, NULL) || readcount == 0) {
+            errno = (int)GetLastError();
+            return NULL;
+        }
+        res -= readcount;
+    }
+    return (const unsigned char *)buf;
+}
+
+const unsigned char *Win32PipeStream::read( void *buf, size_t *inout_len)
+{
+    size_t len = *inout_len;
+    DWORD  readcount;
+
+    if (m_pipe == INVALID_HANDLE_VALUE)
+        return NULL;
+
+    if (!buf) {
+        return NULL;  // do not allow NULL buf in that implementation
+    }
+
+    if (!::ReadFile(m_pipe, (char *)buf, len, &readcount, NULL)) {
+        errno = (int)GetLastError();
+        return NULL;
+    }
+
+    *inout_len = (size_t)readcount;
+    return (const unsigned char *)buf;
+}
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.h b/tools/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.h
new file mode 100644
index 0000000..4114545
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.h
@@ -0,0 +1,41 @@
+/*
+* 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 __WIN32_PIPE_STREAM_H
+#define __WIN32_PIPE_STREAM_H
+
+#include "SocketStream.h"
+#include <windows.h>
+
+class Win32PipeStream : public SocketStream {
+public:
+    explicit Win32PipeStream(size_t bufsize = 10000);
+    virtual ~Win32PipeStream();
+    virtual int listen(unsigned short port);
+    virtual SocketStream *accept();
+    virtual int connect(unsigned short port);
+
+    virtual int commitBuffer(size_t size);
+    virtual const unsigned char *readFully(void *buf, size_t len);
+    virtual const unsigned char *read(void *buf, size_t *inout_len);
+
+private:
+    Win32PipeStream(HANDLE pipe, size_t bufSize);
+    HANDLE  m_pipe;
+    int     m_port;
+};
+
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h b/tools/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h
new file mode 100644
index 0000000..f19f514
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h
@@ -0,0 +1,23 @@
+/*
+* 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
+
+#define CODEC_MAX_VERTEX_ATTRIBUTES 64
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp
new file mode 100644
index 0000000..4b7fc89
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp
@@ -0,0 +1,471 @@
+/*
+* 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"
+#include <IOStream.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:
+    case GL_HALF_FLOAT_OES:
+        retval = 2;
+        break;
+    case GL_INT:
+    case GL_FLOAT:
+    case GL_FIXED:
+    case GL_BOOL:
+        retval =  4;
+        break;
+#ifdef GL_DOUBLE
+    case GL_DOUBLE:
+        retval = 8;
+        break;
+#endif
+    case GL_FLOAT_VEC2:
+    case GL_INT_VEC2:
+    case GL_BOOL_VEC2:
+        retval = 8;
+        break;
+    case GL_INT_VEC3:
+    case GL_BOOL_VEC3:
+    case GL_FLOAT_VEC3:
+        retval = 12;
+        break;
+    case GL_FLOAT_VEC4:
+    case GL_BOOL_VEC4:
+    case GL_INT_VEC4:
+    case GL_FLOAT_MAT2:
+        retval = 16;
+        break;
+    case GL_FLOAT_MAT3:
+        retval = 36;
+        break;
+    case GL_FLOAT_MAT4:
+        retval = 64;
+        break;
+    case GL_SAMPLER_2D:
+    case GL_SAMPLER_CUBE:
+        retval = 4;
+        break;
+    default:
+        ERR("**** ERROR unknown type 0x%x (%s,%d)\n", type, __FUNCTION__,__LINE__);
+    }
+    return retval;
+
+}
+
+size_t glUtilsParamSize(GLenum param)
+{
+    size_t s = 0;
+
+    switch(param)
+    {
+    case GL_DEPTH_TEST:
+    case GL_DEPTH_FUNC:
+    case GL_DEPTH_BITS:
+    case GL_MAX_CLIP_PLANES:
+    case GL_GREEN_BITS:
+    case GL_MAX_MODELVIEW_STACK_DEPTH:
+    case GL_MAX_PROJECTION_STACK_DEPTH:
+    case GL_MAX_TEXTURE_STACK_DEPTH:
+    case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+    case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+    case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
+    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_ALPHA_TEST:
+    case GL_BLEND_DST:
+    case GL_BLEND_SRC:
+    case GL_BLEND:
+    case GL_LOGIC_OP_MODE:
+    case GL_SCISSOR_TEST:
+    case GL_MAX_TEXTURE_UNITS:
+    case GL_ACTIVE_TEXTURE:
+    case GL_ALPHA_BITS:
+    case GL_ARRAY_BUFFER_BINDING:
+    case GL_BLUE_BITS:
+    case GL_CLIENT_ACTIVE_TEXTURE:
+    case GL_CLIP_PLANE0:
+    case GL_CLIP_PLANE1:
+    case GL_CLIP_PLANE2:
+    case GL_CLIP_PLANE3:
+    case GL_CLIP_PLANE4:
+    case GL_CLIP_PLANE5:
+    case GL_COLOR_ARRAY:
+    case GL_COLOR_ARRAY_BUFFER_BINDING:
+    case GL_COLOR_ARRAY_SIZE:
+    case GL_COLOR_ARRAY_STRIDE:
+    case GL_COLOR_ARRAY_TYPE:
+    case GL_COLOR_LOGIC_OP:
+    case GL_COLOR_MATERIAL:
+    case GL_PACK_ALIGNMENT:
+    case GL_PERSPECTIVE_CORRECTION_HINT:
+    case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
+    case GL_POINT_SIZE_ARRAY_STRIDE_OES:
+    case GL_POINT_SIZE_ARRAY_TYPE_OES:
+    case GL_POINT_SMOOTH:
+    case GL_POINT_SMOOTH_HINT:
+    case GL_POINT_SPRITE_OES:
+    case GL_COORD_REPLACE_OES:
+    case GL_COMBINE_ALPHA:
+    case GL_SRC0_RGB:
+    case GL_SRC1_RGB:
+    case GL_SRC2_RGB:
+    case GL_OPERAND0_RGB:
+    case GL_OPERAND1_RGB:
+    case GL_OPERAND2_RGB:
+    case GL_SRC0_ALPHA:
+    case GL_SRC1_ALPHA:
+    case GL_SRC2_ALPHA:
+    case GL_OPERAND0_ALPHA:
+    case GL_OPERAND1_ALPHA:
+    case GL_OPERAND2_ALPHA:
+    case GL_RGB_SCALE:
+    case GL_ALPHA_SCALE:
+    case GL_COMBINE_RGB:
+    case GL_POLYGON_OFFSET_FACTOR:
+    case GL_POLYGON_OFFSET_FILL:
+    case GL_POLYGON_OFFSET_UNITS:
+    case GL_RED_BITS:
+    case GL_RESCALE_NORMAL:
+    case GL_SAMPLE_ALPHA_TO_COVERAGE:
+    case GL_SAMPLE_ALPHA_TO_ONE:
+    case GL_SAMPLE_BUFFERS:
+    case GL_SAMPLE_COVERAGE:
+    case GL_SAMPLE_COVERAGE_INVERT:
+    case GL_SAMPLE_COVERAGE_VALUE:
+    case GL_SAMPLES:
+    case GL_STENCIL_BITS:
+    case GL_STENCIL_CLEAR_VALUE:
+    case GL_STENCIL_FUNC:
+    case GL_STENCIL_TEST:
+    case GL_STENCIL_VALUE_MASK:
+    case GL_STENCIL_BACK_FUNC:
+    case GL_STENCIL_BACK_VALUE_MASK:
+    case GL_STENCIL_BACK_REF:
+    case GL_STENCIL_BACK_FAIL:
+    case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
+    case GL_STENCIL_BACK_PASS_DEPTH_PASS:
+    case GL_STENCIL_BACK_WRITEMASK:
+    case GL_TEXTURE_2D:
+    case GL_TEXTURE_BINDING_2D:
+    case GL_TEXTURE_BINDING_CUBE_MAP:
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
+    case GL_TEXTURE_COORD_ARRAY:
+    case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
+    case GL_TEXTURE_COORD_ARRAY_SIZE:
+    case GL_TEXTURE_COORD_ARRAY_STRIDE:
+    case GL_TEXTURE_COORD_ARRAY_TYPE:
+    case GL_UNPACK_ALIGNMENT:
+    case GL_VERTEX_ARRAY:
+    case GL_VERTEX_ARRAY_BUFFER_BINDING:
+    case GL_VERTEX_ARRAY_SIZE:
+    case GL_VERTEX_ARRAY_STRIDE:
+    case GL_VERTEX_ARRAY_TYPE:
+    case GL_SPOT_CUTOFF:
+    case GL_TEXTURE_MIN_FILTER:
+    case GL_TEXTURE_MAG_FILTER:
+    case GL_TEXTURE_WRAP_S:
+    case GL_TEXTURE_WRAP_T:
+    case GL_GENERATE_MIPMAP:
+    case GL_GENERATE_MIPMAP_HINT:
+    case GL_RENDERBUFFER_WIDTH_OES:
+    case GL_RENDERBUFFER_HEIGHT_OES:
+    case GL_RENDERBUFFER_INTERNAL_FORMAT_OES:
+    case GL_RENDERBUFFER_RED_SIZE_OES:
+    case GL_RENDERBUFFER_GREEN_SIZE_OES:
+    case GL_RENDERBUFFER_BLUE_SIZE_OES:
+    case GL_RENDERBUFFER_ALPHA_SIZE_OES:
+    case GL_RENDERBUFFER_DEPTH_SIZE_OES:
+    case GL_RENDERBUFFER_STENCIL_SIZE_OES:
+    case GL_RENDERBUFFER_BINDING:
+    case GL_FRAMEBUFFER_BINDING:
+    case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES:
+    case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES:
+    case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES:
+    case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES:
+    case GL_FENCE_STATUS_NV:
+    case GL_FENCE_CONDITION_NV:
+    case GL_TEXTURE_WIDTH_QCOM:
+    case GL_TEXTURE_HEIGHT_QCOM:
+    case GL_TEXTURE_DEPTH_QCOM:
+    case GL_TEXTURE_INTERNAL_FORMAT_QCOM:
+    case GL_TEXTURE_FORMAT_QCOM:
+    case GL_TEXTURE_TYPE_QCOM:
+    case GL_TEXTURE_IMAGE_VALID_QCOM:
+    case GL_TEXTURE_NUM_LEVELS_QCOM:
+    case GL_TEXTURE_TARGET_QCOM:
+    case GL_TEXTURE_OBJECT_VALID_QCOM:
+    case GL_BLEND_EQUATION_RGB_OES:
+    case GL_BLEND_EQUATION_ALPHA_OES:
+    case GL_BLEND_DST_RGB_OES:
+    case GL_BLEND_SRC_RGB_OES:
+    case GL_BLEND_DST_ALPHA_OES:
+    case GL_BLEND_SRC_ALPHA_OES:
+    case GL_MAX_LIGHTS:
+    case GL_SHADER_TYPE:
+    case GL_DELETE_STATUS:
+    case GL_COMPILE_STATUS:
+    case GL_INFO_LOG_LENGTH:
+    case GL_SHADER_SOURCE_LENGTH:
+    case GL_CURRENT_PROGRAM:
+    case GL_LINK_STATUS:
+    case GL_VALIDATE_STATUS:
+    case GL_ATTACHED_SHADERS:
+    case GL_ACTIVE_UNIFORMS:
+    case GL_ACTIVE_ATTRIBUTES:
+    case GL_SUBPIXEL_BITS:
+    case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
+    case GL_NUM_SHADER_BINARY_FORMATS:
+    case GL_SHADER_COMPILER:
+    case GL_MAX_VERTEX_ATTRIBS:
+    case GL_MAX_VERTEX_UNIFORM_VECTORS:
+    case GL_MAX_VARYING_VECTORS:
+    case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
+    case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
+    case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
+    case GL_MAX_RENDERBUFFER_SIZE:
+    case GL_MAX_TEXTURE_IMAGE_UNITS:
+    case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
+    case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
+    case GL_LINE_WIDTH:
+        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_VERTEX_ATTRIB:
+    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:
+    case GL_COLOR_CLEAR_VALUE:
+    case GL_COLOR_WRITEMASK:
+    case GL_AMBIENT_AND_DIFFUSE:
+    case GL_BLEND_COLOR:
+        s =  4;
+        break;
+    case GL_MODELVIEW_MATRIX:
+    case GL_PROJECTION_MATRIX:
+    case GL_TEXTURE_MATRIX:
+        s = 16;
+    break;
+    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;
+        }
+    }
+}
+
+void glUtilsWritePackPointerData(void* _stream, unsigned char *src,
+                                 int size, GLenum type, unsigned int stride,
+                                 unsigned int datalen)
+{
+    IOStream* stream = reinterpret_cast<IOStream*>(_stream);
+
+    unsigned int  vsize = size * glSizeof(type);
+    if (stride == 0) stride = vsize;
+
+    if (stride == vsize) {
+        stream->writeFully(src, datalen);
+    } else {
+        for (unsigned int i = 0; i < datalen; i += vsize) {
+            stream->writeFully(src, (size_t)vsize);
+            src += stride;
+        }
+    }
+}
+
+int glUtilsPixelBitSize(GLenum format, GLenum type)
+{
+    int components = 0;
+    int componentsize = 0;
+    int pixelsize = 0;
+    switch(type) {
+    case GL_BYTE:
+    case GL_UNSIGNED_BYTE:
+        componentsize = 8;
+        break;
+    case GL_SHORT:
+    case GL_UNSIGNED_SHORT:
+    case GL_UNSIGNED_SHORT_5_6_5:
+    case GL_UNSIGNED_SHORT_4_4_4_4:
+    case GL_UNSIGNED_SHORT_5_5_5_1:
+    case GL_RGB565_OES:
+    case GL_RGB5_A1_OES:
+    case GL_RGBA4_OES:
+        pixelsize = 16;
+        break;
+    case GL_INT:
+    case GL_UNSIGNED_INT:
+    case GL_FLOAT:
+    case GL_FIXED:
+    case GL_UNSIGNED_INT_24_8_OES:
+        pixelsize = 32;
+        break;
+    default:
+        ERR("glUtilsPixelBitSize: 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:
+        case GL_DEPTH_COMPONENT:
+        case GL_DEPTH_STENCIL_OES:
+            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:
+        case GL_BGRA_EXT:
+            components = 4;
+            break;
+        default:
+            ERR("glUtilsPixelBitSize: unknown pixel format...\n");
+            components = 0;
+        }
+        pixelsize = components * componentsize;
+    }
+
+    return pixelsize;
+}
+
+// pack a list of strings into one.
+void glUtilsPackStrings(char *ptr,  char **strings,  GLint *length, GLsizei count)
+{
+    char *p = ptr;
+    *p = '\0';
+    for (int i = 0; i < count; i++) {
+        int l=0;
+        if (strings[i]!=NULL) {
+            if (length == NULL || length[i] < 0) {
+                l = strlen(strings[i]);
+                strcat(p, strings[i]);
+            } else {
+                l = length[i];
+                strncat(p, strings[i], l);
+            }
+        }
+        p += l;
+    }
+}
+
+// claculate the length of a list of strings
+int glUtilsCalcShaderSourceLen( char **strings,  GLint *length, GLsizei count)
+{
+    int len = 0;
+    for (int i = 0; i < count; i++) {
+        int l;
+        if (length == NULL || length[i] < 0) {
+            l = strings[i]!=NULL ? strlen(strings[i]) : 0;
+        } else {
+            l = length[i];
+        }
+        len += l;
+    }
+    return len;
+
+}
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.h b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.h
new file mode 100644
index 0000000..f8857f1
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.h
@@ -0,0 +1,95 @@
+/*
+* 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>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.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);
+    void glUtilsWritePackPointerData(void* stream, unsigned char *src,
+                                    int size, GLenum type, unsigned int stride,
+                                    unsigned int datalen);
+    int glUtilsPixelBitSize(GLenum format, GLenum type);
+    void   glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei count);
+    int glUtilsCalcShaderSourceLen(char **strings, GLint *length, GLsizei count);
+#ifdef __cplusplus
+};
+#endif
+
+namespace GLUtils {
+
+    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++;
+        }
+    }
+}; // namespace GLUtils
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/gl_base_types.h b/tools/emulator/opengl/shared/OpenglCodecCommon/gl_base_types.h
new file mode 100644
index 0000000..d7bdef8
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/gl_base_types.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_BASE_TYPES__H
+#define __GL_BASE_TYPES__H
+
+#include <KHR/khrplatform.h>
+
+#ifndef gl_APIENTRY
+#define gl_APIENTRY KHRONOS_APIENTRY
+#endif
+
+#ifndef gl2_APIENTRY
+#define gl2_APIENTRY KHRONOS_APIENTRY
+#endif
+
+typedef void             GLvoid;
+typedef unsigned int     GLenum;
+typedef unsigned char    GLboolean;
+typedef unsigned int     GLbitfield;
+typedef char             GLchar;
+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;
+typedef char *GLstr;
+/* JR XXX Treating this as an in handle - is this correct? */
+typedef void * GLeglImageOES;
+
+/* ErrorCode */
+#ifndef GL_INVALID_ENUM
+#define GL_NO_ERROR                       0
+#define GL_INVALID_ENUM                   0x0500
+#define GL_INVALID_VALUE                  0x0501
+#define GL_INVALID_OPERATION              0x0502
+#define GL_STACK_OVERFLOW                 0x0503
+#define GL_STACK_UNDERFLOW                0x0504
+#define GL_OUT_OF_MEMORY                  0x0505
+#endif
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/Android.mk b/tools/emulator/opengl/shared/OpenglOsUtils/Android.mk
new file mode 100644
index 0000000..e7fd9e9
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/Android.mk
@@ -0,0 +1,20 @@
+# This build script corresponds to a small library containing
+# OS-specific support functions for:
+#   - thread-local storage
+#   - dynamic library loading
+#   - child process creation and wait  (probably not needed in guest)
+#
+LOCAL_PATH := $(call my-dir)
+
+### Guest library ##############################################
+$(call emugl-begin-static-library,libOpenglOsUtils)
+
+    $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+    $(call emugl-export,LDLIBS,-ldl)
+
+    LOCAL_SRC_FILES := \
+        osProcessUnix.cpp \
+        osThreadUnix.cpp \
+        osDynLibrary.cpp
+
+$(call emugl-end-module)
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/osDynLibrary.cpp b/tools/emulator/opengl/shared/OpenglOsUtils/osDynLibrary.cpp
new file mode 100644
index 0000000..e8e6ab7
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/osDynLibrary.cpp
@@ -0,0 +1,79 @@
+/*
+* 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 "osDynLibrary.h"
+
+#ifndef _WIN32
+#include <dlfcn.h>
+#endif
+#include <stdio.h>
+
+namespace osUtils {
+
+dynLibrary *dynLibrary::open(const char *p_libName)
+{
+    dynLibrary *lib = new dynLibrary();
+    if (!lib) {
+        return NULL;
+    }
+
+#ifdef _WIN32
+    lib->m_lib = LoadLibrary(p_libName);
+#else // !WIN32
+    lib->m_lib = dlopen(p_libName, RTLD_NOW);
+#endif
+
+    if (lib->m_lib == NULL) {
+        printf("Failed to load %s\n", p_libName);
+#ifndef _WIN32
+        printf("error %s\n", dlerror()); //only on linux
+#endif
+        delete lib;
+        return NULL;
+    }
+
+    return lib;
+}
+
+dynLibrary::dynLibrary() :
+    m_lib(NULL)
+{
+}
+
+dynLibrary::~dynLibrary()
+{
+    if (NULL != m_lib) {
+#ifdef _WIN32
+        FreeLibrary(m_lib);
+#else // !WIN32
+        dlclose(m_lib);
+#endif
+    }
+}
+
+dynFuncPtr dynLibrary::findSymbol(const char *p_symName)
+{
+    if (NULL == m_lib) {
+        return NULL;
+    }
+
+#ifdef _WIN32
+    return (dynFuncPtr) GetProcAddress(m_lib, p_symName);
+#else // !WIN32
+    return (dynFuncPtr) dlsym(m_lib, p_symName);
+#endif
+}
+
+} // of namespace osUtils
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/osDynLibrary.h b/tools/emulator/opengl/shared/OpenglOsUtils/osDynLibrary.h
new file mode 100644
index 0000000..c83fbf3
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/osDynLibrary.h
@@ -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.
+*/
+#ifndef _OSUTILS_DYN_LIBRARY_H
+#define _OSUTILS_DYN_LIBRARY_H
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+namespace osUtils {
+
+typedef void (*dynFuncPtr)(void);
+
+class dynLibrary
+{
+public:
+    static dynLibrary *open(const char *p_libName);
+    ~dynLibrary();
+
+    dynFuncPtr findSymbol(const char *p_symName);
+
+private:
+    dynLibrary();
+
+private:
+#ifdef _WIN32
+    HMODULE m_lib;
+#else
+    void *m_lib;
+#endif
+};
+
+} // of namespace osUtils
+
+
+
+// Macro to compose emugl shared library name under various OS and bitness
+// eg.
+//     on x86_64, EMUGL_LIBNAME("foo") --> "lib64foo.so"
+
+#ifdef _WIN32
+#  define DLL_EXTENSION  "" // _WIN32 LoadLibrary only accept name w/o .dll extension
+#elif defined(__APPLE__)
+#  define DLL_EXTENSION  ".dylib"
+#else
+#  define DLL_EXTENSION  ".so"
+#endif
+
+#if defined(__x86_64__)
+#  define EMUGL_LIBNAME(name) "lib64" name DLL_EXTENSION
+#elif defined(__i386__)
+#  define EMUGL_LIBNAME(name) "lib" name DLL_EXTENSION
+#else
+/* This header is included by target w/o using EMUGL_LIBNAME().  Don't #error, leave it undefined */
+#endif
+
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/osProcess.h b/tools/emulator/opengl/shared/OpenglOsUtils/osProcess.h
new file mode 100644
index 0000000..82b31b3
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/osProcess.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 _OSUTILS_PROCESS_H
+#define _OSUTILS_PROCESS_H
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+namespace osUtils {
+
+class childProcess
+{
+public:
+    static childProcess *create(const char *p_cmdLine, const char *p_startdir);
+    ~childProcess();
+
+    int getPID()
+    {
+#ifdef _WIN32
+        return m_proc.dwProcessId;
+#else
+        return(m_pid);
+#endif
+    }
+
+    int tryWait(bool& isAlive);
+    bool wait(int *exitStatus);
+
+private:
+    childProcess() {};
+
+private:
+#ifdef _WIN32
+    PROCESS_INFORMATION m_proc;
+#else
+    int m_pid;
+#endif
+};
+
+int ProcessGetPID();
+int ProcessGetTID();
+bool ProcessGetName(char *p_outName, int p_outNameLen);
+int KillProcess(int pid, bool wait);
+bool isProcessRunning(int pid);
+
+} // of namespace osUtils
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/osProcessUnix.cpp b/tools/emulator/opengl/shared/OpenglOsUtils/osProcessUnix.cpp
new file mode 100644
index 0000000..c97ff58
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/osProcessUnix.cpp
@@ -0,0 +1,210 @@
+/*
+* 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 "osProcess.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <poll.h>
+#include <pthread.h>
+#include <string.h>
+#include <pwd.h>
+#include <paths.h>
+#include <errno.h>
+#include <signal.h>
+#include <unistd.h>
+#include <assert.h>
+
+namespace osUtils {
+
+//
+// buildArgList converts a command line into null terminated argument list.
+// to be used with execv or execvp.
+// each argument is seperated by space or tab, to specify multiple words
+// at the same argument place it inside single-quoted or double-quoted string.
+//
+static char **buildArgList(const char *command)
+{
+    char **argv = NULL;
+    int argvSize = 0;
+    int nArgs = 0;
+    char *tmpcmd = strdup(command);
+    char *t = tmpcmd;
+    char *strStart = NULL;
+    int i = 0;
+
+    #define ADD_ARG \
+        { \
+            nArgs++; \
+            if (!argv) { \
+                argvSize = 12; \
+                argv = (char **)malloc(argvSize * sizeof(char *)); \
+            } \
+            else if (nArgs > argvSize) { \
+                argvSize += 12; \
+                argv = (char **)realloc(argv, argvSize * sizeof(char *)); \
+            } \
+            argv[nArgs-1] = t; \
+            t = NULL; \
+        }
+
+    while( tmpcmd[i] != '\0' ) {
+        if (!strStart) {
+            if (tmpcmd[i] == '"' || tmpcmd[i] == '\'') {
+                strStart = &tmpcmd[i];
+            }
+            else if (tmpcmd[i] == ' ' || tmpcmd[i] == '\t') {
+                tmpcmd[i] = '\0';
+                if (t) ADD_ARG;
+            }
+            else if (!t) {
+                t = &tmpcmd[i];
+            }
+        }
+        else if (tmpcmd[i] == *strStart) {
+            t = strStart;
+            strStart = NULL;
+        }
+
+        i++;
+    }
+    if (t) {
+        ADD_ARG;
+    }
+    if (nArgs > 0) {
+        ADD_ARG; // for NULL terminating list
+    }
+
+    return argv;
+}
+
+static pid_t start_process(const char *command,const char *startDir)
+{
+    pid_t pid;
+
+    pid = fork();
+
+    if (pid < 0) {
+        return pid;
+    }
+    else if (pid == 0) {
+        //
+        // Close all opened file descriptors
+        //
+        for (int i=3; i<256; i++) {
+            close(i);
+        }
+
+        if (startDir) {
+            chdir(startDir);
+        }
+
+        char **argv = buildArgList(command);
+        if (!argv) {
+            return -1;
+        }
+        execvp(argv[0], argv);
+
+        perror("execl");
+        exit(-101);
+    }
+
+    return pid;
+}
+
+childProcess *
+childProcess::create(const char *p_cmdLine, const char *p_startdir)
+{
+    childProcess *child = new childProcess();
+    if (!child) {
+        return NULL;
+    }
+
+    child->m_pid = start_process(p_cmdLine, p_startdir);
+    if (child->m_pid < 0) {
+        delete child;
+        return NULL;
+    }
+
+    return child;
+}
+
+childProcess::~childProcess()
+{
+}
+
+bool
+childProcess::wait(int *exitStatus)
+{
+    int ret=0;
+    if (m_pid>0) {
+        pid_t pid = waitpid(m_pid,&ret,0);
+        if (pid != -1) {
+            m_pid=-1;
+            if (exitStatus) {
+                *exitStatus = ret;
+            }
+            return true;
+        }
+    }
+    return false;
+}
+
+int
+childProcess::tryWait(bool &isAlive)
+{
+    int ret=0;
+    isAlive = false;
+    if (m_pid>0) {
+        pid_t pid = waitpid(m_pid,&ret,WNOHANG);
+        if (pid == 0) {
+            isAlive = true;
+        }
+    }
+
+    return ((char)WEXITSTATUS(ret));
+}
+
+int ProcessGetPID()
+{
+    return getpid();
+}
+
+int KillProcess(int pid, bool wait)
+{
+    if (pid<1) {
+        return false;
+    }
+
+    if (0!=kill(pid,SIGTERM)) {
+        return false;
+    }
+
+    if (wait) {
+        if (waitpid(pid,NULL,0)<0) {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool isProcessRunning(int pid)
+{
+    return (kill(pid,0) == 0);
+}
+
+} // of namespace osUtils
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/osProcessWin.cpp b/tools/emulator/opengl/shared/OpenglOsUtils/osProcessWin.cpp
new file mode 100644
index 0000000..6ff0fdf
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/osProcessWin.cpp
@@ -0,0 +1,171 @@
+/*
+* 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 "osProcess.h"
+#include <windows.h>
+#include <string>
+#include <stdlib.h>
+#include <psapi.h>
+
+namespace osUtils {
+
+childProcess *
+childProcess::create(const char *p_cmdLine, const char *p_startdir)
+{
+    childProcess *child = new childProcess();
+    if (!child) {
+        return NULL;
+    }
+
+    STARTUPINFOA        si;
+    ZeroMemory(&si, sizeof(si));
+
+    ZeroMemory(&child->m_proc, sizeof(child->m_proc));
+    BOOL ret = CreateProcessA(
+                    NULL ,
+                    (LPSTR)p_cmdLine,
+                    NULL,
+                    NULL,
+                    FALSE,
+                    CREATE_DEFAULT_ERROR_MODE,
+                    NULL,
+                    (p_startdir != NULL ? p_startdir : ".\\"),
+                    &si,
+                    &child->m_proc);
+    if (ret == 0) {
+        delete child;
+        return NULL;
+    }
+
+    // close the thread handle we do not need it,
+    // keep the process handle for wait/trywait operations, will
+    // be closed on destruction
+    CloseHandle(child->m_proc.hThread);
+
+    return child;
+}
+
+childProcess::~childProcess()
+{
+    if (m_proc.hProcess) {
+        CloseHandle(m_proc.hProcess);
+    }
+}
+
+bool
+childProcess::wait(int *exitStatus)
+{
+DWORD _exitStatus;
+
+    if (WaitForSingleObject(m_proc.hProcess, INFINITE) == WAIT_FAILED) {
+        return false;
+    }
+
+    if (!GetExitCodeProcess(m_proc.hProcess, &_exitStatus))
+    {
+        return false;
+    }
+
+    if (exitStatus) {
+        *exitStatus = _exitStatus;
+    }
+
+    return true;
+}
+
+int
+childProcess::tryWait(bool& isAlive)
+{
+    DWORD status = WaitForSingleObject(m_proc.hProcess, 0);
+
+    if(status == WAIT_OBJECT_0)
+    {
+        // process has exited
+        isAlive = false;
+        GetExitCodeProcess(m_proc.hProcess, &status);
+    }
+    else if (status == WAIT_TIMEOUT)
+    {
+        isAlive = true;
+        status = 0;
+    }
+
+    return status;
+
+}
+
+int ProcessGetPID()
+{
+    return GetCurrentProcessId();
+}
+
+int ProcessGetTID()
+{
+    return GetCurrentThreadId();
+}
+
+bool ProcessGetName(char *p_outName, int p_outNameLen)
+{
+    return 0 != GetModuleFileNameEx( GetCurrentProcess(), NULL, p_outName, p_outNameLen);
+}
+
+int KillProcess(int pid, bool wait)
+{
+    DWORD exitStatus = 1;
+    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
+
+    if (NULL == hProc) {
+        return 0;
+    }
+
+    //
+    // Terminate the process
+    //
+    TerminateProcess(hProc, 0x55);
+
+    if (wait) {
+        //
+        // Wait for it to be terminated
+        //
+        if(WaitForSingleObject(hProc, INFINITE) == WAIT_FAILED) {
+            CloseHandle(hProc);
+            return 0;
+        }
+
+        if (!GetExitCodeProcess(hProc, &exitStatus)) {
+            CloseHandle(hProc);
+            return 0;
+        }
+    }
+
+    CloseHandle(hProc);
+
+    return exitStatus;
+}
+
+bool isProcessRunning(int pid)
+{
+    bool isRunning = false;
+
+    HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
+    if (NULL != process) {
+        DWORD ret = WaitForSingleObject(process, 0);
+        CloseHandle(process);
+        isRunning = (ret == WAIT_TIMEOUT);
+    }
+    return isRunning;
+}
+
+} // of namespace osUtils
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/osThread.h b/tools/emulator/opengl/shared/OpenglOsUtils/osThread.h
new file mode 100644
index 0000000..970396d
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/osThread.h
@@ -0,0 +1,60 @@
+/*
+* 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 _OSUTILS_THREAD_H
+#define _OSUTILS_THREAD_H
+
+#ifdef _WIN32
+#include <windows.h>
+#else // !WIN32
+#include <pthread.h>
+#endif
+
+namespace osUtils {
+
+class Thread
+{
+public:
+    Thread();
+    virtual ~Thread();
+
+    virtual int Main() = 0;
+
+    bool start();
+    bool  wait(int *exitStatus);
+    bool trywait(int *exitStatus);
+
+private:
+#ifdef _WIN32
+    static DWORD WINAPI thread_main(void *p_arg);
+#else // !WIN32
+    static void* thread_main(void *p_arg);
+#endif
+
+private:
+#ifdef _WIN32
+    HANDLE m_thread;
+    DWORD m_threadId;
+#else // !WIN32
+    pthread_t m_thread;
+    int       m_exitStatus;
+    pthread_mutex_t m_lock;
+#endif
+    bool m_isRunning;
+};
+
+} // of namespace osUtils
+
+#endif
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp b/tools/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp
new file mode 100644
index 0000000..d8879eb
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp
@@ -0,0 +1,94 @@
+/*
+* 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 "osThread.h"
+
+namespace osUtils {
+
+Thread::Thread() :
+    m_thread((pthread_t)NULL),
+    m_exitStatus(0),
+    m_isRunning(false)
+{
+    pthread_mutex_init(&m_lock, NULL);
+}
+
+Thread::~Thread()
+{
+    pthread_mutex_destroy(&m_lock);
+}
+
+bool
+Thread::start()
+{
+    pthread_mutex_lock(&m_lock);
+    m_isRunning = true;
+    int ret = pthread_create(&m_thread, NULL, Thread::thread_main, this);
+    if(ret) {
+        m_isRunning = false;
+    }
+    pthread_mutex_unlock(&m_lock);
+    return m_isRunning;
+}
+
+bool
+Thread::wait(int *exitStatus)
+{
+    if (!m_isRunning) {
+        return false;
+    }
+
+    void *retval;
+    if (pthread_join(m_thread,&retval)) {
+        return false;
+    }
+
+    long long int ret=(long long int)retval;
+    if (exitStatus) {
+        *exitStatus = (int)ret;
+    }
+    return true;
+}
+
+bool
+Thread::trywait(int *exitStatus)
+{
+    bool ret = false;
+
+    pthread_mutex_lock(&m_lock);
+    if (!m_isRunning) {
+        *exitStatus = m_exitStatus;
+        ret = true;
+    }
+    pthread_mutex_unlock(&m_lock);
+    return ret;
+}
+
+void *
+Thread::thread_main(void *p_arg)
+{
+    Thread *self = (Thread *)p_arg;
+    int ret = self->Main();
+
+    pthread_mutex_lock(&self->m_lock);
+    self->m_isRunning = false;
+    self->m_exitStatus = ret;
+    pthread_mutex_unlock(&self->m_lock);
+
+    return (void*)ret;
+}
+
+} // of namespace osUtils
+
diff --git a/tools/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp b/tools/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp
new file mode 100644
index 0000000..2d563f8
--- /dev/null
+++ b/tools/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp
@@ -0,0 +1,101 @@
+/*
+* 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 "osThread.h"
+
+namespace osUtils {
+
+Thread::Thread() :
+    m_thread(NULL),
+    m_threadId(0),
+    m_isRunning(false)
+{
+}
+
+Thread::~Thread()
+{
+    if(m_thread) {
+        CloseHandle(m_thread);
+    }
+}
+
+bool
+Thread::start()
+{
+    m_isRunning = true;
+    m_thread = CreateThread(NULL, 0, &Thread::thread_main, this, 0, &m_threadId);
+    if(!m_thread) {
+        m_isRunning = false;
+    }
+    return m_isRunning;
+}
+
+bool
+Thread::wait(int *exitStatus)
+{
+    if (!m_isRunning) {
+        return false;
+    }
+
+    if(WaitForSingleObject(m_thread, INFINITE) == WAIT_FAILED) {
+        return false;
+    }
+
+    DWORD retval;
+    if (!GetExitCodeThread(m_thread,&retval)) {
+        return false;
+    }
+
+    m_isRunning = 0;
+
+    if (exitStatus) {
+        *exitStatus = retval;
+    }
+    return true;
+}
+
+bool
+Thread::trywait(int *exitStatus)
+{
+    if (!m_isRunning) {
+        return false;
+    }
+
+    if(WaitForSingleObject(m_thread, 0) == WAIT_OBJECT_0) {
+
+        DWORD retval;
+        if (!GetExitCodeThread(m_thread,&retval)) {
+            return true;
+        }
+
+        if (exitStatus) {
+            *exitStatus = retval;
+        }
+        return true;
+    }
+
+    return false;
+}
+
+DWORD WINAPI
+Thread::thread_main(void *p_arg)
+{
+    Thread *self = (Thread *)p_arg;
+    int ret = self->Main();
+    self->m_isRunning = false;
+    return ret;
+}
+
+} // of namespace osUtils
diff --git a/tools/emulator/opengl/system/GLESv1/Android.mk b/tools/emulator/opengl/system/GLESv1/Android.mk
new file mode 100644
index 0000000..97356b7
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+
+### GLESv1 implementation ###########################################
+$(call emugl-begin-shared-library,libGLESv1_CM_emulation)
+$(call emugl-import,libOpenglSystemCommon libGLESv1_enc lib_renderControl_enc)
+
+LOCAL_CFLAGS += -DLOG_TAG=\"GLES_emulation\" -DGL_GLEXT_PROTOTYPES
+
+LOCAL_SRC_FILES := gl.cpp
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
+
+$(call emugl-end-module)
diff --git a/tools/emulator/opengl/system/GLESv1/gl.cpp b/tools/emulator/opengl/system/GLESv1/gl.cpp
new file mode 100644
index 0000000..8ecb504
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1/gl.cpp
@@ -0,0 +1,146 @@
+/*
+* Copyright 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 "EGLClientIface.h"
+#include "HostConnection.h"
+#include "GLEncoder.h"
+#include "GLES/gl.h"
+#include "GLES/glext.h"
+#include "ErrorLog.h"
+#include "gralloc_cb.h"
+#include "ThreadInfo.h"
+
+
+//XXX: fix this macro to get the context from fast tls path
+#define GET_CONTEXT GLEncoder * ctx = getEGLThreadInfo()->hostConn->glEncoder();
+
+#include "gl_entry.cpp"
+
+//The functions table
+#include "gl_ftable.h"
+
+static EGLClient_eglInterface * s_egl = NULL;
+static EGLClient_glesInterface * s_gl = NULL;
+
+#define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \
+    HostConnection *hostCon = HostConnection::get(); \
+    if (!hostCon) { \
+        ALOGE("egl: Failed to get host connection\n"); \
+        return ret; \
+    } \
+    renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
+    if (!rcEnc) { \
+        ALOGE("egl: Failed to get renderControl encoder context\n"); \
+        return ret; \
+    }
+
+//GL extensions
+void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES image)
+{
+    DBG("glEGLImageTargetTexture2DOES v1 target=%#x image=%p", target, image);
+    //TODO: check error - we don't have a way to set gl error
+    android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+
+    if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
+        return;
+    }
+
+    if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+        return;
+    }
+
+    GET_CONTEXT;
+    DEFINE_AND_VALIDATE_HOST_CONNECTION();
+
+    ctx->override2DTextureTarget(target);
+    rcEnc->rcBindTexture(rcEnc,
+            ((cb_handle_t *)(native_buffer->handle))->hostHandle);
+    ctx->restore2DTextureTarget();
+
+    return;
+}
+
+void glEGLImageTargetRenderbufferStorageOES(void *self, GLenum target, GLeglImageOES image)
+{
+    DBG("glEGLImageTargetRenderbufferStorageOES v1 target=%#x image=%p",
+            target, image);
+    //TODO: check error - we don't have a way to set gl error
+    android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+
+    if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
+        return;
+    }
+
+    if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+        return;
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION();
+    rcEnc->rcBindRenderbuffer(rcEnc,
+            ((cb_handle_t *)(native_buffer->handle))->hostHandle);
+
+    return;
+}
+
+void * getProcAddress(const char * procname)
+{
+    // search in GL function table
+    for (int i=0; i<gl_num_funcs; i++) {
+        if (!strcmp(gl_funcs_by_name[i].name, procname)) {
+            return gl_funcs_by_name[i].proc;
+        }
+    }
+    return NULL;
+}
+
+void finish()
+{
+    glFinish();
+}
+
+const GLubyte *my_glGetString (void *self, GLenum name)
+{
+    if (s_egl) {
+        return (const GLubyte*)s_egl->getGLString(name);
+    }
+    return NULL;
+}
+
+void init()
+{
+    GET_CONTEXT;
+    ctx->set_glEGLImageTargetTexture2DOES(glEGLImageTargetTexture2DOES);
+    ctx->set_glEGLImageTargetRenderbufferStorageOES(glEGLImageTargetRenderbufferStorageOES);
+    ctx->set_glGetString(my_glGetString);
+}
+
+extern "C" {
+EGLClient_glesInterface * init_emul_gles(EGLClient_eglInterface *eglIface)
+{
+    s_egl = eglIface;
+
+    if (!s_gl) {
+        s_gl = new EGLClient_glesInterface();
+        s_gl->getProcAddress = getProcAddress;
+        s_gl->finish = finish;
+        s_gl->init = init;
+    }
+
+    return s_gl;
+}
+} //extern
+
+
diff --git a/tools/emulator/opengl/system/GLESv1_enc/Android.mk b/tools/emulator/opengl/system/GLESv1_enc/Android.mk
new file mode 100644
index 0000000..fd12395
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/Android.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+
+### GLESv1_enc Encoder ###########################################
+$(call emugl-begin-shared-library,libGLESv1_enc)
+
+LOCAL_CFLAGS += -DLOG_TAG=\"emuglGLESv1_enc\"
+
+LOCAL_SRC_FILES := \
+        GLEncoder.cpp \
+        GLEncoderUtils.cpp \
+        gl_client_context.cpp \
+        gl_enc.cpp \
+        gl_entry.cpp
+
+$(call emugl-import,libOpenglCodecCommon)
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+$(call emugl-export,C_INCLUDES,$(intermediates))
+
+$(call emugl-end-module)
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..4414f24
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.cpp
@@ -0,0 +1,989 @@
+/*
+* 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>
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+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;
+
+#define SET_ERROR_IF(condition,err) if((condition)) {                            \
+        ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+        ctx->setError(err);                                    \
+        return;                                                  \
+    }
+
+
+#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) {                \
+        ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+        ctx->setError(err);                                    \
+        return ret;                                              \
+    }
+
+GLenum GLEncoder::s_glGetError(void * self)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    GLenum err = ctx->getError();
+    if(err != GL_NO_ERROR) {
+        ctx->setError(GL_NO_ERROR);
+        return err;
+    }
+
+    return ctx->m_glGetError_enc(self);
+
+}
+
+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;
+    assert(ctx->m_state != NULL);
+    GLClientState* state = ctx->m_state;
+
+    switch (param) {
+    case 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));
+        }
+        break;
+    }
+
+    case GL_MAX_TEXTURE_UNITS:
+        ctx->m_glGetIntegerv_enc(self, param, ptr);
+        *ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS);
+        break;
+
+    case GL_TEXTURE_BINDING_2D:
+        *ptr = state->getBoundTexture(GL_TEXTURE_2D);
+        break;
+
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
+        *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES);
+        break;
+
+    default:
+        if (!state->getClientStateParameter<GLint>(param,ptr)) {
+            ctx->m_glGetIntegerv_enc(self, param, ptr);
+        }
+        break;
+    }
+}
+
+void GLEncoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    GLClientState* state = ctx->m_state;
+
+    switch (param) {
+    case 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];
+            }
+        }
+        break;
+    }
+
+    case GL_MAX_TEXTURE_UNITS:
+        ctx->m_glGetFloatv_enc(self, param, ptr);
+        *ptr = MIN(*ptr, (GLfloat)GLClientState::MAX_TEXTURE_UNITS);
+        break;
+
+    case GL_TEXTURE_BINDING_2D:
+        *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_2D);
+        break;
+
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
+        *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES);
+        break;
+
+    default:
+        if (!state->getClientStateParameter<GLfloat>(param,ptr)) {
+            ctx->m_glGetFloatv_enc(self, param, ptr);
+        }
+        break;
+    }
+}
+
+void GLEncoder::s_glGetFixedv(void *self, GLenum param, GLfixed *ptr)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    GLClientState* state = ctx->m_state;
+
+    switch (param) {
+    case 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;
+            }
+        }
+        break;
+    }
+
+    case GL_MAX_TEXTURE_UNITS:
+        ctx->m_glGetFixedv_enc(self, param, ptr);
+        *ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS << 16);
+        break;
+
+    case GL_TEXTURE_BINDING_2D:
+        *ptr = state->getBoundTexture(GL_TEXTURE_2D) << 16;
+        break;
+
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
+        *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES) << 16;
+        break;
+
+    default:
+        if (!state->getClientStateParameter<GLfixed>(param,ptr)) {
+            ctx->m_glGetFixedv_enc(self, param, ptr);
+        }
+        break;
+    }
+}
+
+void GLEncoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    GLClientState* state = ctx->m_state;
+
+    switch (param) {
+    case 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] != 0 ? GL_TRUE : GL_FALSE;
+            }
+        }
+        break;
+    }
+
+    case GL_TEXTURE_BINDING_2D:
+        *ptr = state->getBoundTexture(GL_TEXTURE_2D) != 0 ? GL_TRUE : GL_FALSE;
+        break;
+
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
+        *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES) != 0
+                ? GL_TRUE : GL_FALSE;
+        break;
+
+    default:
+        if (!state->getClientStateParameter<GLboolean>(param,ptr)) {
+            ctx->m_glGetBooleanv_enc(self, param, ptr);
+        }
+        break;
+    }
+}
+
+void GLEncoder::s_glGetPointerv(void * self, GLenum param, GLvoid **params)
+{
+    GLEncoder * ctx = (GLEncoder *) self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->getClientStatePointer(param,params);
+}
+
+void GLEncoder::s_glFlush(void *self)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    ctx->m_glFlush_enc(self);
+    ctx->m_stream->flush();
+}
+
+const 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);
+    ALOG_ASSERT(ctx->m_state, "GLEncoder::s_glPixelStorei");
+    ctx->m_state->setPixelStore(param, value);
+}
+
+void GLEncoder::s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, const void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->setState(GLClientState::VERTEX_LOCATION, size, type, false, stride, data);
+}
+
+void GLEncoder::s_glNormalPointer(void *self, GLenum type, GLsizei stride, const void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->setState(GLClientState::NORMAL_LOCATION, 3, type, false, stride, data);
+}
+
+void GLEncoder::s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, const void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->setState(GLClientState::COLOR_LOCATION, size, type, false, stride, data);
+}
+
+void GLEncoder::s_glPointsizePointer(void *self, GLenum type, GLsizei stride, const void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->setState(GLClientState::POINTSIZE_LOCATION, 1, type, false, stride, data);
+}
+
+void GLEncoder::s_glClientActiveTexture(void *self, GLenum texture)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->setActiveTexture(texture - GL_TEXTURE0);
+}
+
+void GLEncoder::s_glTexcoordPointer(void *self, int size, GLenum type, GLsizei stride, const void *data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    int loc = ctx->m_state->getLocation(GL_TEXTURE_COORD_ARRAY);
+    ctx->m_state->setState(loc, size, type, false, stride, data);
+}
+
+void GLEncoder::s_glMatrixIndexPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    int loc = ctx->m_state->getLocation(GL_MATRIX_INDEX_ARRAY_OES);
+    ctx->m_state->setState(loc, size, type, false, stride, data);
+}
+
+void GLEncoder::s_glWeightPointerOES(void * self, int size, GLenum type, GLsizei stride, const void * data)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    int loc = ctx->m_state->getLocation(GL_WEIGHT_ARRAY_OES);
+    ctx->m_state->setState(loc, size, type, false, stride, data);
+}
+
+void GLEncoder::s_glEnableClientState(void *self, GLenum state)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    assert(ctx->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(ctx->m_state != NULL);
+    int loc = ctx->m_state->getLocation(state);
+    ctx->m_state->enable(loc, 0);
+}
+
+GLboolean GLEncoder::s_glIsEnabled(void *self, GLenum cap)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    assert(ctx->m_state != NULL);
+    int loc = ctx->m_state->getLocation(cap);
+    const GLClientState::VertexAttribState *state = ctx->m_state->getState(loc);
+
+    if (state!=NULL)
+      return state->enabled;
+
+    return ctx->m_glIsEnabled_enc(self,cap);
+}
+
+void GLEncoder::s_glBindBuffer(void *self, GLenum target, GLuint id)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->bindBuffer(target, id);
+    // TODO set error state if needed;
+    ctx->m_glBindBuffer_enc(self, target, id);
+}
+
+void GLEncoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    GLuint bufferId = ctx->m_state->getBuffer(target);
+    SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION);
+    SET_ERROR_IF(size<0, GL_INVALID_VALUE);
+
+    ctx->m_shared->updateBufferData(bufferId, size, (void*)data);
+    ctx->m_glBufferData_enc(self, target, size, data, usage);
+}
+
+void GLEncoder::s_glBufferSubData(void * self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    GLuint bufferId = ctx->m_state->getBuffer(target);
+    SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION);
+
+    GLenum res = ctx->m_shared->subUpdateBufferData(bufferId, offset, size, (void*)data);
+    SET_ERROR_IF(res, res);
+
+    ctx->m_glBufferSubData_enc(self, target, offset, size, data);
+}
+
+void GLEncoder::s_glDeleteBuffers(void * self, GLsizei n, const GLuint * buffers)
+{
+    GLEncoder *ctx = (GLEncoder *) self;
+    SET_ERROR_IF(n<0, GL_INVALID_VALUE);
+    for (int i=0; i<n; i++) {
+        ctx->m_shared->deleteBufferData(buffers[i]);
+        ctx->m_glDeleteBuffers_enc(self,1,&buffers[i]);
+    }
+}
+
+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;
+                case GLClientState::WEIGHT_LOCATION:
+                    this->glWeightPointerData(this, state->size, state->type, state->stride,
+                                              (unsigned char * ) state->data + firstIndex, datalen);
+                    break;
+                case GLClientState::MATRIXINDEX_LOCATION:
+                    this->glMatrixIndexPointerData(this, state->size, state->type, state->stride,
+                                                  (unsigned char *)state->data + firstIndex, datalen);
+                    break;
+                }
+            } else {
+                this->m_glBindBuffer_enc(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;
+                case GLClientState::WEIGHT_LOCATION:
+                    this->glWeightPointerOffset(this,state->size,state->type,state->stride,
+                                                (GLuint)state->data+firstIndex);
+                    break;
+                case GLClientState::MATRIXINDEX_LOCATION:
+                    this->glMatrixIndexPointerOffset(this,state->size,state->type,state->stride,
+                                              (GLuint)state->data+firstIndex);
+                    break;
+                }                
+                this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo());
+            }
+        } 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, const void *indices)
+{
+
+    GLEncoder *ctx = (GLEncoder *)self;
+    assert(ctx->m_state != NULL);
+    SET_ERROR_IF(count<0, GL_INVALID_VALUE);
+
+    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) {
+        ALOGE("glDrawElements: no data bound to the command - ignoring\n");
+        return;
+    }
+
+    bool adjustIndices = true;
+    if (ctx->m_state->currentIndexVbo() != 0) {
+        if (!has_immediate_arrays) {
+            ctx->sendVertexData(0, count);
+            ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, ctx->m_state->currentIndexVbo());
+            ctx->glDrawElementsOffset(ctx, mode, count, type, (GLuint)indices);
+            adjustIndices = false;
+        } else {
+            BufferData * buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
+            ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, 0);
+            indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+        }
+    } 
+    if (adjustIndices) {
+        void *adjustedIndices = (void*)indices;
+        int minIndex = 0, maxIndex = 0;
+
+        switch(type) {
+        case GL_BYTE:
+        case GL_UNSIGNED_BYTE:
+            GLUtils::minmax<unsigned char>((unsigned char *)indices, count, &minIndex, &maxIndex);
+            if (minIndex != 0) {
+                adjustedIndices =  ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                GLUtils::shiftIndices<unsigned char>((unsigned char *)indices,
+                                                 (unsigned char *)adjustedIndices,
+                                                 count, -minIndex);
+            }
+            break;
+        case GL_SHORT:
+        case GL_UNSIGNED_SHORT:
+            GLUtils::minmax<unsigned short>((unsigned short *)indices, count, &minIndex, &maxIndex);
+            if (minIndex != 0) {
+                adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                GLUtils::shiftIndices<unsigned short>((unsigned short *)indices,
+                                                 (unsigned short *)adjustedIndices,
+                                                 count, -minIndex);
+            }
+            break;
+        default:
+            ALOGE("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) {
+                //ALOGD("unoptimized drawelements !!!\n");
+            }
+        } else {
+            // we are all direct arrays and immidate mode index array -
+            // rebuild the arrays and the index array;
+            ALOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n");
+        }
+    }
+}
+
+void GLEncoder::s_glActiveTexture(void* self, GLenum texture)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    GLClientState* state = ctx->m_state;
+    GLenum err;
+
+    if ((err = state->setActiveTextureUnit(texture)) != GL_NO_ERROR) {
+        ALOGE("%s:%s:%d GL error %#x\n", __FILE__, __FUNCTION__, __LINE__, err);
+        ctx->setError(err);
+        return;
+    }
+
+    ctx->m_glActiveTexture_enc(ctx, texture);
+}
+
+void GLEncoder::s_glBindTexture(void* self, GLenum target, GLuint texture)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    GLClientState* state = ctx->m_state;
+    GLenum err;
+
+    GLboolean firstUse;
+    if ((err = state->bindTexture(target, texture, &firstUse)) != GL_NO_ERROR) {
+        ALOGE("%s:%s:%d GL error %#x\n", __FILE__, __FUNCTION__, __LINE__, err);
+        ctx->setError(err);
+        return;
+    }
+
+    if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
+        ctx->m_glBindTexture_enc(ctx, target, texture);
+        return;
+    }
+
+    GLenum priorityTarget = state->getPriorityEnabledTarget(GL_TEXTURE_2D);
+
+    if (target == GL_TEXTURE_EXTERNAL_OES && firstUse) {
+        // set TEXTURE_EXTERNAL_OES default states which differ from TEXTURE_2D
+        ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture);
+        ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+                GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+                GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+                GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+        if (target != priorityTarget) {
+            ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D,
+                    state->getBoundTexture(GL_TEXTURE_2D));
+        }
+    }
+
+    if (target == priorityTarget) {
+        ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture);
+    }
+}
+
+void GLEncoder::s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    GLClientState* state = ctx->m_state;
+
+    state->deleteTextures(n, textures);
+    ctx->m_glDeleteTextures_enc(ctx, n, textures);
+}
+
+void GLEncoder::s_glDisable(void* self, GLenum cap)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    GLClientState* state = ctx->m_state;
+
+    if (cap == GL_TEXTURE_2D || cap == GL_TEXTURE_EXTERNAL_OES) {
+        GLenum prevTarget = state->getPriorityEnabledTarget(GL_INVALID_ENUM);
+        state->disableTextureTarget(cap);
+        GLenum currTarget = state->getPriorityEnabledTarget(GL_INVALID_ENUM);
+
+        if (prevTarget != currTarget) {
+            if (currTarget == GL_INVALID_ENUM) {
+                ctx->m_glDisable_enc(ctx, GL_TEXTURE_2D);
+                currTarget = GL_TEXTURE_2D;
+            }
+            // maintain the invariant that when TEXTURE_EXTERNAL_OES is
+            // disabled, the TEXTURE_2D binding is active, even if
+            // TEXTURE_2D is also disabled.
+            ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D,
+                    state->getBoundTexture(currTarget));
+        }
+
+    } else {
+        ctx->m_glDisable_enc(ctx, cap);
+    }
+}
+
+void GLEncoder::s_glEnable(void* self, GLenum cap)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    GLClientState* state = ctx->m_state;
+
+    if (cap == GL_TEXTURE_2D || cap == GL_TEXTURE_EXTERNAL_OES) {
+        GLenum prevTarget = state->getPriorityEnabledTarget(GL_INVALID_ENUM);
+        state->enableTextureTarget(cap);
+        GLenum currTarget = state->getPriorityEnabledTarget(GL_INVALID_ENUM);
+
+        if (prevTarget != currTarget) {
+            if (prevTarget == GL_INVALID_ENUM) {
+                ctx->m_glEnable_enc(ctx, GL_TEXTURE_2D);
+            }
+            if (currTarget == GL_TEXTURE_EXTERNAL_OES) {
+                ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D,
+                        state->getBoundTexture(currTarget));
+            }
+        }
+
+    } else {
+        ctx->m_glEnable_enc(ctx, cap);
+    }
+}
+
+void GLEncoder::s_glGetTexParameterfv(void* self,
+        GLenum target, GLenum pname, GLfloat* params)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glGetTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glGetTexParameterfv_enc(ctx, target, pname, params);
+    }
+}
+
+void GLEncoder::s_glGetTexParameteriv(void* self,
+        GLenum target, GLenum pname, GLint* params)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    switch (pname) {
+    case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
+        *params = 1;
+        break;
+
+    default:
+        if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+            ctx->override2DTextureTarget(target);
+            ctx->m_glGetTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params);
+            ctx->restore2DTextureTarget();
+        } else {
+            ctx->m_glGetTexParameteriv_enc(ctx, target, pname, params);
+        }
+        break;
+    }
+}
+
+void GLEncoder::s_glGetTexParameterxv(void* self,
+        GLenum target, GLenum pname, GLfixed* params)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glGetTexParameterxv_enc(ctx, GL_TEXTURE_2D, pname, params);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glGetTexParameterxv_enc(ctx, target, pname, params);
+    }
+}
+
+static bool isValidTextureExternalParam(GLenum pname, GLenum param)
+{
+    switch (pname) {
+    case GL_TEXTURE_MIN_FILTER:
+    case GL_TEXTURE_MAG_FILTER:
+        return param == GL_NEAREST || param == GL_LINEAR;
+
+    case GL_TEXTURE_WRAP_S:
+    case GL_TEXTURE_WRAP_T:
+        return param == GL_CLAMP_TO_EDGE;
+
+    case GL_GENERATE_MIPMAP:
+        return param == GL_FALSE;
+
+    default:
+        return true;
+    }
+}
+
+void GLEncoder::s_glTexParameterf(void* self,
+        GLenum target, GLenum pname, GLfloat param)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)param)),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameterf_enc(ctx, GL_TEXTURE_2D, pname, param);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameterf_enc(ctx, target, pname, param);
+    }
+}
+
+void GLEncoder::s_glTexParameterfv(void* self,
+        GLenum target, GLenum pname, const GLfloat* params)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)params[0])),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameterfv_enc(ctx, target, pname, params);
+    }
+}
+
+void GLEncoder::s_glTexParameteri(void* self,
+        GLenum target, GLenum pname, GLint param)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)param)),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, pname, param);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameteri_enc(ctx, target, pname, param);
+    }
+}
+
+void GLEncoder::s_glTexParameterx(void* self,
+        GLenum target, GLenum pname, GLfixed param)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)param)),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameterx_enc(ctx, GL_TEXTURE_2D, pname, param);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameterx_enc(ctx, target, pname, param);
+    }
+}
+
+void GLEncoder::s_glTexParameteriv(void* self,
+        GLenum target, GLenum pname, const GLint* params)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)params[0])),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameteriv_enc(ctx, target, pname, params);
+    }
+}
+
+void GLEncoder::s_glTexParameterxv(void* self,
+        GLenum target, GLenum pname, const GLfixed* params)
+{
+    GLEncoder* ctx = (GLEncoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)params[0])),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameterxv_enc(ctx, GL_TEXTURE_2D, pname, params);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameterxv_enc(ctx, target, pname, params);
+    }
+}
+
+void GLEncoder::override2DTextureTarget(GLenum target)
+{
+    if ((target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) &&
+        target != m_state->getPriorityEnabledTarget(GL_TEXTURE_2D)) {
+            m_glBindTexture_enc(this, GL_TEXTURE_2D,
+                    m_state->getBoundTexture(target));
+    }
+}
+
+void GLEncoder::restore2DTextureTarget()
+{
+    GLenum priorityTarget = m_state->getPriorityEnabledTarget(GL_TEXTURE_2D);
+    m_glBindTexture_enc(this, GL_TEXTURE_2D,
+            m_state->getBoundTexture(priorityTarget));
+}
+
+GLEncoder::GLEncoder(IOStream *stream) : gl_encoder_context_t(stream)
+{
+    m_initialized = false;
+    m_state = NULL;
+    m_error = GL_NO_ERROR;
+    m_num_compressedTextureFormats = 0;
+    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_glMatrixIndexPointerOES_enc = set_glMatrixIndexPointerOES(s_glMatrixIndexPointerOES);
+    m_glWeightPointerOES_enc = set_glWeightPointerOES(s_glWeightPointerOES);
+
+    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_glGetPointerv_enc = set_glGetPointerv(s_glGetPointerv);
+
+    m_glBindBuffer_enc = set_glBindBuffer(s_glBindBuffer);
+    m_glBufferData_enc = set_glBufferData(s_glBufferData);
+    m_glBufferSubData_enc = set_glBufferSubData(s_glBufferSubData);
+    m_glDeleteBuffers_enc = set_glDeleteBuffers(s_glDeleteBuffers);
+
+    m_glEnableClientState_enc = set_glEnableClientState(s_glEnableClientState);
+    m_glDisableClientState_enc = set_glDisableClientState(s_glDisableClientState);
+    m_glIsEnabled_enc = set_glIsEnabled(s_glIsEnabled);
+    m_glDrawArrays_enc = set_glDrawArrays(s_glDrawArrays);
+    m_glDrawElements_enc = set_glDrawElements(s_glDrawElements);
+    set_glGetString(s_glGetString);
+    set_glFinish(s_glFinish);
+    m_glGetError_enc = set_glGetError(s_glGetError);
+
+    m_glActiveTexture_enc = set_glActiveTexture(s_glActiveTexture);
+    m_glBindTexture_enc = set_glBindTexture(s_glBindTexture);
+    m_glDeleteTextures_enc = set_glDeleteTextures(s_glDeleteTextures);
+    m_glDisable_enc = set_glDisable(s_glDisable);
+    m_glEnable_enc = set_glEnable(s_glEnable);
+    m_glGetTexParameterfv_enc = set_glGetTexParameterfv(s_glGetTexParameterfv);
+    m_glGetTexParameteriv_enc = set_glGetTexParameteriv(s_glGetTexParameteriv);
+    m_glGetTexParameterxv_enc = set_glGetTexParameterxv(s_glGetTexParameterxv);
+    m_glTexParameterf_enc = set_glTexParameterf(s_glTexParameterf);
+    m_glTexParameterfv_enc = set_glTexParameterfv(s_glTexParameterfv);
+    m_glTexParameteri_enc = set_glTexParameteri(s_glTexParameteri);
+    m_glTexParameterx_enc = set_glTexParameterx(s_glTexParameterx);
+    m_glTexParameteriv_enc = set_glTexParameteriv(s_glTexParameteriv);
+    m_glTexParameterxv_enc = set_glTexParameterxv(s_glTexParameterxv);
+}
+
+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);
+}
+
+void GLEncoder::s_glFinish(void *self)
+{
+    GLEncoder *ctx = (GLEncoder *)self;
+    ctx->glFinishRoundTrip(self);
+}
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..effc53f
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/GLEncoder.h
@@ -0,0 +1,149 @@
+/*
+* 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 "GLSharedGroup.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 setSharedGroup(GLSharedGroupPtr shared) { m_shared = shared; }
+    void flush() { m_stream->flush(); }
+    size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack);
+
+    void setInitialized(){ m_initialized = true; };
+    bool isInitialized(){ return m_initialized; };
+
+    virtual void setError(GLenum error){ m_error = error; };
+    virtual GLenum getError() { return m_error; };
+
+    void override2DTextureTarget(GLenum target);
+    void restore2DTextureTarget();
+
+private:
+
+    bool    m_initialized;
+    GLClientState *m_state;
+    GLSharedGroupPtr m_shared;
+    GLenum  m_error;
+    FixedBuffer m_fixedBuffer;
+    GLint *m_compressedTextureFormats;
+    GLint m_num_compressedTextureFormats;
+
+    GLint *getCompressedTextureFormats();
+    // original functions;
+    glGetError_client_proc_t    m_glGetError_enc;
+    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;
+    glGetPointerv_client_proc_t m_glGetPointerv_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;
+    glMatrixIndexPointerOES_client_proc_t m_glMatrixIndexPointerOES_enc;
+    glWeightPointerOES_client_proc_t m_glWeightPointerOES_enc;
+
+    glBindBuffer_client_proc_t m_glBindBuffer_enc;
+    glBufferData_client_proc_t m_glBufferData_enc;
+    glBufferSubData_client_proc_t m_glBufferSubData_enc;
+    glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
+    
+    glEnableClientState_client_proc_t m_glEnableClientState_enc;
+    glDisableClientState_client_proc_t m_glDisableClientState_enc;
+    glIsEnabled_client_proc_t m_glIsEnabled_enc;
+    glDrawArrays_client_proc_t m_glDrawArrays_enc;
+    glDrawElements_client_proc_t m_glDrawElements_enc;
+    glFlush_client_proc_t m_glFlush_enc;
+
+    glActiveTexture_client_proc_t m_glActiveTexture_enc;
+    glBindTexture_client_proc_t m_glBindTexture_enc;
+    glDeleteTextures_client_proc_t m_glDeleteTextures_enc;
+    glDisable_client_proc_t m_glDisable_enc;
+    glEnable_client_proc_t m_glEnable_enc;
+    glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc;
+    glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc;
+    glGetTexParameterxv_client_proc_t m_glGetTexParameterxv_enc;
+    glTexParameterf_client_proc_t m_glTexParameterf_enc;
+    glTexParameterfv_client_proc_t m_glTexParameterfv_enc;
+    glTexParameteri_client_proc_t m_glTexParameteri_enc;
+    glTexParameterx_client_proc_t m_glTexParameterx_enc;
+    glTexParameteriv_client_proc_t m_glTexParameteriv_enc;
+    glTexParameterxv_client_proc_t m_glTexParameterxv_enc;
+
+    // statics
+    static GLenum s_glGetError(void * self);
+    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_glGetPointerv(void *self, GLenum pname, GLvoid **params);
+
+    static void s_glFlush(void * self);
+    static const GLubyte * s_glGetString(void *self, GLenum name);
+    static void s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
+    static void s_glNormalPointer(void *self, GLenum type, GLsizei stride, const void *data);
+    static void s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
+    static void s_glPointsizePointer(void *self, GLenum type, GLsizei stride, const void *data);
+    static void s_glClientActiveTexture(void *self, GLenum texture);
+    static void s_glTexcoordPointer(void *self, int size, GLenum type, GLsizei stride, const void *data);
+    static void s_glMatrixIndexPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data);
+    static void s_glWeightPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data);
+    static void s_glDisableClientState(void *self, GLenum state);
+    static void s_glEnableClientState(void *self, GLenum state);
+    static GLboolean s_glIsEnabled(void *self, GLenum cap);
+    static void s_glBindBuffer(void *self, GLenum target, GLuint id);
+    static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+    static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
+    static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
+
+    static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
+    static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
+    static void s_glPixelStorei(void *self, GLenum param, GLint value);
+
+    static void s_glFinish(void *self);
+    void sendVertexData(unsigned first, unsigned count);
+
+    static void s_glActiveTexture(void* self, GLenum texture);
+    static void s_glBindTexture(void* self, GLenum target, GLuint texture);
+    static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures);
+    static void s_glDisable(void* self, GLenum cap);
+    static void s_glEnable(void* self, GLenum cap);
+    static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params);
+    static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
+    static void s_glGetTexParameterxv(void* self, GLenum target, GLenum pname, GLfixed* params);
+    static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param);
+    static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params);
+    static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param);
+    static void s_glTexParameterx(void* self, GLenum target, GLenum pname, GLfixed param);
+    static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params);
+    static void s_glTexParameterxv(void* self, GLenum target, GLenum pname, const GLfixed* params);
+};
+#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_client_context.cpp b/tools/emulator/opengl/system/GLESv1_enc/gl_client_context.cpp
new file mode 100644
index 0000000..a5fd04b
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_client_context.cpp
@@ -0,0 +1,308 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "gl_client_context.h"
+
+
+#include <stdio.h>
+
+int gl_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+	void *ptr;
+
+	ptr = getProc("glAlphaFunc", userData); set_glAlphaFunc((glAlphaFunc_client_proc_t)ptr);
+	ptr = getProc("glClearColor", userData); set_glClearColor((glClearColor_client_proc_t)ptr);
+	ptr = getProc("glClearDepthf", userData); set_glClearDepthf((glClearDepthf_client_proc_t)ptr);
+	ptr = getProc("glClipPlanef", userData); set_glClipPlanef((glClipPlanef_client_proc_t)ptr);
+	ptr = getProc("glColor4f", userData); set_glColor4f((glColor4f_client_proc_t)ptr);
+	ptr = getProc("glDepthRangef", userData); set_glDepthRangef((glDepthRangef_client_proc_t)ptr);
+	ptr = getProc("glFogf", userData); set_glFogf((glFogf_client_proc_t)ptr);
+	ptr = getProc("glFogfv", userData); set_glFogfv((glFogfv_client_proc_t)ptr);
+	ptr = getProc("glFrustumf", userData); set_glFrustumf((glFrustumf_client_proc_t)ptr);
+	ptr = getProc("glGetClipPlanef", userData); set_glGetClipPlanef((glGetClipPlanef_client_proc_t)ptr);
+	ptr = getProc("glGetFloatv", userData); set_glGetFloatv((glGetFloatv_client_proc_t)ptr);
+	ptr = getProc("glGetLightfv", userData); set_glGetLightfv((glGetLightfv_client_proc_t)ptr);
+	ptr = getProc("glGetMaterialfv", userData); set_glGetMaterialfv((glGetMaterialfv_client_proc_t)ptr);
+	ptr = getProc("glGetTexEnvfv", userData); set_glGetTexEnvfv((glGetTexEnvfv_client_proc_t)ptr);
+	ptr = getProc("glGetTexParameterfv", userData); set_glGetTexParameterfv((glGetTexParameterfv_client_proc_t)ptr);
+	ptr = getProc("glLightModelf", userData); set_glLightModelf((glLightModelf_client_proc_t)ptr);
+	ptr = getProc("glLightModelfv", userData); set_glLightModelfv((glLightModelfv_client_proc_t)ptr);
+	ptr = getProc("glLightf", userData); set_glLightf((glLightf_client_proc_t)ptr);
+	ptr = getProc("glLightfv", userData); set_glLightfv((glLightfv_client_proc_t)ptr);
+	ptr = getProc("glLineWidth", userData); set_glLineWidth((glLineWidth_client_proc_t)ptr);
+	ptr = getProc("glLoadMatrixf", userData); set_glLoadMatrixf((glLoadMatrixf_client_proc_t)ptr);
+	ptr = getProc("glMaterialf", userData); set_glMaterialf((glMaterialf_client_proc_t)ptr);
+	ptr = getProc("glMaterialfv", userData); set_glMaterialfv((glMaterialfv_client_proc_t)ptr);
+	ptr = getProc("glMultMatrixf", userData); set_glMultMatrixf((glMultMatrixf_client_proc_t)ptr);
+	ptr = getProc("glMultiTexCoord4f", userData); set_glMultiTexCoord4f((glMultiTexCoord4f_client_proc_t)ptr);
+	ptr = getProc("glNormal3f", userData); set_glNormal3f((glNormal3f_client_proc_t)ptr);
+	ptr = getProc("glOrthof", userData); set_glOrthof((glOrthof_client_proc_t)ptr);
+	ptr = getProc("glPointParameterf", userData); set_glPointParameterf((glPointParameterf_client_proc_t)ptr);
+	ptr = getProc("glPointParameterfv", userData); set_glPointParameterfv((glPointParameterfv_client_proc_t)ptr);
+	ptr = getProc("glPointSize", userData); set_glPointSize((glPointSize_client_proc_t)ptr);
+	ptr = getProc("glPolygonOffset", userData); set_glPolygonOffset((glPolygonOffset_client_proc_t)ptr);
+	ptr = getProc("glRotatef", userData); set_glRotatef((glRotatef_client_proc_t)ptr);
+	ptr = getProc("glScalef", userData); set_glScalef((glScalef_client_proc_t)ptr);
+	ptr = getProc("glTexEnvf", userData); set_glTexEnvf((glTexEnvf_client_proc_t)ptr);
+	ptr = getProc("glTexEnvfv", userData); set_glTexEnvfv((glTexEnvfv_client_proc_t)ptr);
+	ptr = getProc("glTexParameterf", userData); set_glTexParameterf((glTexParameterf_client_proc_t)ptr);
+	ptr = getProc("glTexParameterfv", userData); set_glTexParameterfv((glTexParameterfv_client_proc_t)ptr);
+	ptr = getProc("glTranslatef", userData); set_glTranslatef((glTranslatef_client_proc_t)ptr);
+	ptr = getProc("glActiveTexture", userData); set_glActiveTexture((glActiveTexture_client_proc_t)ptr);
+	ptr = getProc("glAlphaFuncx", userData); set_glAlphaFuncx((glAlphaFuncx_client_proc_t)ptr);
+	ptr = getProc("glBindBuffer", userData); set_glBindBuffer((glBindBuffer_client_proc_t)ptr);
+	ptr = getProc("glBindTexture", userData); set_glBindTexture((glBindTexture_client_proc_t)ptr);
+	ptr = getProc("glBlendFunc", userData); set_glBlendFunc((glBlendFunc_client_proc_t)ptr);
+	ptr = getProc("glBufferData", userData); set_glBufferData((glBufferData_client_proc_t)ptr);
+	ptr = getProc("glBufferSubData", userData); set_glBufferSubData((glBufferSubData_client_proc_t)ptr);
+	ptr = getProc("glClear", userData); set_glClear((glClear_client_proc_t)ptr);
+	ptr = getProc("glClearColorx", userData); set_glClearColorx((glClearColorx_client_proc_t)ptr);
+	ptr = getProc("glClearDepthx", userData); set_glClearDepthx((glClearDepthx_client_proc_t)ptr);
+	ptr = getProc("glClearStencil", userData); set_glClearStencil((glClearStencil_client_proc_t)ptr);
+	ptr = getProc("glClientActiveTexture", userData); set_glClientActiveTexture((glClientActiveTexture_client_proc_t)ptr);
+	ptr = getProc("glColor4ub", userData); set_glColor4ub((glColor4ub_client_proc_t)ptr);
+	ptr = getProc("glColor4x", userData); set_glColor4x((glColor4x_client_proc_t)ptr);
+	ptr = getProc("glColorMask", userData); set_glColorMask((glColorMask_client_proc_t)ptr);
+	ptr = getProc("glColorPointer", userData); set_glColorPointer((glColorPointer_client_proc_t)ptr);
+	ptr = getProc("glCompressedTexImage2D", userData); set_glCompressedTexImage2D((glCompressedTexImage2D_client_proc_t)ptr);
+	ptr = getProc("glCompressedTexSubImage2D", userData); set_glCompressedTexSubImage2D((glCompressedTexSubImage2D_client_proc_t)ptr);
+	ptr = getProc("glCopyTexImage2D", userData); set_glCopyTexImage2D((glCopyTexImage2D_client_proc_t)ptr);
+	ptr = getProc("glCopyTexSubImage2D", userData); set_glCopyTexSubImage2D((glCopyTexSubImage2D_client_proc_t)ptr);
+	ptr = getProc("glCullFace", userData); set_glCullFace((glCullFace_client_proc_t)ptr);
+	ptr = getProc("glDeleteBuffers", userData); set_glDeleteBuffers((glDeleteBuffers_client_proc_t)ptr);
+	ptr = getProc("glDeleteTextures", userData); set_glDeleteTextures((glDeleteTextures_client_proc_t)ptr);
+	ptr = getProc("glDepthFunc", userData); set_glDepthFunc((glDepthFunc_client_proc_t)ptr);
+	ptr = getProc("glDepthMask", userData); set_glDepthMask((glDepthMask_client_proc_t)ptr);
+	ptr = getProc("glDepthRangex", userData); set_glDepthRangex((glDepthRangex_client_proc_t)ptr);
+	ptr = getProc("glDisable", userData); set_glDisable((glDisable_client_proc_t)ptr);
+	ptr = getProc("glDisableClientState", userData); set_glDisableClientState((glDisableClientState_client_proc_t)ptr);
+	ptr = getProc("glDrawArrays", userData); set_glDrawArrays((glDrawArrays_client_proc_t)ptr);
+	ptr = getProc("glDrawElements", userData); set_glDrawElements((glDrawElements_client_proc_t)ptr);
+	ptr = getProc("glEnable", userData); set_glEnable((glEnable_client_proc_t)ptr);
+	ptr = getProc("glEnableClientState", userData); set_glEnableClientState((glEnableClientState_client_proc_t)ptr);
+	ptr = getProc("glFinish", userData); set_glFinish((glFinish_client_proc_t)ptr);
+	ptr = getProc("glFlush", userData); set_glFlush((glFlush_client_proc_t)ptr);
+	ptr = getProc("glFogx", userData); set_glFogx((glFogx_client_proc_t)ptr);
+	ptr = getProc("glFogxv", userData); set_glFogxv((glFogxv_client_proc_t)ptr);
+	ptr = getProc("glFrontFace", userData); set_glFrontFace((glFrontFace_client_proc_t)ptr);
+	ptr = getProc("glFrustumx", userData); set_glFrustumx((glFrustumx_client_proc_t)ptr);
+	ptr = getProc("glGetBooleanv", userData); set_glGetBooleanv((glGetBooleanv_client_proc_t)ptr);
+	ptr = getProc("glGetBufferParameteriv", userData); set_glGetBufferParameteriv((glGetBufferParameteriv_client_proc_t)ptr);
+	ptr = getProc("glClipPlanex", userData); set_glClipPlanex((glClipPlanex_client_proc_t)ptr);
+	ptr = getProc("glGenBuffers", userData); set_glGenBuffers((glGenBuffers_client_proc_t)ptr);
+	ptr = getProc("glGenTextures", userData); set_glGenTextures((glGenTextures_client_proc_t)ptr);
+	ptr = getProc("glGetError", userData); set_glGetError((glGetError_client_proc_t)ptr);
+	ptr = getProc("glGetFixedv", userData); set_glGetFixedv((glGetFixedv_client_proc_t)ptr);
+	ptr = getProc("glGetIntegerv", userData); set_glGetIntegerv((glGetIntegerv_client_proc_t)ptr);
+	ptr = getProc("glGetLightxv", userData); set_glGetLightxv((glGetLightxv_client_proc_t)ptr);
+	ptr = getProc("glGetMaterialxv", userData); set_glGetMaterialxv((glGetMaterialxv_client_proc_t)ptr);
+	ptr = getProc("glGetPointerv", userData); set_glGetPointerv((glGetPointerv_client_proc_t)ptr);
+	ptr = getProc("glGetString", userData); set_glGetString((glGetString_client_proc_t)ptr);
+	ptr = getProc("glGetTexEnviv", userData); set_glGetTexEnviv((glGetTexEnviv_client_proc_t)ptr);
+	ptr = getProc("glGetTexEnvxv", userData); set_glGetTexEnvxv((glGetTexEnvxv_client_proc_t)ptr);
+	ptr = getProc("glGetTexParameteriv", userData); set_glGetTexParameteriv((glGetTexParameteriv_client_proc_t)ptr);
+	ptr = getProc("glGetTexParameterxv", userData); set_glGetTexParameterxv((glGetTexParameterxv_client_proc_t)ptr);
+	ptr = getProc("glHint", userData); set_glHint((glHint_client_proc_t)ptr);
+	ptr = getProc("glIsBuffer", userData); set_glIsBuffer((glIsBuffer_client_proc_t)ptr);
+	ptr = getProc("glIsEnabled", userData); set_glIsEnabled((glIsEnabled_client_proc_t)ptr);
+	ptr = getProc("glIsTexture", userData); set_glIsTexture((glIsTexture_client_proc_t)ptr);
+	ptr = getProc("glLightModelx", userData); set_glLightModelx((glLightModelx_client_proc_t)ptr);
+	ptr = getProc("glLightModelxv", userData); set_glLightModelxv((glLightModelxv_client_proc_t)ptr);
+	ptr = getProc("glLightx", userData); set_glLightx((glLightx_client_proc_t)ptr);
+	ptr = getProc("glLightxv", userData); set_glLightxv((glLightxv_client_proc_t)ptr);
+	ptr = getProc("glLineWidthx", userData); set_glLineWidthx((glLineWidthx_client_proc_t)ptr);
+	ptr = getProc("glLoadIdentity", userData); set_glLoadIdentity((glLoadIdentity_client_proc_t)ptr);
+	ptr = getProc("glLoadMatrixx", userData); set_glLoadMatrixx((glLoadMatrixx_client_proc_t)ptr);
+	ptr = getProc("glLogicOp", userData); set_glLogicOp((glLogicOp_client_proc_t)ptr);
+	ptr = getProc("glMaterialx", userData); set_glMaterialx((glMaterialx_client_proc_t)ptr);
+	ptr = getProc("glMaterialxv", userData); set_glMaterialxv((glMaterialxv_client_proc_t)ptr);
+	ptr = getProc("glMatrixMode", userData); set_glMatrixMode((glMatrixMode_client_proc_t)ptr);
+	ptr = getProc("glMultMatrixx", userData); set_glMultMatrixx((glMultMatrixx_client_proc_t)ptr);
+	ptr = getProc("glMultiTexCoord4x", userData); set_glMultiTexCoord4x((glMultiTexCoord4x_client_proc_t)ptr);
+	ptr = getProc("glNormal3x", userData); set_glNormal3x((glNormal3x_client_proc_t)ptr);
+	ptr = getProc("glNormalPointer", userData); set_glNormalPointer((glNormalPointer_client_proc_t)ptr);
+	ptr = getProc("glOrthox", userData); set_glOrthox((glOrthox_client_proc_t)ptr);
+	ptr = getProc("glPixelStorei", userData); set_glPixelStorei((glPixelStorei_client_proc_t)ptr);
+	ptr = getProc("glPointParameterx", userData); set_glPointParameterx((glPointParameterx_client_proc_t)ptr);
+	ptr = getProc("glPointParameterxv", userData); set_glPointParameterxv((glPointParameterxv_client_proc_t)ptr);
+	ptr = getProc("glPointSizex", userData); set_glPointSizex((glPointSizex_client_proc_t)ptr);
+	ptr = getProc("glPolygonOffsetx", userData); set_glPolygonOffsetx((glPolygonOffsetx_client_proc_t)ptr);
+	ptr = getProc("glPopMatrix", userData); set_glPopMatrix((glPopMatrix_client_proc_t)ptr);
+	ptr = getProc("glPushMatrix", userData); set_glPushMatrix((glPushMatrix_client_proc_t)ptr);
+	ptr = getProc("glReadPixels", userData); set_glReadPixels((glReadPixels_client_proc_t)ptr);
+	ptr = getProc("glRotatex", userData); set_glRotatex((glRotatex_client_proc_t)ptr);
+	ptr = getProc("glSampleCoverage", userData); set_glSampleCoverage((glSampleCoverage_client_proc_t)ptr);
+	ptr = getProc("glSampleCoveragex", userData); set_glSampleCoveragex((glSampleCoveragex_client_proc_t)ptr);
+	ptr = getProc("glScalex", userData); set_glScalex((glScalex_client_proc_t)ptr);
+	ptr = getProc("glScissor", userData); set_glScissor((glScissor_client_proc_t)ptr);
+	ptr = getProc("glShadeModel", userData); set_glShadeModel((glShadeModel_client_proc_t)ptr);
+	ptr = getProc("glStencilFunc", userData); set_glStencilFunc((glStencilFunc_client_proc_t)ptr);
+	ptr = getProc("glStencilMask", userData); set_glStencilMask((glStencilMask_client_proc_t)ptr);
+	ptr = getProc("glStencilOp", userData); set_glStencilOp((glStencilOp_client_proc_t)ptr);
+	ptr = getProc("glTexCoordPointer", userData); set_glTexCoordPointer((glTexCoordPointer_client_proc_t)ptr);
+	ptr = getProc("glTexEnvi", userData); set_glTexEnvi((glTexEnvi_client_proc_t)ptr);
+	ptr = getProc("glTexEnvx", userData); set_glTexEnvx((glTexEnvx_client_proc_t)ptr);
+	ptr = getProc("glTexEnviv", userData); set_glTexEnviv((glTexEnviv_client_proc_t)ptr);
+	ptr = getProc("glTexEnvxv", userData); set_glTexEnvxv((glTexEnvxv_client_proc_t)ptr);
+	ptr = getProc("glTexImage2D", userData); set_glTexImage2D((glTexImage2D_client_proc_t)ptr);
+	ptr = getProc("glTexParameteri", userData); set_glTexParameteri((glTexParameteri_client_proc_t)ptr);
+	ptr = getProc("glTexParameterx", userData); set_glTexParameterx((glTexParameterx_client_proc_t)ptr);
+	ptr = getProc("glTexParameteriv", userData); set_glTexParameteriv((glTexParameteriv_client_proc_t)ptr);
+	ptr = getProc("glTexParameterxv", userData); set_glTexParameterxv((glTexParameterxv_client_proc_t)ptr);
+	ptr = getProc("glTexSubImage2D", userData); set_glTexSubImage2D((glTexSubImage2D_client_proc_t)ptr);
+	ptr = getProc("glTranslatex", userData); set_glTranslatex((glTranslatex_client_proc_t)ptr);
+	ptr = getProc("glVertexPointer", userData); set_glVertexPointer((glVertexPointer_client_proc_t)ptr);
+	ptr = getProc("glViewport", userData); set_glViewport((glViewport_client_proc_t)ptr);
+	ptr = getProc("glPointSizePointerOES", userData); set_glPointSizePointerOES((glPointSizePointerOES_client_proc_t)ptr);
+	ptr = getProc("glVertexPointerOffset", userData); set_glVertexPointerOffset((glVertexPointerOffset_client_proc_t)ptr);
+	ptr = getProc("glColorPointerOffset", userData); set_glColorPointerOffset((glColorPointerOffset_client_proc_t)ptr);
+	ptr = getProc("glNormalPointerOffset", userData); set_glNormalPointerOffset((glNormalPointerOffset_client_proc_t)ptr);
+	ptr = getProc("glPointSizePointerOffset", userData); set_glPointSizePointerOffset((glPointSizePointerOffset_client_proc_t)ptr);
+	ptr = getProc("glTexCoordPointerOffset", userData); set_glTexCoordPointerOffset((glTexCoordPointerOffset_client_proc_t)ptr);
+	ptr = getProc("glWeightPointerOffset", userData); set_glWeightPointerOffset((glWeightPointerOffset_client_proc_t)ptr);
+	ptr = getProc("glMatrixIndexPointerOffset", userData); set_glMatrixIndexPointerOffset((glMatrixIndexPointerOffset_client_proc_t)ptr);
+	ptr = getProc("glVertexPointerData", userData); set_glVertexPointerData((glVertexPointerData_client_proc_t)ptr);
+	ptr = getProc("glColorPointerData", userData); set_glColorPointerData((glColorPointerData_client_proc_t)ptr);
+	ptr = getProc("glNormalPointerData", userData); set_glNormalPointerData((glNormalPointerData_client_proc_t)ptr);
+	ptr = getProc("glTexCoordPointerData", userData); set_glTexCoordPointerData((glTexCoordPointerData_client_proc_t)ptr);
+	ptr = getProc("glPointSizePointerData", userData); set_glPointSizePointerData((glPointSizePointerData_client_proc_t)ptr);
+	ptr = getProc("glWeightPointerData", userData); set_glWeightPointerData((glWeightPointerData_client_proc_t)ptr);
+	ptr = getProc("glMatrixIndexPointerData", userData); set_glMatrixIndexPointerData((glMatrixIndexPointerData_client_proc_t)ptr);
+	ptr = getProc("glDrawElementsOffset", userData); set_glDrawElementsOffset((glDrawElementsOffset_client_proc_t)ptr);
+	ptr = getProc("glDrawElementsData", userData); set_glDrawElementsData((glDrawElementsData_client_proc_t)ptr);
+	ptr = getProc("glGetCompressedTextureFormats", userData); set_glGetCompressedTextureFormats((glGetCompressedTextureFormats_client_proc_t)ptr);
+	ptr = getProc("glFinishRoundTrip", userData); set_glFinishRoundTrip((glFinishRoundTrip_client_proc_t)ptr);
+	ptr = getProc("glBlendEquationSeparateOES", userData); set_glBlendEquationSeparateOES((glBlendEquationSeparateOES_client_proc_t)ptr);
+	ptr = getProc("glBlendFuncSeparateOES", userData); set_glBlendFuncSeparateOES((glBlendFuncSeparateOES_client_proc_t)ptr);
+	ptr = getProc("glBlendEquationOES", userData); set_glBlendEquationOES((glBlendEquationOES_client_proc_t)ptr);
+	ptr = getProc("glDrawTexsOES", userData); set_glDrawTexsOES((glDrawTexsOES_client_proc_t)ptr);
+	ptr = getProc("glDrawTexiOES", userData); set_glDrawTexiOES((glDrawTexiOES_client_proc_t)ptr);
+	ptr = getProc("glDrawTexxOES", userData); set_glDrawTexxOES((glDrawTexxOES_client_proc_t)ptr);
+	ptr = getProc("glDrawTexsvOES", userData); set_glDrawTexsvOES((glDrawTexsvOES_client_proc_t)ptr);
+	ptr = getProc("glDrawTexivOES", userData); set_glDrawTexivOES((glDrawTexivOES_client_proc_t)ptr);
+	ptr = getProc("glDrawTexxvOES", userData); set_glDrawTexxvOES((glDrawTexxvOES_client_proc_t)ptr);
+	ptr = getProc("glDrawTexfOES", userData); set_glDrawTexfOES((glDrawTexfOES_client_proc_t)ptr);
+	ptr = getProc("glDrawTexfvOES", userData); set_glDrawTexfvOES((glDrawTexfvOES_client_proc_t)ptr);
+	ptr = getProc("glEGLImageTargetTexture2DOES", userData); set_glEGLImageTargetTexture2DOES((glEGLImageTargetTexture2DOES_client_proc_t)ptr);
+	ptr = getProc("glEGLImageTargetRenderbufferStorageOES", userData); set_glEGLImageTargetRenderbufferStorageOES((glEGLImageTargetRenderbufferStorageOES_client_proc_t)ptr);
+	ptr = getProc("glAlphaFuncxOES", userData); set_glAlphaFuncxOES((glAlphaFuncxOES_client_proc_t)ptr);
+	ptr = getProc("glClearColorxOES", userData); set_glClearColorxOES((glClearColorxOES_client_proc_t)ptr);
+	ptr = getProc("glClearDepthxOES", userData); set_glClearDepthxOES((glClearDepthxOES_client_proc_t)ptr);
+	ptr = getProc("glClipPlanexOES", userData); set_glClipPlanexOES((glClipPlanexOES_client_proc_t)ptr);
+	ptr = getProc("glClipPlanexIMG", userData); set_glClipPlanexIMG((glClipPlanexIMG_client_proc_t)ptr);
+	ptr = getProc("glColor4xOES", userData); set_glColor4xOES((glColor4xOES_client_proc_t)ptr);
+	ptr = getProc("glDepthRangexOES", userData); set_glDepthRangexOES((glDepthRangexOES_client_proc_t)ptr);
+	ptr = getProc("glFogxOES", userData); set_glFogxOES((glFogxOES_client_proc_t)ptr);
+	ptr = getProc("glFogxvOES", userData); set_glFogxvOES((glFogxvOES_client_proc_t)ptr);
+	ptr = getProc("glFrustumxOES", userData); set_glFrustumxOES((glFrustumxOES_client_proc_t)ptr);
+	ptr = getProc("glGetClipPlanexOES", userData); set_glGetClipPlanexOES((glGetClipPlanexOES_client_proc_t)ptr);
+	ptr = getProc("glGetClipPlanex", userData); set_glGetClipPlanex((glGetClipPlanex_client_proc_t)ptr);
+	ptr = getProc("glGetFixedvOES", userData); set_glGetFixedvOES((glGetFixedvOES_client_proc_t)ptr);
+	ptr = getProc("glGetLightxvOES", userData); set_glGetLightxvOES((glGetLightxvOES_client_proc_t)ptr);
+	ptr = getProc("glGetMaterialxvOES", userData); set_glGetMaterialxvOES((glGetMaterialxvOES_client_proc_t)ptr);
+	ptr = getProc("glGetTexEnvxvOES", userData); set_glGetTexEnvxvOES((glGetTexEnvxvOES_client_proc_t)ptr);
+	ptr = getProc("glGetTexParameterxvOES", userData); set_glGetTexParameterxvOES((glGetTexParameterxvOES_client_proc_t)ptr);
+	ptr = getProc("glLightModelxOES", userData); set_glLightModelxOES((glLightModelxOES_client_proc_t)ptr);
+	ptr = getProc("glLightModelxvOES", userData); set_glLightModelxvOES((glLightModelxvOES_client_proc_t)ptr);
+	ptr = getProc("glLightxOES", userData); set_glLightxOES((glLightxOES_client_proc_t)ptr);
+	ptr = getProc("glLightxvOES", userData); set_glLightxvOES((glLightxvOES_client_proc_t)ptr);
+	ptr = getProc("glLineWidthxOES", userData); set_glLineWidthxOES((glLineWidthxOES_client_proc_t)ptr);
+	ptr = getProc("glLoadMatrixxOES", userData); set_glLoadMatrixxOES((glLoadMatrixxOES_client_proc_t)ptr);
+	ptr = getProc("glMaterialxOES", userData); set_glMaterialxOES((glMaterialxOES_client_proc_t)ptr);
+	ptr = getProc("glMaterialxvOES", userData); set_glMaterialxvOES((glMaterialxvOES_client_proc_t)ptr);
+	ptr = getProc("glMultMatrixxOES", userData); set_glMultMatrixxOES((glMultMatrixxOES_client_proc_t)ptr);
+	ptr = getProc("glMultiTexCoord4xOES", userData); set_glMultiTexCoord4xOES((glMultiTexCoord4xOES_client_proc_t)ptr);
+	ptr = getProc("glNormal3xOES", userData); set_glNormal3xOES((glNormal3xOES_client_proc_t)ptr);
+	ptr = getProc("glOrthoxOES", userData); set_glOrthoxOES((glOrthoxOES_client_proc_t)ptr);
+	ptr = getProc("glPointParameterxOES", userData); set_glPointParameterxOES((glPointParameterxOES_client_proc_t)ptr);
+	ptr = getProc("glPointParameterxvOES", userData); set_glPointParameterxvOES((glPointParameterxvOES_client_proc_t)ptr);
+	ptr = getProc("glPointSizexOES", userData); set_glPointSizexOES((glPointSizexOES_client_proc_t)ptr);
+	ptr = getProc("glPolygonOffsetxOES", userData); set_glPolygonOffsetxOES((glPolygonOffsetxOES_client_proc_t)ptr);
+	ptr = getProc("glRotatexOES", userData); set_glRotatexOES((glRotatexOES_client_proc_t)ptr);
+	ptr = getProc("glSampleCoveragexOES", userData); set_glSampleCoveragexOES((glSampleCoveragexOES_client_proc_t)ptr);
+	ptr = getProc("glScalexOES", userData); set_glScalexOES((glScalexOES_client_proc_t)ptr);
+	ptr = getProc("glTexEnvxOES", userData); set_glTexEnvxOES((glTexEnvxOES_client_proc_t)ptr);
+	ptr = getProc("glTexEnvxvOES", userData); set_glTexEnvxvOES((glTexEnvxvOES_client_proc_t)ptr);
+	ptr = getProc("glTexParameterxOES", userData); set_glTexParameterxOES((glTexParameterxOES_client_proc_t)ptr);
+	ptr = getProc("glTexParameterxvOES", userData); set_glTexParameterxvOES((glTexParameterxvOES_client_proc_t)ptr);
+	ptr = getProc("glTranslatexOES", userData); set_glTranslatexOES((glTranslatexOES_client_proc_t)ptr);
+	ptr = getProc("glIsRenderbufferOES", userData); set_glIsRenderbufferOES((glIsRenderbufferOES_client_proc_t)ptr);
+	ptr = getProc("glBindRenderbufferOES", userData); set_glBindRenderbufferOES((glBindRenderbufferOES_client_proc_t)ptr);
+	ptr = getProc("glDeleteRenderbuffersOES", userData); set_glDeleteRenderbuffersOES((glDeleteRenderbuffersOES_client_proc_t)ptr);
+	ptr = getProc("glGenRenderbuffersOES", userData); set_glGenRenderbuffersOES((glGenRenderbuffersOES_client_proc_t)ptr);
+	ptr = getProc("glRenderbufferStorageOES", userData); set_glRenderbufferStorageOES((glRenderbufferStorageOES_client_proc_t)ptr);
+	ptr = getProc("glGetRenderbufferParameterivOES", userData); set_glGetRenderbufferParameterivOES((glGetRenderbufferParameterivOES_client_proc_t)ptr);
+	ptr = getProc("glIsFramebufferOES", userData); set_glIsFramebufferOES((glIsFramebufferOES_client_proc_t)ptr);
+	ptr = getProc("glBindFramebufferOES", userData); set_glBindFramebufferOES((glBindFramebufferOES_client_proc_t)ptr);
+	ptr = getProc("glDeleteFramebuffersOES", userData); set_glDeleteFramebuffersOES((glDeleteFramebuffersOES_client_proc_t)ptr);
+	ptr = getProc("glGenFramebuffersOES", userData); set_glGenFramebuffersOES((glGenFramebuffersOES_client_proc_t)ptr);
+	ptr = getProc("glCheckFramebufferStatusOES", userData); set_glCheckFramebufferStatusOES((glCheckFramebufferStatusOES_client_proc_t)ptr);
+	ptr = getProc("glFramebufferRenderbufferOES", userData); set_glFramebufferRenderbufferOES((glFramebufferRenderbufferOES_client_proc_t)ptr);
+	ptr = getProc("glFramebufferTexture2DOES", userData); set_glFramebufferTexture2DOES((glFramebufferTexture2DOES_client_proc_t)ptr);
+	ptr = getProc("glGetFramebufferAttachmentParameterivOES", userData); set_glGetFramebufferAttachmentParameterivOES((glGetFramebufferAttachmentParameterivOES_client_proc_t)ptr);
+	ptr = getProc("glGenerateMipmapOES", userData); set_glGenerateMipmapOES((glGenerateMipmapOES_client_proc_t)ptr);
+	ptr = getProc("glMapBufferOES", userData); set_glMapBufferOES((glMapBufferOES_client_proc_t)ptr);
+	ptr = getProc("glUnmapBufferOES", userData); set_glUnmapBufferOES((glUnmapBufferOES_client_proc_t)ptr);
+	ptr = getProc("glGetBufferPointervOES", userData); set_glGetBufferPointervOES((glGetBufferPointervOES_client_proc_t)ptr);
+	ptr = getProc("glCurrentPaletteMatrixOES", userData); set_glCurrentPaletteMatrixOES((glCurrentPaletteMatrixOES_client_proc_t)ptr);
+	ptr = getProc("glLoadPaletteFromModelViewMatrixOES", userData); set_glLoadPaletteFromModelViewMatrixOES((glLoadPaletteFromModelViewMatrixOES_client_proc_t)ptr);
+	ptr = getProc("glMatrixIndexPointerOES", userData); set_glMatrixIndexPointerOES((glMatrixIndexPointerOES_client_proc_t)ptr);
+	ptr = getProc("glWeightPointerOES", userData); set_glWeightPointerOES((glWeightPointerOES_client_proc_t)ptr);
+	ptr = getProc("glQueryMatrixxOES", userData); set_glQueryMatrixxOES((glQueryMatrixxOES_client_proc_t)ptr);
+	ptr = getProc("glDepthRangefOES", userData); set_glDepthRangefOES((glDepthRangefOES_client_proc_t)ptr);
+	ptr = getProc("glFrustumfOES", userData); set_glFrustumfOES((glFrustumfOES_client_proc_t)ptr);
+	ptr = getProc("glOrthofOES", userData); set_glOrthofOES((glOrthofOES_client_proc_t)ptr);
+	ptr = getProc("glClipPlanefOES", userData); set_glClipPlanefOES((glClipPlanefOES_client_proc_t)ptr);
+	ptr = getProc("glClipPlanefIMG", userData); set_glClipPlanefIMG((glClipPlanefIMG_client_proc_t)ptr);
+	ptr = getProc("glGetClipPlanefOES", userData); set_glGetClipPlanefOES((glGetClipPlanefOES_client_proc_t)ptr);
+	ptr = getProc("glClearDepthfOES", userData); set_glClearDepthfOES((glClearDepthfOES_client_proc_t)ptr);
+	ptr = getProc("glTexGenfOES", userData); set_glTexGenfOES((glTexGenfOES_client_proc_t)ptr);
+	ptr = getProc("glTexGenfvOES", userData); set_glTexGenfvOES((glTexGenfvOES_client_proc_t)ptr);
+	ptr = getProc("glTexGeniOES", userData); set_glTexGeniOES((glTexGeniOES_client_proc_t)ptr);
+	ptr = getProc("glTexGenivOES", userData); set_glTexGenivOES((glTexGenivOES_client_proc_t)ptr);
+	ptr = getProc("glTexGenxOES", userData); set_glTexGenxOES((glTexGenxOES_client_proc_t)ptr);
+	ptr = getProc("glTexGenxvOES", userData); set_glTexGenxvOES((glTexGenxvOES_client_proc_t)ptr);
+	ptr = getProc("glGetTexGenfvOES", userData); set_glGetTexGenfvOES((glGetTexGenfvOES_client_proc_t)ptr);
+	ptr = getProc("glGetTexGenivOES", userData); set_glGetTexGenivOES((glGetTexGenivOES_client_proc_t)ptr);
+	ptr = getProc("glGetTexGenxvOES", userData); set_glGetTexGenxvOES((glGetTexGenxvOES_client_proc_t)ptr);
+	ptr = getProc("glBindVertexArrayOES", userData); set_glBindVertexArrayOES((glBindVertexArrayOES_client_proc_t)ptr);
+	ptr = getProc("glDeleteVertexArraysOES", userData); set_glDeleteVertexArraysOES((glDeleteVertexArraysOES_client_proc_t)ptr);
+	ptr = getProc("glGenVertexArraysOES", userData); set_glGenVertexArraysOES((glGenVertexArraysOES_client_proc_t)ptr);
+	ptr = getProc("glIsVertexArrayOES", userData); set_glIsVertexArrayOES((glIsVertexArrayOES_client_proc_t)ptr);
+	ptr = getProc("glDiscardFramebufferEXT", userData); set_glDiscardFramebufferEXT((glDiscardFramebufferEXT_client_proc_t)ptr);
+	ptr = getProc("glMultiDrawArraysEXT", userData); set_glMultiDrawArraysEXT((glMultiDrawArraysEXT_client_proc_t)ptr);
+	ptr = getProc("glMultiDrawElementsEXT", userData); set_glMultiDrawElementsEXT((glMultiDrawElementsEXT_client_proc_t)ptr);
+	ptr = getProc("glMultiDrawArraysSUN", userData); set_glMultiDrawArraysSUN((glMultiDrawArraysSUN_client_proc_t)ptr);
+	ptr = getProc("glMultiDrawElementsSUN", userData); set_glMultiDrawElementsSUN((glMultiDrawElementsSUN_client_proc_t)ptr);
+	ptr = getProc("glRenderbufferStorageMultisampleIMG", userData); set_glRenderbufferStorageMultisampleIMG((glRenderbufferStorageMultisampleIMG_client_proc_t)ptr);
+	ptr = getProc("glFramebufferTexture2DMultisampleIMG", userData); set_glFramebufferTexture2DMultisampleIMG((glFramebufferTexture2DMultisampleIMG_client_proc_t)ptr);
+	ptr = getProc("glDeleteFencesNV", userData); set_glDeleteFencesNV((glDeleteFencesNV_client_proc_t)ptr);
+	ptr = getProc("glGenFencesNV", userData); set_glGenFencesNV((glGenFencesNV_client_proc_t)ptr);
+	ptr = getProc("glIsFenceNV", userData); set_glIsFenceNV((glIsFenceNV_client_proc_t)ptr);
+	ptr = getProc("glTestFenceNV", userData); set_glTestFenceNV((glTestFenceNV_client_proc_t)ptr);
+	ptr = getProc("glGetFenceivNV", userData); set_glGetFenceivNV((glGetFenceivNV_client_proc_t)ptr);
+	ptr = getProc("glFinishFenceNV", userData); set_glFinishFenceNV((glFinishFenceNV_client_proc_t)ptr);
+	ptr = getProc("glSetFenceNV", userData); set_glSetFenceNV((glSetFenceNV_client_proc_t)ptr);
+	ptr = getProc("glGetDriverControlsQCOM", userData); set_glGetDriverControlsQCOM((glGetDriverControlsQCOM_client_proc_t)ptr);
+	ptr = getProc("glGetDriverControlStringQCOM", userData); set_glGetDriverControlStringQCOM((glGetDriverControlStringQCOM_client_proc_t)ptr);
+	ptr = getProc("glEnableDriverControlQCOM", userData); set_glEnableDriverControlQCOM((glEnableDriverControlQCOM_client_proc_t)ptr);
+	ptr = getProc("glDisableDriverControlQCOM", userData); set_glDisableDriverControlQCOM((glDisableDriverControlQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetTexturesQCOM", userData); set_glExtGetTexturesQCOM((glExtGetTexturesQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetBuffersQCOM", userData); set_glExtGetBuffersQCOM((glExtGetBuffersQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetRenderbuffersQCOM", userData); set_glExtGetRenderbuffersQCOM((glExtGetRenderbuffersQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetFramebuffersQCOM", userData); set_glExtGetFramebuffersQCOM((glExtGetFramebuffersQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetTexLevelParameterivQCOM", userData); set_glExtGetTexLevelParameterivQCOM((glExtGetTexLevelParameterivQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtTexObjectStateOverrideiQCOM", userData); set_glExtTexObjectStateOverrideiQCOM((glExtTexObjectStateOverrideiQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetTexSubImageQCOM", userData); set_glExtGetTexSubImageQCOM((glExtGetTexSubImageQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetBufferPointervQCOM", userData); set_glExtGetBufferPointervQCOM((glExtGetBufferPointervQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetShadersQCOM", userData); set_glExtGetShadersQCOM((glExtGetShadersQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetProgramsQCOM", userData); set_glExtGetProgramsQCOM((glExtGetProgramsQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtIsProgramBinaryQCOM", userData); set_glExtIsProgramBinaryQCOM((glExtIsProgramBinaryQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetProgramBinarySourceQCOM", userData); set_glExtGetProgramBinarySourceQCOM((glExtGetProgramBinarySourceQCOM_client_proc_t)ptr);
+	ptr = getProc("glStartTilingQCOM", userData); set_glStartTilingQCOM((glStartTilingQCOM_client_proc_t)ptr);
+	ptr = getProc("glEndTilingQCOM", userData); set_glEndTilingQCOM((glEndTilingQCOM_client_proc_t)ptr);
+	return 0;
+}
+
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl_client_context.h b/tools/emulator/opengl/system/GLESv1_enc/gl_client_context.h
new file mode 100644
index 0000000..c0b83ad
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_client_context.h
@@ -0,0 +1,603 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __gl_client_context_t_h
+#define __gl_client_context_t_h
+
+#include "gl_client_proc.h"
+
+
+struct gl_client_context_t {
+
+	glAlphaFunc_client_proc_t glAlphaFunc;
+	glClearColor_client_proc_t glClearColor;
+	glClearDepthf_client_proc_t glClearDepthf;
+	glClipPlanef_client_proc_t glClipPlanef;
+	glColor4f_client_proc_t glColor4f;
+	glDepthRangef_client_proc_t glDepthRangef;
+	glFogf_client_proc_t glFogf;
+	glFogfv_client_proc_t glFogfv;
+	glFrustumf_client_proc_t glFrustumf;
+	glGetClipPlanef_client_proc_t glGetClipPlanef;
+	glGetFloatv_client_proc_t glGetFloatv;
+	glGetLightfv_client_proc_t glGetLightfv;
+	glGetMaterialfv_client_proc_t glGetMaterialfv;
+	glGetTexEnvfv_client_proc_t glGetTexEnvfv;
+	glGetTexParameterfv_client_proc_t glGetTexParameterfv;
+	glLightModelf_client_proc_t glLightModelf;
+	glLightModelfv_client_proc_t glLightModelfv;
+	glLightf_client_proc_t glLightf;
+	glLightfv_client_proc_t glLightfv;
+	glLineWidth_client_proc_t glLineWidth;
+	glLoadMatrixf_client_proc_t glLoadMatrixf;
+	glMaterialf_client_proc_t glMaterialf;
+	glMaterialfv_client_proc_t glMaterialfv;
+	glMultMatrixf_client_proc_t glMultMatrixf;
+	glMultiTexCoord4f_client_proc_t glMultiTexCoord4f;
+	glNormal3f_client_proc_t glNormal3f;
+	glOrthof_client_proc_t glOrthof;
+	glPointParameterf_client_proc_t glPointParameterf;
+	glPointParameterfv_client_proc_t glPointParameterfv;
+	glPointSize_client_proc_t glPointSize;
+	glPolygonOffset_client_proc_t glPolygonOffset;
+	glRotatef_client_proc_t glRotatef;
+	glScalef_client_proc_t glScalef;
+	glTexEnvf_client_proc_t glTexEnvf;
+	glTexEnvfv_client_proc_t glTexEnvfv;
+	glTexParameterf_client_proc_t glTexParameterf;
+	glTexParameterfv_client_proc_t glTexParameterfv;
+	glTranslatef_client_proc_t glTranslatef;
+	glActiveTexture_client_proc_t glActiveTexture;
+	glAlphaFuncx_client_proc_t glAlphaFuncx;
+	glBindBuffer_client_proc_t glBindBuffer;
+	glBindTexture_client_proc_t glBindTexture;
+	glBlendFunc_client_proc_t glBlendFunc;
+	glBufferData_client_proc_t glBufferData;
+	glBufferSubData_client_proc_t glBufferSubData;
+	glClear_client_proc_t glClear;
+	glClearColorx_client_proc_t glClearColorx;
+	glClearDepthx_client_proc_t glClearDepthx;
+	glClearStencil_client_proc_t glClearStencil;
+	glClientActiveTexture_client_proc_t glClientActiveTexture;
+	glColor4ub_client_proc_t glColor4ub;
+	glColor4x_client_proc_t glColor4x;
+	glColorMask_client_proc_t glColorMask;
+	glColorPointer_client_proc_t glColorPointer;
+	glCompressedTexImage2D_client_proc_t glCompressedTexImage2D;
+	glCompressedTexSubImage2D_client_proc_t glCompressedTexSubImage2D;
+	glCopyTexImage2D_client_proc_t glCopyTexImage2D;
+	glCopyTexSubImage2D_client_proc_t glCopyTexSubImage2D;
+	glCullFace_client_proc_t glCullFace;
+	glDeleteBuffers_client_proc_t glDeleteBuffers;
+	glDeleteTextures_client_proc_t glDeleteTextures;
+	glDepthFunc_client_proc_t glDepthFunc;
+	glDepthMask_client_proc_t glDepthMask;
+	glDepthRangex_client_proc_t glDepthRangex;
+	glDisable_client_proc_t glDisable;
+	glDisableClientState_client_proc_t glDisableClientState;
+	glDrawArrays_client_proc_t glDrawArrays;
+	glDrawElements_client_proc_t glDrawElements;
+	glEnable_client_proc_t glEnable;
+	glEnableClientState_client_proc_t glEnableClientState;
+	glFinish_client_proc_t glFinish;
+	glFlush_client_proc_t glFlush;
+	glFogx_client_proc_t glFogx;
+	glFogxv_client_proc_t glFogxv;
+	glFrontFace_client_proc_t glFrontFace;
+	glFrustumx_client_proc_t glFrustumx;
+	glGetBooleanv_client_proc_t glGetBooleanv;
+	glGetBufferParameteriv_client_proc_t glGetBufferParameteriv;
+	glClipPlanex_client_proc_t glClipPlanex;
+	glGenBuffers_client_proc_t glGenBuffers;
+	glGenTextures_client_proc_t glGenTextures;
+	glGetError_client_proc_t glGetError;
+	glGetFixedv_client_proc_t glGetFixedv;
+	glGetIntegerv_client_proc_t glGetIntegerv;
+	glGetLightxv_client_proc_t glGetLightxv;
+	glGetMaterialxv_client_proc_t glGetMaterialxv;
+	glGetPointerv_client_proc_t glGetPointerv;
+	glGetString_client_proc_t glGetString;
+	glGetTexEnviv_client_proc_t glGetTexEnviv;
+	glGetTexEnvxv_client_proc_t glGetTexEnvxv;
+	glGetTexParameteriv_client_proc_t glGetTexParameteriv;
+	glGetTexParameterxv_client_proc_t glGetTexParameterxv;
+	glHint_client_proc_t glHint;
+	glIsBuffer_client_proc_t glIsBuffer;
+	glIsEnabled_client_proc_t glIsEnabled;
+	glIsTexture_client_proc_t glIsTexture;
+	glLightModelx_client_proc_t glLightModelx;
+	glLightModelxv_client_proc_t glLightModelxv;
+	glLightx_client_proc_t glLightx;
+	glLightxv_client_proc_t glLightxv;
+	glLineWidthx_client_proc_t glLineWidthx;
+	glLoadIdentity_client_proc_t glLoadIdentity;
+	glLoadMatrixx_client_proc_t glLoadMatrixx;
+	glLogicOp_client_proc_t glLogicOp;
+	glMaterialx_client_proc_t glMaterialx;
+	glMaterialxv_client_proc_t glMaterialxv;
+	glMatrixMode_client_proc_t glMatrixMode;
+	glMultMatrixx_client_proc_t glMultMatrixx;
+	glMultiTexCoord4x_client_proc_t glMultiTexCoord4x;
+	glNormal3x_client_proc_t glNormal3x;
+	glNormalPointer_client_proc_t glNormalPointer;
+	glOrthox_client_proc_t glOrthox;
+	glPixelStorei_client_proc_t glPixelStorei;
+	glPointParameterx_client_proc_t glPointParameterx;
+	glPointParameterxv_client_proc_t glPointParameterxv;
+	glPointSizex_client_proc_t glPointSizex;
+	glPolygonOffsetx_client_proc_t glPolygonOffsetx;
+	glPopMatrix_client_proc_t glPopMatrix;
+	glPushMatrix_client_proc_t glPushMatrix;
+	glReadPixels_client_proc_t glReadPixels;
+	glRotatex_client_proc_t glRotatex;
+	glSampleCoverage_client_proc_t glSampleCoverage;
+	glSampleCoveragex_client_proc_t glSampleCoveragex;
+	glScalex_client_proc_t glScalex;
+	glScissor_client_proc_t glScissor;
+	glShadeModel_client_proc_t glShadeModel;
+	glStencilFunc_client_proc_t glStencilFunc;
+	glStencilMask_client_proc_t glStencilMask;
+	glStencilOp_client_proc_t glStencilOp;
+	glTexCoordPointer_client_proc_t glTexCoordPointer;
+	glTexEnvi_client_proc_t glTexEnvi;
+	glTexEnvx_client_proc_t glTexEnvx;
+	glTexEnviv_client_proc_t glTexEnviv;
+	glTexEnvxv_client_proc_t glTexEnvxv;
+	glTexImage2D_client_proc_t glTexImage2D;
+	glTexParameteri_client_proc_t glTexParameteri;
+	glTexParameterx_client_proc_t glTexParameterx;
+	glTexParameteriv_client_proc_t glTexParameteriv;
+	glTexParameterxv_client_proc_t glTexParameterxv;
+	glTexSubImage2D_client_proc_t glTexSubImage2D;
+	glTranslatex_client_proc_t glTranslatex;
+	glVertexPointer_client_proc_t glVertexPointer;
+	glViewport_client_proc_t glViewport;
+	glPointSizePointerOES_client_proc_t glPointSizePointerOES;
+	glVertexPointerOffset_client_proc_t glVertexPointerOffset;
+	glColorPointerOffset_client_proc_t glColorPointerOffset;
+	glNormalPointerOffset_client_proc_t glNormalPointerOffset;
+	glPointSizePointerOffset_client_proc_t glPointSizePointerOffset;
+	glTexCoordPointerOffset_client_proc_t glTexCoordPointerOffset;
+	glWeightPointerOffset_client_proc_t glWeightPointerOffset;
+	glMatrixIndexPointerOffset_client_proc_t glMatrixIndexPointerOffset;
+	glVertexPointerData_client_proc_t glVertexPointerData;
+	glColorPointerData_client_proc_t glColorPointerData;
+	glNormalPointerData_client_proc_t glNormalPointerData;
+	glTexCoordPointerData_client_proc_t glTexCoordPointerData;
+	glPointSizePointerData_client_proc_t glPointSizePointerData;
+	glWeightPointerData_client_proc_t glWeightPointerData;
+	glMatrixIndexPointerData_client_proc_t glMatrixIndexPointerData;
+	glDrawElementsOffset_client_proc_t glDrawElementsOffset;
+	glDrawElementsData_client_proc_t glDrawElementsData;
+	glGetCompressedTextureFormats_client_proc_t glGetCompressedTextureFormats;
+	glFinishRoundTrip_client_proc_t glFinishRoundTrip;
+	glBlendEquationSeparateOES_client_proc_t glBlendEquationSeparateOES;
+	glBlendFuncSeparateOES_client_proc_t glBlendFuncSeparateOES;
+	glBlendEquationOES_client_proc_t glBlendEquationOES;
+	glDrawTexsOES_client_proc_t glDrawTexsOES;
+	glDrawTexiOES_client_proc_t glDrawTexiOES;
+	glDrawTexxOES_client_proc_t glDrawTexxOES;
+	glDrawTexsvOES_client_proc_t glDrawTexsvOES;
+	glDrawTexivOES_client_proc_t glDrawTexivOES;
+	glDrawTexxvOES_client_proc_t glDrawTexxvOES;
+	glDrawTexfOES_client_proc_t glDrawTexfOES;
+	glDrawTexfvOES_client_proc_t glDrawTexfvOES;
+	glEGLImageTargetTexture2DOES_client_proc_t glEGLImageTargetTexture2DOES;
+	glEGLImageTargetRenderbufferStorageOES_client_proc_t glEGLImageTargetRenderbufferStorageOES;
+	glAlphaFuncxOES_client_proc_t glAlphaFuncxOES;
+	glClearColorxOES_client_proc_t glClearColorxOES;
+	glClearDepthxOES_client_proc_t glClearDepthxOES;
+	glClipPlanexOES_client_proc_t glClipPlanexOES;
+	glClipPlanexIMG_client_proc_t glClipPlanexIMG;
+	glColor4xOES_client_proc_t glColor4xOES;
+	glDepthRangexOES_client_proc_t glDepthRangexOES;
+	glFogxOES_client_proc_t glFogxOES;
+	glFogxvOES_client_proc_t glFogxvOES;
+	glFrustumxOES_client_proc_t glFrustumxOES;
+	glGetClipPlanexOES_client_proc_t glGetClipPlanexOES;
+	glGetClipPlanex_client_proc_t glGetClipPlanex;
+	glGetFixedvOES_client_proc_t glGetFixedvOES;
+	glGetLightxvOES_client_proc_t glGetLightxvOES;
+	glGetMaterialxvOES_client_proc_t glGetMaterialxvOES;
+	glGetTexEnvxvOES_client_proc_t glGetTexEnvxvOES;
+	glGetTexParameterxvOES_client_proc_t glGetTexParameterxvOES;
+	glLightModelxOES_client_proc_t glLightModelxOES;
+	glLightModelxvOES_client_proc_t glLightModelxvOES;
+	glLightxOES_client_proc_t glLightxOES;
+	glLightxvOES_client_proc_t glLightxvOES;
+	glLineWidthxOES_client_proc_t glLineWidthxOES;
+	glLoadMatrixxOES_client_proc_t glLoadMatrixxOES;
+	glMaterialxOES_client_proc_t glMaterialxOES;
+	glMaterialxvOES_client_proc_t glMaterialxvOES;
+	glMultMatrixxOES_client_proc_t glMultMatrixxOES;
+	glMultiTexCoord4xOES_client_proc_t glMultiTexCoord4xOES;
+	glNormal3xOES_client_proc_t glNormal3xOES;
+	glOrthoxOES_client_proc_t glOrthoxOES;
+	glPointParameterxOES_client_proc_t glPointParameterxOES;
+	glPointParameterxvOES_client_proc_t glPointParameterxvOES;
+	glPointSizexOES_client_proc_t glPointSizexOES;
+	glPolygonOffsetxOES_client_proc_t glPolygonOffsetxOES;
+	glRotatexOES_client_proc_t glRotatexOES;
+	glSampleCoveragexOES_client_proc_t glSampleCoveragexOES;
+	glScalexOES_client_proc_t glScalexOES;
+	glTexEnvxOES_client_proc_t glTexEnvxOES;
+	glTexEnvxvOES_client_proc_t glTexEnvxvOES;
+	glTexParameterxOES_client_proc_t glTexParameterxOES;
+	glTexParameterxvOES_client_proc_t glTexParameterxvOES;
+	glTranslatexOES_client_proc_t glTranslatexOES;
+	glIsRenderbufferOES_client_proc_t glIsRenderbufferOES;
+	glBindRenderbufferOES_client_proc_t glBindRenderbufferOES;
+	glDeleteRenderbuffersOES_client_proc_t glDeleteRenderbuffersOES;
+	glGenRenderbuffersOES_client_proc_t glGenRenderbuffersOES;
+	glRenderbufferStorageOES_client_proc_t glRenderbufferStorageOES;
+	glGetRenderbufferParameterivOES_client_proc_t glGetRenderbufferParameterivOES;
+	glIsFramebufferOES_client_proc_t glIsFramebufferOES;
+	glBindFramebufferOES_client_proc_t glBindFramebufferOES;
+	glDeleteFramebuffersOES_client_proc_t glDeleteFramebuffersOES;
+	glGenFramebuffersOES_client_proc_t glGenFramebuffersOES;
+	glCheckFramebufferStatusOES_client_proc_t glCheckFramebufferStatusOES;
+	glFramebufferRenderbufferOES_client_proc_t glFramebufferRenderbufferOES;
+	glFramebufferTexture2DOES_client_proc_t glFramebufferTexture2DOES;
+	glGetFramebufferAttachmentParameterivOES_client_proc_t glGetFramebufferAttachmentParameterivOES;
+	glGenerateMipmapOES_client_proc_t glGenerateMipmapOES;
+	glMapBufferOES_client_proc_t glMapBufferOES;
+	glUnmapBufferOES_client_proc_t glUnmapBufferOES;
+	glGetBufferPointervOES_client_proc_t glGetBufferPointervOES;
+	glCurrentPaletteMatrixOES_client_proc_t glCurrentPaletteMatrixOES;
+	glLoadPaletteFromModelViewMatrixOES_client_proc_t glLoadPaletteFromModelViewMatrixOES;
+	glMatrixIndexPointerOES_client_proc_t glMatrixIndexPointerOES;
+	glWeightPointerOES_client_proc_t glWeightPointerOES;
+	glQueryMatrixxOES_client_proc_t glQueryMatrixxOES;
+	glDepthRangefOES_client_proc_t glDepthRangefOES;
+	glFrustumfOES_client_proc_t glFrustumfOES;
+	glOrthofOES_client_proc_t glOrthofOES;
+	glClipPlanefOES_client_proc_t glClipPlanefOES;
+	glClipPlanefIMG_client_proc_t glClipPlanefIMG;
+	glGetClipPlanefOES_client_proc_t glGetClipPlanefOES;
+	glClearDepthfOES_client_proc_t glClearDepthfOES;
+	glTexGenfOES_client_proc_t glTexGenfOES;
+	glTexGenfvOES_client_proc_t glTexGenfvOES;
+	glTexGeniOES_client_proc_t glTexGeniOES;
+	glTexGenivOES_client_proc_t glTexGenivOES;
+	glTexGenxOES_client_proc_t glTexGenxOES;
+	glTexGenxvOES_client_proc_t glTexGenxvOES;
+	glGetTexGenfvOES_client_proc_t glGetTexGenfvOES;
+	glGetTexGenivOES_client_proc_t glGetTexGenivOES;
+	glGetTexGenxvOES_client_proc_t glGetTexGenxvOES;
+	glBindVertexArrayOES_client_proc_t glBindVertexArrayOES;
+	glDeleteVertexArraysOES_client_proc_t glDeleteVertexArraysOES;
+	glGenVertexArraysOES_client_proc_t glGenVertexArraysOES;
+	glIsVertexArrayOES_client_proc_t glIsVertexArrayOES;
+	glDiscardFramebufferEXT_client_proc_t glDiscardFramebufferEXT;
+	glMultiDrawArraysEXT_client_proc_t glMultiDrawArraysEXT;
+	glMultiDrawElementsEXT_client_proc_t glMultiDrawElementsEXT;
+	glMultiDrawArraysSUN_client_proc_t glMultiDrawArraysSUN;
+	glMultiDrawElementsSUN_client_proc_t glMultiDrawElementsSUN;
+	glRenderbufferStorageMultisampleIMG_client_proc_t glRenderbufferStorageMultisampleIMG;
+	glFramebufferTexture2DMultisampleIMG_client_proc_t glFramebufferTexture2DMultisampleIMG;
+	glDeleteFencesNV_client_proc_t glDeleteFencesNV;
+	glGenFencesNV_client_proc_t glGenFencesNV;
+	glIsFenceNV_client_proc_t glIsFenceNV;
+	glTestFenceNV_client_proc_t glTestFenceNV;
+	glGetFenceivNV_client_proc_t glGetFenceivNV;
+	glFinishFenceNV_client_proc_t glFinishFenceNV;
+	glSetFenceNV_client_proc_t glSetFenceNV;
+	glGetDriverControlsQCOM_client_proc_t glGetDriverControlsQCOM;
+	glGetDriverControlStringQCOM_client_proc_t glGetDriverControlStringQCOM;
+	glEnableDriverControlQCOM_client_proc_t glEnableDriverControlQCOM;
+	glDisableDriverControlQCOM_client_proc_t glDisableDriverControlQCOM;
+	glExtGetTexturesQCOM_client_proc_t glExtGetTexturesQCOM;
+	glExtGetBuffersQCOM_client_proc_t glExtGetBuffersQCOM;
+	glExtGetRenderbuffersQCOM_client_proc_t glExtGetRenderbuffersQCOM;
+	glExtGetFramebuffersQCOM_client_proc_t glExtGetFramebuffersQCOM;
+	glExtGetTexLevelParameterivQCOM_client_proc_t glExtGetTexLevelParameterivQCOM;
+	glExtTexObjectStateOverrideiQCOM_client_proc_t glExtTexObjectStateOverrideiQCOM;
+	glExtGetTexSubImageQCOM_client_proc_t glExtGetTexSubImageQCOM;
+	glExtGetBufferPointervQCOM_client_proc_t glExtGetBufferPointervQCOM;
+	glExtGetShadersQCOM_client_proc_t glExtGetShadersQCOM;
+	glExtGetProgramsQCOM_client_proc_t glExtGetProgramsQCOM;
+	glExtIsProgramBinaryQCOM_client_proc_t glExtIsProgramBinaryQCOM;
+	glExtGetProgramBinarySourceQCOM_client_proc_t glExtGetProgramBinarySourceQCOM;
+	glStartTilingQCOM_client_proc_t glStartTilingQCOM;
+	glEndTilingQCOM_client_proc_t glEndTilingQCOM;
+	//Accessors 
+	virtual glAlphaFunc_client_proc_t set_glAlphaFunc(glAlphaFunc_client_proc_t f) { glAlphaFunc_client_proc_t retval = glAlphaFunc; glAlphaFunc = f; return retval;}
+	virtual glClearColor_client_proc_t set_glClearColor(glClearColor_client_proc_t f) { glClearColor_client_proc_t retval = glClearColor; glClearColor = f; return retval;}
+	virtual glClearDepthf_client_proc_t set_glClearDepthf(glClearDepthf_client_proc_t f) { glClearDepthf_client_proc_t retval = glClearDepthf; glClearDepthf = f; return retval;}
+	virtual glClipPlanef_client_proc_t set_glClipPlanef(glClipPlanef_client_proc_t f) { glClipPlanef_client_proc_t retval = glClipPlanef; glClipPlanef = f; return retval;}
+	virtual glColor4f_client_proc_t set_glColor4f(glColor4f_client_proc_t f) { glColor4f_client_proc_t retval = glColor4f; glColor4f = f; return retval;}
+	virtual glDepthRangef_client_proc_t set_glDepthRangef(glDepthRangef_client_proc_t f) { glDepthRangef_client_proc_t retval = glDepthRangef; glDepthRangef = f; return retval;}
+	virtual glFogf_client_proc_t set_glFogf(glFogf_client_proc_t f) { glFogf_client_proc_t retval = glFogf; glFogf = f; return retval;}
+	virtual glFogfv_client_proc_t set_glFogfv(glFogfv_client_proc_t f) { glFogfv_client_proc_t retval = glFogfv; glFogfv = f; return retval;}
+	virtual glFrustumf_client_proc_t set_glFrustumf(glFrustumf_client_proc_t f) { glFrustumf_client_proc_t retval = glFrustumf; glFrustumf = f; return retval;}
+	virtual glGetClipPlanef_client_proc_t set_glGetClipPlanef(glGetClipPlanef_client_proc_t f) { glGetClipPlanef_client_proc_t retval = glGetClipPlanef; glGetClipPlanef = f; return retval;}
+	virtual glGetFloatv_client_proc_t set_glGetFloatv(glGetFloatv_client_proc_t f) { glGetFloatv_client_proc_t retval = glGetFloatv; glGetFloatv = f; return retval;}
+	virtual glGetLightfv_client_proc_t set_glGetLightfv(glGetLightfv_client_proc_t f) { glGetLightfv_client_proc_t retval = glGetLightfv; glGetLightfv = f; return retval;}
+	virtual glGetMaterialfv_client_proc_t set_glGetMaterialfv(glGetMaterialfv_client_proc_t f) { glGetMaterialfv_client_proc_t retval = glGetMaterialfv; glGetMaterialfv = f; return retval;}
+	virtual glGetTexEnvfv_client_proc_t set_glGetTexEnvfv(glGetTexEnvfv_client_proc_t f) { glGetTexEnvfv_client_proc_t retval = glGetTexEnvfv; glGetTexEnvfv = f; return retval;}
+	virtual glGetTexParameterfv_client_proc_t set_glGetTexParameterfv(glGetTexParameterfv_client_proc_t f) { glGetTexParameterfv_client_proc_t retval = glGetTexParameterfv; glGetTexParameterfv = f; return retval;}
+	virtual glLightModelf_client_proc_t set_glLightModelf(glLightModelf_client_proc_t f) { glLightModelf_client_proc_t retval = glLightModelf; glLightModelf = f; return retval;}
+	virtual glLightModelfv_client_proc_t set_glLightModelfv(glLightModelfv_client_proc_t f) { glLightModelfv_client_proc_t retval = glLightModelfv; glLightModelfv = f; return retval;}
+	virtual glLightf_client_proc_t set_glLightf(glLightf_client_proc_t f) { glLightf_client_proc_t retval = glLightf; glLightf = f; return retval;}
+	virtual glLightfv_client_proc_t set_glLightfv(glLightfv_client_proc_t f) { glLightfv_client_proc_t retval = glLightfv; glLightfv = f; return retval;}
+	virtual glLineWidth_client_proc_t set_glLineWidth(glLineWidth_client_proc_t f) { glLineWidth_client_proc_t retval = glLineWidth; glLineWidth = f; return retval;}
+	virtual glLoadMatrixf_client_proc_t set_glLoadMatrixf(glLoadMatrixf_client_proc_t f) { glLoadMatrixf_client_proc_t retval = glLoadMatrixf; glLoadMatrixf = f; return retval;}
+	virtual glMaterialf_client_proc_t set_glMaterialf(glMaterialf_client_proc_t f) { glMaterialf_client_proc_t retval = glMaterialf; glMaterialf = f; return retval;}
+	virtual glMaterialfv_client_proc_t set_glMaterialfv(glMaterialfv_client_proc_t f) { glMaterialfv_client_proc_t retval = glMaterialfv; glMaterialfv = f; return retval;}
+	virtual glMultMatrixf_client_proc_t set_glMultMatrixf(glMultMatrixf_client_proc_t f) { glMultMatrixf_client_proc_t retval = glMultMatrixf; glMultMatrixf = f; return retval;}
+	virtual glMultiTexCoord4f_client_proc_t set_glMultiTexCoord4f(glMultiTexCoord4f_client_proc_t f) { glMultiTexCoord4f_client_proc_t retval = glMultiTexCoord4f; glMultiTexCoord4f = f; return retval;}
+	virtual glNormal3f_client_proc_t set_glNormal3f(glNormal3f_client_proc_t f) { glNormal3f_client_proc_t retval = glNormal3f; glNormal3f = f; return retval;}
+	virtual glOrthof_client_proc_t set_glOrthof(glOrthof_client_proc_t f) { glOrthof_client_proc_t retval = glOrthof; glOrthof = f; return retval;}
+	virtual glPointParameterf_client_proc_t set_glPointParameterf(glPointParameterf_client_proc_t f) { glPointParameterf_client_proc_t retval = glPointParameterf; glPointParameterf = f; return retval;}
+	virtual glPointParameterfv_client_proc_t set_glPointParameterfv(glPointParameterfv_client_proc_t f) { glPointParameterfv_client_proc_t retval = glPointParameterfv; glPointParameterfv = f; return retval;}
+	virtual glPointSize_client_proc_t set_glPointSize(glPointSize_client_proc_t f) { glPointSize_client_proc_t retval = glPointSize; glPointSize = f; return retval;}
+	virtual glPolygonOffset_client_proc_t set_glPolygonOffset(glPolygonOffset_client_proc_t f) { glPolygonOffset_client_proc_t retval = glPolygonOffset; glPolygonOffset = f; return retval;}
+	virtual glRotatef_client_proc_t set_glRotatef(glRotatef_client_proc_t f) { glRotatef_client_proc_t retval = glRotatef; glRotatef = f; return retval;}
+	virtual glScalef_client_proc_t set_glScalef(glScalef_client_proc_t f) { glScalef_client_proc_t retval = glScalef; glScalef = f; return retval;}
+	virtual glTexEnvf_client_proc_t set_glTexEnvf(glTexEnvf_client_proc_t f) { glTexEnvf_client_proc_t retval = glTexEnvf; glTexEnvf = f; return retval;}
+	virtual glTexEnvfv_client_proc_t set_glTexEnvfv(glTexEnvfv_client_proc_t f) { glTexEnvfv_client_proc_t retval = glTexEnvfv; glTexEnvfv = f; return retval;}
+	virtual glTexParameterf_client_proc_t set_glTexParameterf(glTexParameterf_client_proc_t f) { glTexParameterf_client_proc_t retval = glTexParameterf; glTexParameterf = f; return retval;}
+	virtual glTexParameterfv_client_proc_t set_glTexParameterfv(glTexParameterfv_client_proc_t f) { glTexParameterfv_client_proc_t retval = glTexParameterfv; glTexParameterfv = f; return retval;}
+	virtual glTranslatef_client_proc_t set_glTranslatef(glTranslatef_client_proc_t f) { glTranslatef_client_proc_t retval = glTranslatef; glTranslatef = f; return retval;}
+	virtual glActiveTexture_client_proc_t set_glActiveTexture(glActiveTexture_client_proc_t f) { glActiveTexture_client_proc_t retval = glActiveTexture; glActiveTexture = f; return retval;}
+	virtual glAlphaFuncx_client_proc_t set_glAlphaFuncx(glAlphaFuncx_client_proc_t f) { glAlphaFuncx_client_proc_t retval = glAlphaFuncx; glAlphaFuncx = f; return retval;}
+	virtual glBindBuffer_client_proc_t set_glBindBuffer(glBindBuffer_client_proc_t f) { glBindBuffer_client_proc_t retval = glBindBuffer; glBindBuffer = f; return retval;}
+	virtual glBindTexture_client_proc_t set_glBindTexture(glBindTexture_client_proc_t f) { glBindTexture_client_proc_t retval = glBindTexture; glBindTexture = f; return retval;}
+	virtual glBlendFunc_client_proc_t set_glBlendFunc(glBlendFunc_client_proc_t f) { glBlendFunc_client_proc_t retval = glBlendFunc; glBlendFunc = f; return retval;}
+	virtual glBufferData_client_proc_t set_glBufferData(glBufferData_client_proc_t f) { glBufferData_client_proc_t retval = glBufferData; glBufferData = f; return retval;}
+	virtual glBufferSubData_client_proc_t set_glBufferSubData(glBufferSubData_client_proc_t f) { glBufferSubData_client_proc_t retval = glBufferSubData; glBufferSubData = f; return retval;}
+	virtual glClear_client_proc_t set_glClear(glClear_client_proc_t f) { glClear_client_proc_t retval = glClear; glClear = f; return retval;}
+	virtual glClearColorx_client_proc_t set_glClearColorx(glClearColorx_client_proc_t f) { glClearColorx_client_proc_t retval = glClearColorx; glClearColorx = f; return retval;}
+	virtual glClearDepthx_client_proc_t set_glClearDepthx(glClearDepthx_client_proc_t f) { glClearDepthx_client_proc_t retval = glClearDepthx; glClearDepthx = f; return retval;}
+	virtual glClearStencil_client_proc_t set_glClearStencil(glClearStencil_client_proc_t f) { glClearStencil_client_proc_t retval = glClearStencil; glClearStencil = f; return retval;}
+	virtual glClientActiveTexture_client_proc_t set_glClientActiveTexture(glClientActiveTexture_client_proc_t f) { glClientActiveTexture_client_proc_t retval = glClientActiveTexture; glClientActiveTexture = f; return retval;}
+	virtual glColor4ub_client_proc_t set_glColor4ub(glColor4ub_client_proc_t f) { glColor4ub_client_proc_t retval = glColor4ub; glColor4ub = f; return retval;}
+	virtual glColor4x_client_proc_t set_glColor4x(glColor4x_client_proc_t f) { glColor4x_client_proc_t retval = glColor4x; glColor4x = f; return retval;}
+	virtual glColorMask_client_proc_t set_glColorMask(glColorMask_client_proc_t f) { glColorMask_client_proc_t retval = glColorMask; glColorMask = f; return retval;}
+	virtual glColorPointer_client_proc_t set_glColorPointer(glColorPointer_client_proc_t f) { glColorPointer_client_proc_t retval = glColorPointer; glColorPointer = f; return retval;}
+	virtual glCompressedTexImage2D_client_proc_t set_glCompressedTexImage2D(glCompressedTexImage2D_client_proc_t f) { glCompressedTexImage2D_client_proc_t retval = glCompressedTexImage2D; glCompressedTexImage2D = f; return retval;}
+	virtual glCompressedTexSubImage2D_client_proc_t set_glCompressedTexSubImage2D(glCompressedTexSubImage2D_client_proc_t f) { glCompressedTexSubImage2D_client_proc_t retval = glCompressedTexSubImage2D; glCompressedTexSubImage2D = f; return retval;}
+	virtual glCopyTexImage2D_client_proc_t set_glCopyTexImage2D(glCopyTexImage2D_client_proc_t f) { glCopyTexImage2D_client_proc_t retval = glCopyTexImage2D; glCopyTexImage2D = f; return retval;}
+	virtual glCopyTexSubImage2D_client_proc_t set_glCopyTexSubImage2D(glCopyTexSubImage2D_client_proc_t f) { glCopyTexSubImage2D_client_proc_t retval = glCopyTexSubImage2D; glCopyTexSubImage2D = f; return retval;}
+	virtual glCullFace_client_proc_t set_glCullFace(glCullFace_client_proc_t f) { glCullFace_client_proc_t retval = glCullFace; glCullFace = f; return retval;}
+	virtual glDeleteBuffers_client_proc_t set_glDeleteBuffers(glDeleteBuffers_client_proc_t f) { glDeleteBuffers_client_proc_t retval = glDeleteBuffers; glDeleteBuffers = f; return retval;}
+	virtual glDeleteTextures_client_proc_t set_glDeleteTextures(glDeleteTextures_client_proc_t f) { glDeleteTextures_client_proc_t retval = glDeleteTextures; glDeleteTextures = f; return retval;}
+	virtual glDepthFunc_client_proc_t set_glDepthFunc(glDepthFunc_client_proc_t f) { glDepthFunc_client_proc_t retval = glDepthFunc; glDepthFunc = f; return retval;}
+	virtual glDepthMask_client_proc_t set_glDepthMask(glDepthMask_client_proc_t f) { glDepthMask_client_proc_t retval = glDepthMask; glDepthMask = f; return retval;}
+	virtual glDepthRangex_client_proc_t set_glDepthRangex(glDepthRangex_client_proc_t f) { glDepthRangex_client_proc_t retval = glDepthRangex; glDepthRangex = f; return retval;}
+	virtual glDisable_client_proc_t set_glDisable(glDisable_client_proc_t f) { glDisable_client_proc_t retval = glDisable; glDisable = f; return retval;}
+	virtual glDisableClientState_client_proc_t set_glDisableClientState(glDisableClientState_client_proc_t f) { glDisableClientState_client_proc_t retval = glDisableClientState; glDisableClientState = f; return retval;}
+	virtual glDrawArrays_client_proc_t set_glDrawArrays(glDrawArrays_client_proc_t f) { glDrawArrays_client_proc_t retval = glDrawArrays; glDrawArrays = f; return retval;}
+	virtual glDrawElements_client_proc_t set_glDrawElements(glDrawElements_client_proc_t f) { glDrawElements_client_proc_t retval = glDrawElements; glDrawElements = f; return retval;}
+	virtual glEnable_client_proc_t set_glEnable(glEnable_client_proc_t f) { glEnable_client_proc_t retval = glEnable; glEnable = f; return retval;}
+	virtual glEnableClientState_client_proc_t set_glEnableClientState(glEnableClientState_client_proc_t f) { glEnableClientState_client_proc_t retval = glEnableClientState; glEnableClientState = f; return retval;}
+	virtual glFinish_client_proc_t set_glFinish(glFinish_client_proc_t f) { glFinish_client_proc_t retval = glFinish; glFinish = f; return retval;}
+	virtual glFlush_client_proc_t set_glFlush(glFlush_client_proc_t f) { glFlush_client_proc_t retval = glFlush; glFlush = f; return retval;}
+	virtual glFogx_client_proc_t set_glFogx(glFogx_client_proc_t f) { glFogx_client_proc_t retval = glFogx; glFogx = f; return retval;}
+	virtual glFogxv_client_proc_t set_glFogxv(glFogxv_client_proc_t f) { glFogxv_client_proc_t retval = glFogxv; glFogxv = f; return retval;}
+	virtual glFrontFace_client_proc_t set_glFrontFace(glFrontFace_client_proc_t f) { glFrontFace_client_proc_t retval = glFrontFace; glFrontFace = f; return retval;}
+	virtual glFrustumx_client_proc_t set_glFrustumx(glFrustumx_client_proc_t f) { glFrustumx_client_proc_t retval = glFrustumx; glFrustumx = f; return retval;}
+	virtual glGetBooleanv_client_proc_t set_glGetBooleanv(glGetBooleanv_client_proc_t f) { glGetBooleanv_client_proc_t retval = glGetBooleanv; glGetBooleanv = f; return retval;}
+	virtual glGetBufferParameteriv_client_proc_t set_glGetBufferParameteriv(glGetBufferParameteriv_client_proc_t f) { glGetBufferParameteriv_client_proc_t retval = glGetBufferParameteriv; glGetBufferParameteriv = f; return retval;}
+	virtual glClipPlanex_client_proc_t set_glClipPlanex(glClipPlanex_client_proc_t f) { glClipPlanex_client_proc_t retval = glClipPlanex; glClipPlanex = f; return retval;}
+	virtual glGenBuffers_client_proc_t set_glGenBuffers(glGenBuffers_client_proc_t f) { glGenBuffers_client_proc_t retval = glGenBuffers; glGenBuffers = f; return retval;}
+	virtual glGenTextures_client_proc_t set_glGenTextures(glGenTextures_client_proc_t f) { glGenTextures_client_proc_t retval = glGenTextures; glGenTextures = f; return retval;}
+	virtual glGetError_client_proc_t set_glGetError(glGetError_client_proc_t f) { glGetError_client_proc_t retval = glGetError; glGetError = f; return retval;}
+	virtual glGetFixedv_client_proc_t set_glGetFixedv(glGetFixedv_client_proc_t f) { glGetFixedv_client_proc_t retval = glGetFixedv; glGetFixedv = f; return retval;}
+	virtual glGetIntegerv_client_proc_t set_glGetIntegerv(glGetIntegerv_client_proc_t f) { glGetIntegerv_client_proc_t retval = glGetIntegerv; glGetIntegerv = f; return retval;}
+	virtual glGetLightxv_client_proc_t set_glGetLightxv(glGetLightxv_client_proc_t f) { glGetLightxv_client_proc_t retval = glGetLightxv; glGetLightxv = f; return retval;}
+	virtual glGetMaterialxv_client_proc_t set_glGetMaterialxv(glGetMaterialxv_client_proc_t f) { glGetMaterialxv_client_proc_t retval = glGetMaterialxv; glGetMaterialxv = f; return retval;}
+	virtual glGetPointerv_client_proc_t set_glGetPointerv(glGetPointerv_client_proc_t f) { glGetPointerv_client_proc_t retval = glGetPointerv; glGetPointerv = f; return retval;}
+	virtual glGetString_client_proc_t set_glGetString(glGetString_client_proc_t f) { glGetString_client_proc_t retval = glGetString; glGetString = f; return retval;}
+	virtual glGetTexEnviv_client_proc_t set_glGetTexEnviv(glGetTexEnviv_client_proc_t f) { glGetTexEnviv_client_proc_t retval = glGetTexEnviv; glGetTexEnviv = f; return retval;}
+	virtual glGetTexEnvxv_client_proc_t set_glGetTexEnvxv(glGetTexEnvxv_client_proc_t f) { glGetTexEnvxv_client_proc_t retval = glGetTexEnvxv; glGetTexEnvxv = f; return retval;}
+	virtual glGetTexParameteriv_client_proc_t set_glGetTexParameteriv(glGetTexParameteriv_client_proc_t f) { glGetTexParameteriv_client_proc_t retval = glGetTexParameteriv; glGetTexParameteriv = f; return retval;}
+	virtual glGetTexParameterxv_client_proc_t set_glGetTexParameterxv(glGetTexParameterxv_client_proc_t f) { glGetTexParameterxv_client_proc_t retval = glGetTexParameterxv; glGetTexParameterxv = f; return retval;}
+	virtual glHint_client_proc_t set_glHint(glHint_client_proc_t f) { glHint_client_proc_t retval = glHint; glHint = f; return retval;}
+	virtual glIsBuffer_client_proc_t set_glIsBuffer(glIsBuffer_client_proc_t f) { glIsBuffer_client_proc_t retval = glIsBuffer; glIsBuffer = f; return retval;}
+	virtual glIsEnabled_client_proc_t set_glIsEnabled(glIsEnabled_client_proc_t f) { glIsEnabled_client_proc_t retval = glIsEnabled; glIsEnabled = f; return retval;}
+	virtual glIsTexture_client_proc_t set_glIsTexture(glIsTexture_client_proc_t f) { glIsTexture_client_proc_t retval = glIsTexture; glIsTexture = f; return retval;}
+	virtual glLightModelx_client_proc_t set_glLightModelx(glLightModelx_client_proc_t f) { glLightModelx_client_proc_t retval = glLightModelx; glLightModelx = f; return retval;}
+	virtual glLightModelxv_client_proc_t set_glLightModelxv(glLightModelxv_client_proc_t f) { glLightModelxv_client_proc_t retval = glLightModelxv; glLightModelxv = f; return retval;}
+	virtual glLightx_client_proc_t set_glLightx(glLightx_client_proc_t f) { glLightx_client_proc_t retval = glLightx; glLightx = f; return retval;}
+	virtual glLightxv_client_proc_t set_glLightxv(glLightxv_client_proc_t f) { glLightxv_client_proc_t retval = glLightxv; glLightxv = f; return retval;}
+	virtual glLineWidthx_client_proc_t set_glLineWidthx(glLineWidthx_client_proc_t f) { glLineWidthx_client_proc_t retval = glLineWidthx; glLineWidthx = f; return retval;}
+	virtual glLoadIdentity_client_proc_t set_glLoadIdentity(glLoadIdentity_client_proc_t f) { glLoadIdentity_client_proc_t retval = glLoadIdentity; glLoadIdentity = f; return retval;}
+	virtual glLoadMatrixx_client_proc_t set_glLoadMatrixx(glLoadMatrixx_client_proc_t f) { glLoadMatrixx_client_proc_t retval = glLoadMatrixx; glLoadMatrixx = f; return retval;}
+	virtual glLogicOp_client_proc_t set_glLogicOp(glLogicOp_client_proc_t f) { glLogicOp_client_proc_t retval = glLogicOp; glLogicOp = f; return retval;}
+	virtual glMaterialx_client_proc_t set_glMaterialx(glMaterialx_client_proc_t f) { glMaterialx_client_proc_t retval = glMaterialx; glMaterialx = f; return retval;}
+	virtual glMaterialxv_client_proc_t set_glMaterialxv(glMaterialxv_client_proc_t f) { glMaterialxv_client_proc_t retval = glMaterialxv; glMaterialxv = f; return retval;}
+	virtual glMatrixMode_client_proc_t set_glMatrixMode(glMatrixMode_client_proc_t f) { glMatrixMode_client_proc_t retval = glMatrixMode; glMatrixMode = f; return retval;}
+	virtual glMultMatrixx_client_proc_t set_glMultMatrixx(glMultMatrixx_client_proc_t f) { glMultMatrixx_client_proc_t retval = glMultMatrixx; glMultMatrixx = f; return retval;}
+	virtual glMultiTexCoord4x_client_proc_t set_glMultiTexCoord4x(glMultiTexCoord4x_client_proc_t f) { glMultiTexCoord4x_client_proc_t retval = glMultiTexCoord4x; glMultiTexCoord4x = f; return retval;}
+	virtual glNormal3x_client_proc_t set_glNormal3x(glNormal3x_client_proc_t f) { glNormal3x_client_proc_t retval = glNormal3x; glNormal3x = f; return retval;}
+	virtual glNormalPointer_client_proc_t set_glNormalPointer(glNormalPointer_client_proc_t f) { glNormalPointer_client_proc_t retval = glNormalPointer; glNormalPointer = f; return retval;}
+	virtual glOrthox_client_proc_t set_glOrthox(glOrthox_client_proc_t f) { glOrthox_client_proc_t retval = glOrthox; glOrthox = f; return retval;}
+	virtual glPixelStorei_client_proc_t set_glPixelStorei(glPixelStorei_client_proc_t f) { glPixelStorei_client_proc_t retval = glPixelStorei; glPixelStorei = f; return retval;}
+	virtual glPointParameterx_client_proc_t set_glPointParameterx(glPointParameterx_client_proc_t f) { glPointParameterx_client_proc_t retval = glPointParameterx; glPointParameterx = f; return retval;}
+	virtual glPointParameterxv_client_proc_t set_glPointParameterxv(glPointParameterxv_client_proc_t f) { glPointParameterxv_client_proc_t retval = glPointParameterxv; glPointParameterxv = f; return retval;}
+	virtual glPointSizex_client_proc_t set_glPointSizex(glPointSizex_client_proc_t f) { glPointSizex_client_proc_t retval = glPointSizex; glPointSizex = f; return retval;}
+	virtual glPolygonOffsetx_client_proc_t set_glPolygonOffsetx(glPolygonOffsetx_client_proc_t f) { glPolygonOffsetx_client_proc_t retval = glPolygonOffsetx; glPolygonOffsetx = f; return retval;}
+	virtual glPopMatrix_client_proc_t set_glPopMatrix(glPopMatrix_client_proc_t f) { glPopMatrix_client_proc_t retval = glPopMatrix; glPopMatrix = f; return retval;}
+	virtual glPushMatrix_client_proc_t set_glPushMatrix(glPushMatrix_client_proc_t f) { glPushMatrix_client_proc_t retval = glPushMatrix; glPushMatrix = f; return retval;}
+	virtual glReadPixels_client_proc_t set_glReadPixels(glReadPixels_client_proc_t f) { glReadPixels_client_proc_t retval = glReadPixels; glReadPixels = f; return retval;}
+	virtual glRotatex_client_proc_t set_glRotatex(glRotatex_client_proc_t f) { glRotatex_client_proc_t retval = glRotatex; glRotatex = f; return retval;}
+	virtual glSampleCoverage_client_proc_t set_glSampleCoverage(glSampleCoverage_client_proc_t f) { glSampleCoverage_client_proc_t retval = glSampleCoverage; glSampleCoverage = f; return retval;}
+	virtual glSampleCoveragex_client_proc_t set_glSampleCoveragex(glSampleCoveragex_client_proc_t f) { glSampleCoveragex_client_proc_t retval = glSampleCoveragex; glSampleCoveragex = f; return retval;}
+	virtual glScalex_client_proc_t set_glScalex(glScalex_client_proc_t f) { glScalex_client_proc_t retval = glScalex; glScalex = f; return retval;}
+	virtual glScissor_client_proc_t set_glScissor(glScissor_client_proc_t f) { glScissor_client_proc_t retval = glScissor; glScissor = f; return retval;}
+	virtual glShadeModel_client_proc_t set_glShadeModel(glShadeModel_client_proc_t f) { glShadeModel_client_proc_t retval = glShadeModel; glShadeModel = f; return retval;}
+	virtual glStencilFunc_client_proc_t set_glStencilFunc(glStencilFunc_client_proc_t f) { glStencilFunc_client_proc_t retval = glStencilFunc; glStencilFunc = f; return retval;}
+	virtual glStencilMask_client_proc_t set_glStencilMask(glStencilMask_client_proc_t f) { glStencilMask_client_proc_t retval = glStencilMask; glStencilMask = f; return retval;}
+	virtual glStencilOp_client_proc_t set_glStencilOp(glStencilOp_client_proc_t f) { glStencilOp_client_proc_t retval = glStencilOp; glStencilOp = f; return retval;}
+	virtual glTexCoordPointer_client_proc_t set_glTexCoordPointer(glTexCoordPointer_client_proc_t f) { glTexCoordPointer_client_proc_t retval = glTexCoordPointer; glTexCoordPointer = f; return retval;}
+	virtual glTexEnvi_client_proc_t set_glTexEnvi(glTexEnvi_client_proc_t f) { glTexEnvi_client_proc_t retval = glTexEnvi; glTexEnvi = f; return retval;}
+	virtual glTexEnvx_client_proc_t set_glTexEnvx(glTexEnvx_client_proc_t f) { glTexEnvx_client_proc_t retval = glTexEnvx; glTexEnvx = f; return retval;}
+	virtual glTexEnviv_client_proc_t set_glTexEnviv(glTexEnviv_client_proc_t f) { glTexEnviv_client_proc_t retval = glTexEnviv; glTexEnviv = f; return retval;}
+	virtual glTexEnvxv_client_proc_t set_glTexEnvxv(glTexEnvxv_client_proc_t f) { glTexEnvxv_client_proc_t retval = glTexEnvxv; glTexEnvxv = f; return retval;}
+	virtual glTexImage2D_client_proc_t set_glTexImage2D(glTexImage2D_client_proc_t f) { glTexImage2D_client_proc_t retval = glTexImage2D; glTexImage2D = f; return retval;}
+	virtual glTexParameteri_client_proc_t set_glTexParameteri(glTexParameteri_client_proc_t f) { glTexParameteri_client_proc_t retval = glTexParameteri; glTexParameteri = f; return retval;}
+	virtual glTexParameterx_client_proc_t set_glTexParameterx(glTexParameterx_client_proc_t f) { glTexParameterx_client_proc_t retval = glTexParameterx; glTexParameterx = f; return retval;}
+	virtual glTexParameteriv_client_proc_t set_glTexParameteriv(glTexParameteriv_client_proc_t f) { glTexParameteriv_client_proc_t retval = glTexParameteriv; glTexParameteriv = f; return retval;}
+	virtual glTexParameterxv_client_proc_t set_glTexParameterxv(glTexParameterxv_client_proc_t f) { glTexParameterxv_client_proc_t retval = glTexParameterxv; glTexParameterxv = f; return retval;}
+	virtual glTexSubImage2D_client_proc_t set_glTexSubImage2D(glTexSubImage2D_client_proc_t f) { glTexSubImage2D_client_proc_t retval = glTexSubImage2D; glTexSubImage2D = f; return retval;}
+	virtual glTranslatex_client_proc_t set_glTranslatex(glTranslatex_client_proc_t f) { glTranslatex_client_proc_t retval = glTranslatex; glTranslatex = f; return retval;}
+	virtual glVertexPointer_client_proc_t set_glVertexPointer(glVertexPointer_client_proc_t f) { glVertexPointer_client_proc_t retval = glVertexPointer; glVertexPointer = f; return retval;}
+	virtual glViewport_client_proc_t set_glViewport(glViewport_client_proc_t f) { glViewport_client_proc_t retval = glViewport; glViewport = f; return retval;}
+	virtual glPointSizePointerOES_client_proc_t set_glPointSizePointerOES(glPointSizePointerOES_client_proc_t f) { glPointSizePointerOES_client_proc_t retval = glPointSizePointerOES; glPointSizePointerOES = f; return retval;}
+	virtual glVertexPointerOffset_client_proc_t set_glVertexPointerOffset(glVertexPointerOffset_client_proc_t f) { glVertexPointerOffset_client_proc_t retval = glVertexPointerOffset; glVertexPointerOffset = f; return retval;}
+	virtual glColorPointerOffset_client_proc_t set_glColorPointerOffset(glColorPointerOffset_client_proc_t f) { glColorPointerOffset_client_proc_t retval = glColorPointerOffset; glColorPointerOffset = f; return retval;}
+	virtual glNormalPointerOffset_client_proc_t set_glNormalPointerOffset(glNormalPointerOffset_client_proc_t f) { glNormalPointerOffset_client_proc_t retval = glNormalPointerOffset; glNormalPointerOffset = f; return retval;}
+	virtual glPointSizePointerOffset_client_proc_t set_glPointSizePointerOffset(glPointSizePointerOffset_client_proc_t f) { glPointSizePointerOffset_client_proc_t retval = glPointSizePointerOffset; glPointSizePointerOffset = f; return retval;}
+	virtual glTexCoordPointerOffset_client_proc_t set_glTexCoordPointerOffset(glTexCoordPointerOffset_client_proc_t f) { glTexCoordPointerOffset_client_proc_t retval = glTexCoordPointerOffset; glTexCoordPointerOffset = f; return retval;}
+	virtual glWeightPointerOffset_client_proc_t set_glWeightPointerOffset(glWeightPointerOffset_client_proc_t f) { glWeightPointerOffset_client_proc_t retval = glWeightPointerOffset; glWeightPointerOffset = f; return retval;}
+	virtual glMatrixIndexPointerOffset_client_proc_t set_glMatrixIndexPointerOffset(glMatrixIndexPointerOffset_client_proc_t f) { glMatrixIndexPointerOffset_client_proc_t retval = glMatrixIndexPointerOffset; glMatrixIndexPointerOffset = f; return retval;}
+	virtual glVertexPointerData_client_proc_t set_glVertexPointerData(glVertexPointerData_client_proc_t f) { glVertexPointerData_client_proc_t retval = glVertexPointerData; glVertexPointerData = f; return retval;}
+	virtual glColorPointerData_client_proc_t set_glColorPointerData(glColorPointerData_client_proc_t f) { glColorPointerData_client_proc_t retval = glColorPointerData; glColorPointerData = f; return retval;}
+	virtual glNormalPointerData_client_proc_t set_glNormalPointerData(glNormalPointerData_client_proc_t f) { glNormalPointerData_client_proc_t retval = glNormalPointerData; glNormalPointerData = f; return retval;}
+	virtual glTexCoordPointerData_client_proc_t set_glTexCoordPointerData(glTexCoordPointerData_client_proc_t f) { glTexCoordPointerData_client_proc_t retval = glTexCoordPointerData; glTexCoordPointerData = f; return retval;}
+	virtual glPointSizePointerData_client_proc_t set_glPointSizePointerData(glPointSizePointerData_client_proc_t f) { glPointSizePointerData_client_proc_t retval = glPointSizePointerData; glPointSizePointerData = f; return retval;}
+	virtual glWeightPointerData_client_proc_t set_glWeightPointerData(glWeightPointerData_client_proc_t f) { glWeightPointerData_client_proc_t retval = glWeightPointerData; glWeightPointerData = f; return retval;}
+	virtual glMatrixIndexPointerData_client_proc_t set_glMatrixIndexPointerData(glMatrixIndexPointerData_client_proc_t f) { glMatrixIndexPointerData_client_proc_t retval = glMatrixIndexPointerData; glMatrixIndexPointerData = f; return retval;}
+	virtual glDrawElementsOffset_client_proc_t set_glDrawElementsOffset(glDrawElementsOffset_client_proc_t f) { glDrawElementsOffset_client_proc_t retval = glDrawElementsOffset; glDrawElementsOffset = f; return retval;}
+	virtual glDrawElementsData_client_proc_t set_glDrawElementsData(glDrawElementsData_client_proc_t f) { glDrawElementsData_client_proc_t retval = glDrawElementsData; glDrawElementsData = f; return retval;}
+	virtual glGetCompressedTextureFormats_client_proc_t set_glGetCompressedTextureFormats(glGetCompressedTextureFormats_client_proc_t f) { glGetCompressedTextureFormats_client_proc_t retval = glGetCompressedTextureFormats; glGetCompressedTextureFormats = f; return retval;}
+	virtual glFinishRoundTrip_client_proc_t set_glFinishRoundTrip(glFinishRoundTrip_client_proc_t f) { glFinishRoundTrip_client_proc_t retval = glFinishRoundTrip; glFinishRoundTrip = f; return retval;}
+	virtual glBlendEquationSeparateOES_client_proc_t set_glBlendEquationSeparateOES(glBlendEquationSeparateOES_client_proc_t f) { glBlendEquationSeparateOES_client_proc_t retval = glBlendEquationSeparateOES; glBlendEquationSeparateOES = f; return retval;}
+	virtual glBlendFuncSeparateOES_client_proc_t set_glBlendFuncSeparateOES(glBlendFuncSeparateOES_client_proc_t f) { glBlendFuncSeparateOES_client_proc_t retval = glBlendFuncSeparateOES; glBlendFuncSeparateOES = f; return retval;}
+	virtual glBlendEquationOES_client_proc_t set_glBlendEquationOES(glBlendEquationOES_client_proc_t f) { glBlendEquationOES_client_proc_t retval = glBlendEquationOES; glBlendEquationOES = f; return retval;}
+	virtual glDrawTexsOES_client_proc_t set_glDrawTexsOES(glDrawTexsOES_client_proc_t f) { glDrawTexsOES_client_proc_t retval = glDrawTexsOES; glDrawTexsOES = f; return retval;}
+	virtual glDrawTexiOES_client_proc_t set_glDrawTexiOES(glDrawTexiOES_client_proc_t f) { glDrawTexiOES_client_proc_t retval = glDrawTexiOES; glDrawTexiOES = f; return retval;}
+	virtual glDrawTexxOES_client_proc_t set_glDrawTexxOES(glDrawTexxOES_client_proc_t f) { glDrawTexxOES_client_proc_t retval = glDrawTexxOES; glDrawTexxOES = f; return retval;}
+	virtual glDrawTexsvOES_client_proc_t set_glDrawTexsvOES(glDrawTexsvOES_client_proc_t f) { glDrawTexsvOES_client_proc_t retval = glDrawTexsvOES; glDrawTexsvOES = f; return retval;}
+	virtual glDrawTexivOES_client_proc_t set_glDrawTexivOES(glDrawTexivOES_client_proc_t f) { glDrawTexivOES_client_proc_t retval = glDrawTexivOES; glDrawTexivOES = f; return retval;}
+	virtual glDrawTexxvOES_client_proc_t set_glDrawTexxvOES(glDrawTexxvOES_client_proc_t f) { glDrawTexxvOES_client_proc_t retval = glDrawTexxvOES; glDrawTexxvOES = f; return retval;}
+	virtual glDrawTexfOES_client_proc_t set_glDrawTexfOES(glDrawTexfOES_client_proc_t f) { glDrawTexfOES_client_proc_t retval = glDrawTexfOES; glDrawTexfOES = f; return retval;}
+	virtual glDrawTexfvOES_client_proc_t set_glDrawTexfvOES(glDrawTexfvOES_client_proc_t f) { glDrawTexfvOES_client_proc_t retval = glDrawTexfvOES; glDrawTexfvOES = f; return retval;}
+	virtual glEGLImageTargetTexture2DOES_client_proc_t set_glEGLImageTargetTexture2DOES(glEGLImageTargetTexture2DOES_client_proc_t f) { glEGLImageTargetTexture2DOES_client_proc_t retval = glEGLImageTargetTexture2DOES; glEGLImageTargetTexture2DOES = f; return retval;}
+	virtual glEGLImageTargetRenderbufferStorageOES_client_proc_t set_glEGLImageTargetRenderbufferStorageOES(glEGLImageTargetRenderbufferStorageOES_client_proc_t f) { glEGLImageTargetRenderbufferStorageOES_client_proc_t retval = glEGLImageTargetRenderbufferStorageOES; glEGLImageTargetRenderbufferStorageOES = f; return retval;}
+	virtual glAlphaFuncxOES_client_proc_t set_glAlphaFuncxOES(glAlphaFuncxOES_client_proc_t f) { glAlphaFuncxOES_client_proc_t retval = glAlphaFuncxOES; glAlphaFuncxOES = f; return retval;}
+	virtual glClearColorxOES_client_proc_t set_glClearColorxOES(glClearColorxOES_client_proc_t f) { glClearColorxOES_client_proc_t retval = glClearColorxOES; glClearColorxOES = f; return retval;}
+	virtual glClearDepthxOES_client_proc_t set_glClearDepthxOES(glClearDepthxOES_client_proc_t f) { glClearDepthxOES_client_proc_t retval = glClearDepthxOES; glClearDepthxOES = f; return retval;}
+	virtual glClipPlanexOES_client_proc_t set_glClipPlanexOES(glClipPlanexOES_client_proc_t f) { glClipPlanexOES_client_proc_t retval = glClipPlanexOES; glClipPlanexOES = f; return retval;}
+	virtual glClipPlanexIMG_client_proc_t set_glClipPlanexIMG(glClipPlanexIMG_client_proc_t f) { glClipPlanexIMG_client_proc_t retval = glClipPlanexIMG; glClipPlanexIMG = f; return retval;}
+	virtual glColor4xOES_client_proc_t set_glColor4xOES(glColor4xOES_client_proc_t f) { glColor4xOES_client_proc_t retval = glColor4xOES; glColor4xOES = f; return retval;}
+	virtual glDepthRangexOES_client_proc_t set_glDepthRangexOES(glDepthRangexOES_client_proc_t f) { glDepthRangexOES_client_proc_t retval = glDepthRangexOES; glDepthRangexOES = f; return retval;}
+	virtual glFogxOES_client_proc_t set_glFogxOES(glFogxOES_client_proc_t f) { glFogxOES_client_proc_t retval = glFogxOES; glFogxOES = f; return retval;}
+	virtual glFogxvOES_client_proc_t set_glFogxvOES(glFogxvOES_client_proc_t f) { glFogxvOES_client_proc_t retval = glFogxvOES; glFogxvOES = f; return retval;}
+	virtual glFrustumxOES_client_proc_t set_glFrustumxOES(glFrustumxOES_client_proc_t f) { glFrustumxOES_client_proc_t retval = glFrustumxOES; glFrustumxOES = f; return retval;}
+	virtual glGetClipPlanexOES_client_proc_t set_glGetClipPlanexOES(glGetClipPlanexOES_client_proc_t f) { glGetClipPlanexOES_client_proc_t retval = glGetClipPlanexOES; glGetClipPlanexOES = f; return retval;}
+	virtual glGetClipPlanex_client_proc_t set_glGetClipPlanex(glGetClipPlanex_client_proc_t f) { glGetClipPlanex_client_proc_t retval = glGetClipPlanex; glGetClipPlanex = f; return retval;}
+	virtual glGetFixedvOES_client_proc_t set_glGetFixedvOES(glGetFixedvOES_client_proc_t f) { glGetFixedvOES_client_proc_t retval = glGetFixedvOES; glGetFixedvOES = f; return retval;}
+	virtual glGetLightxvOES_client_proc_t set_glGetLightxvOES(glGetLightxvOES_client_proc_t f) { glGetLightxvOES_client_proc_t retval = glGetLightxvOES; glGetLightxvOES = f; return retval;}
+	virtual glGetMaterialxvOES_client_proc_t set_glGetMaterialxvOES(glGetMaterialxvOES_client_proc_t f) { glGetMaterialxvOES_client_proc_t retval = glGetMaterialxvOES; glGetMaterialxvOES = f; return retval;}
+	virtual glGetTexEnvxvOES_client_proc_t set_glGetTexEnvxvOES(glGetTexEnvxvOES_client_proc_t f) { glGetTexEnvxvOES_client_proc_t retval = glGetTexEnvxvOES; glGetTexEnvxvOES = f; return retval;}
+	virtual glGetTexParameterxvOES_client_proc_t set_glGetTexParameterxvOES(glGetTexParameterxvOES_client_proc_t f) { glGetTexParameterxvOES_client_proc_t retval = glGetTexParameterxvOES; glGetTexParameterxvOES = f; return retval;}
+	virtual glLightModelxOES_client_proc_t set_glLightModelxOES(glLightModelxOES_client_proc_t f) { glLightModelxOES_client_proc_t retval = glLightModelxOES; glLightModelxOES = f; return retval;}
+	virtual glLightModelxvOES_client_proc_t set_glLightModelxvOES(glLightModelxvOES_client_proc_t f) { glLightModelxvOES_client_proc_t retval = glLightModelxvOES; glLightModelxvOES = f; return retval;}
+	virtual glLightxOES_client_proc_t set_glLightxOES(glLightxOES_client_proc_t f) { glLightxOES_client_proc_t retval = glLightxOES; glLightxOES = f; return retval;}
+	virtual glLightxvOES_client_proc_t set_glLightxvOES(glLightxvOES_client_proc_t f) { glLightxvOES_client_proc_t retval = glLightxvOES; glLightxvOES = f; return retval;}
+	virtual glLineWidthxOES_client_proc_t set_glLineWidthxOES(glLineWidthxOES_client_proc_t f) { glLineWidthxOES_client_proc_t retval = glLineWidthxOES; glLineWidthxOES = f; return retval;}
+	virtual glLoadMatrixxOES_client_proc_t set_glLoadMatrixxOES(glLoadMatrixxOES_client_proc_t f) { glLoadMatrixxOES_client_proc_t retval = glLoadMatrixxOES; glLoadMatrixxOES = f; return retval;}
+	virtual glMaterialxOES_client_proc_t set_glMaterialxOES(glMaterialxOES_client_proc_t f) { glMaterialxOES_client_proc_t retval = glMaterialxOES; glMaterialxOES = f; return retval;}
+	virtual glMaterialxvOES_client_proc_t set_glMaterialxvOES(glMaterialxvOES_client_proc_t f) { glMaterialxvOES_client_proc_t retval = glMaterialxvOES; glMaterialxvOES = f; return retval;}
+	virtual glMultMatrixxOES_client_proc_t set_glMultMatrixxOES(glMultMatrixxOES_client_proc_t f) { glMultMatrixxOES_client_proc_t retval = glMultMatrixxOES; glMultMatrixxOES = f; return retval;}
+	virtual glMultiTexCoord4xOES_client_proc_t set_glMultiTexCoord4xOES(glMultiTexCoord4xOES_client_proc_t f) { glMultiTexCoord4xOES_client_proc_t retval = glMultiTexCoord4xOES; glMultiTexCoord4xOES = f; return retval;}
+	virtual glNormal3xOES_client_proc_t set_glNormal3xOES(glNormal3xOES_client_proc_t f) { glNormal3xOES_client_proc_t retval = glNormal3xOES; glNormal3xOES = f; return retval;}
+	virtual glOrthoxOES_client_proc_t set_glOrthoxOES(glOrthoxOES_client_proc_t f) { glOrthoxOES_client_proc_t retval = glOrthoxOES; glOrthoxOES = f; return retval;}
+	virtual glPointParameterxOES_client_proc_t set_glPointParameterxOES(glPointParameterxOES_client_proc_t f) { glPointParameterxOES_client_proc_t retval = glPointParameterxOES; glPointParameterxOES = f; return retval;}
+	virtual glPointParameterxvOES_client_proc_t set_glPointParameterxvOES(glPointParameterxvOES_client_proc_t f) { glPointParameterxvOES_client_proc_t retval = glPointParameterxvOES; glPointParameterxvOES = f; return retval;}
+	virtual glPointSizexOES_client_proc_t set_glPointSizexOES(glPointSizexOES_client_proc_t f) { glPointSizexOES_client_proc_t retval = glPointSizexOES; glPointSizexOES = f; return retval;}
+	virtual glPolygonOffsetxOES_client_proc_t set_glPolygonOffsetxOES(glPolygonOffsetxOES_client_proc_t f) { glPolygonOffsetxOES_client_proc_t retval = glPolygonOffsetxOES; glPolygonOffsetxOES = f; return retval;}
+	virtual glRotatexOES_client_proc_t set_glRotatexOES(glRotatexOES_client_proc_t f) { glRotatexOES_client_proc_t retval = glRotatexOES; glRotatexOES = f; return retval;}
+	virtual glSampleCoveragexOES_client_proc_t set_glSampleCoveragexOES(glSampleCoveragexOES_client_proc_t f) { glSampleCoveragexOES_client_proc_t retval = glSampleCoveragexOES; glSampleCoveragexOES = f; return retval;}
+	virtual glScalexOES_client_proc_t set_glScalexOES(glScalexOES_client_proc_t f) { glScalexOES_client_proc_t retval = glScalexOES; glScalexOES = f; return retval;}
+	virtual glTexEnvxOES_client_proc_t set_glTexEnvxOES(glTexEnvxOES_client_proc_t f) { glTexEnvxOES_client_proc_t retval = glTexEnvxOES; glTexEnvxOES = f; return retval;}
+	virtual glTexEnvxvOES_client_proc_t set_glTexEnvxvOES(glTexEnvxvOES_client_proc_t f) { glTexEnvxvOES_client_proc_t retval = glTexEnvxvOES; glTexEnvxvOES = f; return retval;}
+	virtual glTexParameterxOES_client_proc_t set_glTexParameterxOES(glTexParameterxOES_client_proc_t f) { glTexParameterxOES_client_proc_t retval = glTexParameterxOES; glTexParameterxOES = f; return retval;}
+	virtual glTexParameterxvOES_client_proc_t set_glTexParameterxvOES(glTexParameterxvOES_client_proc_t f) { glTexParameterxvOES_client_proc_t retval = glTexParameterxvOES; glTexParameterxvOES = f; return retval;}
+	virtual glTranslatexOES_client_proc_t set_glTranslatexOES(glTranslatexOES_client_proc_t f) { glTranslatexOES_client_proc_t retval = glTranslatexOES; glTranslatexOES = f; return retval;}
+	virtual glIsRenderbufferOES_client_proc_t set_glIsRenderbufferOES(glIsRenderbufferOES_client_proc_t f) { glIsRenderbufferOES_client_proc_t retval = glIsRenderbufferOES; glIsRenderbufferOES = f; return retval;}
+	virtual glBindRenderbufferOES_client_proc_t set_glBindRenderbufferOES(glBindRenderbufferOES_client_proc_t f) { glBindRenderbufferOES_client_proc_t retval = glBindRenderbufferOES; glBindRenderbufferOES = f; return retval;}
+	virtual glDeleteRenderbuffersOES_client_proc_t set_glDeleteRenderbuffersOES(glDeleteRenderbuffersOES_client_proc_t f) { glDeleteRenderbuffersOES_client_proc_t retval = glDeleteRenderbuffersOES; glDeleteRenderbuffersOES = f; return retval;}
+	virtual glGenRenderbuffersOES_client_proc_t set_glGenRenderbuffersOES(glGenRenderbuffersOES_client_proc_t f) { glGenRenderbuffersOES_client_proc_t retval = glGenRenderbuffersOES; glGenRenderbuffersOES = f; return retval;}
+	virtual glRenderbufferStorageOES_client_proc_t set_glRenderbufferStorageOES(glRenderbufferStorageOES_client_proc_t f) { glRenderbufferStorageOES_client_proc_t retval = glRenderbufferStorageOES; glRenderbufferStorageOES = f; return retval;}
+	virtual glGetRenderbufferParameterivOES_client_proc_t set_glGetRenderbufferParameterivOES(glGetRenderbufferParameterivOES_client_proc_t f) { glGetRenderbufferParameterivOES_client_proc_t retval = glGetRenderbufferParameterivOES; glGetRenderbufferParameterivOES = f; return retval;}
+	virtual glIsFramebufferOES_client_proc_t set_glIsFramebufferOES(glIsFramebufferOES_client_proc_t f) { glIsFramebufferOES_client_proc_t retval = glIsFramebufferOES; glIsFramebufferOES = f; return retval;}
+	virtual glBindFramebufferOES_client_proc_t set_glBindFramebufferOES(glBindFramebufferOES_client_proc_t f) { glBindFramebufferOES_client_proc_t retval = glBindFramebufferOES; glBindFramebufferOES = f; return retval;}
+	virtual glDeleteFramebuffersOES_client_proc_t set_glDeleteFramebuffersOES(glDeleteFramebuffersOES_client_proc_t f) { glDeleteFramebuffersOES_client_proc_t retval = glDeleteFramebuffersOES; glDeleteFramebuffersOES = f; return retval;}
+	virtual glGenFramebuffersOES_client_proc_t set_glGenFramebuffersOES(glGenFramebuffersOES_client_proc_t f) { glGenFramebuffersOES_client_proc_t retval = glGenFramebuffersOES; glGenFramebuffersOES = f; return retval;}
+	virtual glCheckFramebufferStatusOES_client_proc_t set_glCheckFramebufferStatusOES(glCheckFramebufferStatusOES_client_proc_t f) { glCheckFramebufferStatusOES_client_proc_t retval = glCheckFramebufferStatusOES; glCheckFramebufferStatusOES = f; return retval;}
+	virtual glFramebufferRenderbufferOES_client_proc_t set_glFramebufferRenderbufferOES(glFramebufferRenderbufferOES_client_proc_t f) { glFramebufferRenderbufferOES_client_proc_t retval = glFramebufferRenderbufferOES; glFramebufferRenderbufferOES = f; return retval;}
+	virtual glFramebufferTexture2DOES_client_proc_t set_glFramebufferTexture2DOES(glFramebufferTexture2DOES_client_proc_t f) { glFramebufferTexture2DOES_client_proc_t retval = glFramebufferTexture2DOES; glFramebufferTexture2DOES = f; return retval;}
+	virtual glGetFramebufferAttachmentParameterivOES_client_proc_t set_glGetFramebufferAttachmentParameterivOES(glGetFramebufferAttachmentParameterivOES_client_proc_t f) { glGetFramebufferAttachmentParameterivOES_client_proc_t retval = glGetFramebufferAttachmentParameterivOES; glGetFramebufferAttachmentParameterivOES = f; return retval;}
+	virtual glGenerateMipmapOES_client_proc_t set_glGenerateMipmapOES(glGenerateMipmapOES_client_proc_t f) { glGenerateMipmapOES_client_proc_t retval = glGenerateMipmapOES; glGenerateMipmapOES = f; return retval;}
+	virtual glMapBufferOES_client_proc_t set_glMapBufferOES(glMapBufferOES_client_proc_t f) { glMapBufferOES_client_proc_t retval = glMapBufferOES; glMapBufferOES = f; return retval;}
+	virtual glUnmapBufferOES_client_proc_t set_glUnmapBufferOES(glUnmapBufferOES_client_proc_t f) { glUnmapBufferOES_client_proc_t retval = glUnmapBufferOES; glUnmapBufferOES = f; return retval;}
+	virtual glGetBufferPointervOES_client_proc_t set_glGetBufferPointervOES(glGetBufferPointervOES_client_proc_t f) { glGetBufferPointervOES_client_proc_t retval = glGetBufferPointervOES; glGetBufferPointervOES = f; return retval;}
+	virtual glCurrentPaletteMatrixOES_client_proc_t set_glCurrentPaletteMatrixOES(glCurrentPaletteMatrixOES_client_proc_t f) { glCurrentPaletteMatrixOES_client_proc_t retval = glCurrentPaletteMatrixOES; glCurrentPaletteMatrixOES = f; return retval;}
+	virtual glLoadPaletteFromModelViewMatrixOES_client_proc_t set_glLoadPaletteFromModelViewMatrixOES(glLoadPaletteFromModelViewMatrixOES_client_proc_t f) { glLoadPaletteFromModelViewMatrixOES_client_proc_t retval = glLoadPaletteFromModelViewMatrixOES; glLoadPaletteFromModelViewMatrixOES = f; return retval;}
+	virtual glMatrixIndexPointerOES_client_proc_t set_glMatrixIndexPointerOES(glMatrixIndexPointerOES_client_proc_t f) { glMatrixIndexPointerOES_client_proc_t retval = glMatrixIndexPointerOES; glMatrixIndexPointerOES = f; return retval;}
+	virtual glWeightPointerOES_client_proc_t set_glWeightPointerOES(glWeightPointerOES_client_proc_t f) { glWeightPointerOES_client_proc_t retval = glWeightPointerOES; glWeightPointerOES = f; return retval;}
+	virtual glQueryMatrixxOES_client_proc_t set_glQueryMatrixxOES(glQueryMatrixxOES_client_proc_t f) { glQueryMatrixxOES_client_proc_t retval = glQueryMatrixxOES; glQueryMatrixxOES = f; return retval;}
+	virtual glDepthRangefOES_client_proc_t set_glDepthRangefOES(glDepthRangefOES_client_proc_t f) { glDepthRangefOES_client_proc_t retval = glDepthRangefOES; glDepthRangefOES = f; return retval;}
+	virtual glFrustumfOES_client_proc_t set_glFrustumfOES(glFrustumfOES_client_proc_t f) { glFrustumfOES_client_proc_t retval = glFrustumfOES; glFrustumfOES = f; return retval;}
+	virtual glOrthofOES_client_proc_t set_glOrthofOES(glOrthofOES_client_proc_t f) { glOrthofOES_client_proc_t retval = glOrthofOES; glOrthofOES = f; return retval;}
+	virtual glClipPlanefOES_client_proc_t set_glClipPlanefOES(glClipPlanefOES_client_proc_t f) { glClipPlanefOES_client_proc_t retval = glClipPlanefOES; glClipPlanefOES = f; return retval;}
+	virtual glClipPlanefIMG_client_proc_t set_glClipPlanefIMG(glClipPlanefIMG_client_proc_t f) { glClipPlanefIMG_client_proc_t retval = glClipPlanefIMG; glClipPlanefIMG = f; return retval;}
+	virtual glGetClipPlanefOES_client_proc_t set_glGetClipPlanefOES(glGetClipPlanefOES_client_proc_t f) { glGetClipPlanefOES_client_proc_t retval = glGetClipPlanefOES; glGetClipPlanefOES = f; return retval;}
+	virtual glClearDepthfOES_client_proc_t set_glClearDepthfOES(glClearDepthfOES_client_proc_t f) { glClearDepthfOES_client_proc_t retval = glClearDepthfOES; glClearDepthfOES = f; return retval;}
+	virtual glTexGenfOES_client_proc_t set_glTexGenfOES(glTexGenfOES_client_proc_t f) { glTexGenfOES_client_proc_t retval = glTexGenfOES; glTexGenfOES = f; return retval;}
+	virtual glTexGenfvOES_client_proc_t set_glTexGenfvOES(glTexGenfvOES_client_proc_t f) { glTexGenfvOES_client_proc_t retval = glTexGenfvOES; glTexGenfvOES = f; return retval;}
+	virtual glTexGeniOES_client_proc_t set_glTexGeniOES(glTexGeniOES_client_proc_t f) { glTexGeniOES_client_proc_t retval = glTexGeniOES; glTexGeniOES = f; return retval;}
+	virtual glTexGenivOES_client_proc_t set_glTexGenivOES(glTexGenivOES_client_proc_t f) { glTexGenivOES_client_proc_t retval = glTexGenivOES; glTexGenivOES = f; return retval;}
+	virtual glTexGenxOES_client_proc_t set_glTexGenxOES(glTexGenxOES_client_proc_t f) { glTexGenxOES_client_proc_t retval = glTexGenxOES; glTexGenxOES = f; return retval;}
+	virtual glTexGenxvOES_client_proc_t set_glTexGenxvOES(glTexGenxvOES_client_proc_t f) { glTexGenxvOES_client_proc_t retval = glTexGenxvOES; glTexGenxvOES = f; return retval;}
+	virtual glGetTexGenfvOES_client_proc_t set_glGetTexGenfvOES(glGetTexGenfvOES_client_proc_t f) { glGetTexGenfvOES_client_proc_t retval = glGetTexGenfvOES; glGetTexGenfvOES = f; return retval;}
+	virtual glGetTexGenivOES_client_proc_t set_glGetTexGenivOES(glGetTexGenivOES_client_proc_t f) { glGetTexGenivOES_client_proc_t retval = glGetTexGenivOES; glGetTexGenivOES = f; return retval;}
+	virtual glGetTexGenxvOES_client_proc_t set_glGetTexGenxvOES(glGetTexGenxvOES_client_proc_t f) { glGetTexGenxvOES_client_proc_t retval = glGetTexGenxvOES; glGetTexGenxvOES = f; return retval;}
+	virtual glBindVertexArrayOES_client_proc_t set_glBindVertexArrayOES(glBindVertexArrayOES_client_proc_t f) { glBindVertexArrayOES_client_proc_t retval = glBindVertexArrayOES; glBindVertexArrayOES = f; return retval;}
+	virtual glDeleteVertexArraysOES_client_proc_t set_glDeleteVertexArraysOES(glDeleteVertexArraysOES_client_proc_t f) { glDeleteVertexArraysOES_client_proc_t retval = glDeleteVertexArraysOES; glDeleteVertexArraysOES = f; return retval;}
+	virtual glGenVertexArraysOES_client_proc_t set_glGenVertexArraysOES(glGenVertexArraysOES_client_proc_t f) { glGenVertexArraysOES_client_proc_t retval = glGenVertexArraysOES; glGenVertexArraysOES = f; return retval;}
+	virtual glIsVertexArrayOES_client_proc_t set_glIsVertexArrayOES(glIsVertexArrayOES_client_proc_t f) { glIsVertexArrayOES_client_proc_t retval = glIsVertexArrayOES; glIsVertexArrayOES = f; return retval;}
+	virtual glDiscardFramebufferEXT_client_proc_t set_glDiscardFramebufferEXT(glDiscardFramebufferEXT_client_proc_t f) { glDiscardFramebufferEXT_client_proc_t retval = glDiscardFramebufferEXT; glDiscardFramebufferEXT = f; return retval;}
+	virtual glMultiDrawArraysEXT_client_proc_t set_glMultiDrawArraysEXT(glMultiDrawArraysEXT_client_proc_t f) { glMultiDrawArraysEXT_client_proc_t retval = glMultiDrawArraysEXT; glMultiDrawArraysEXT = f; return retval;}
+	virtual glMultiDrawElementsEXT_client_proc_t set_glMultiDrawElementsEXT(glMultiDrawElementsEXT_client_proc_t f) { glMultiDrawElementsEXT_client_proc_t retval = glMultiDrawElementsEXT; glMultiDrawElementsEXT = f; return retval;}
+	virtual glMultiDrawArraysSUN_client_proc_t set_glMultiDrawArraysSUN(glMultiDrawArraysSUN_client_proc_t f) { glMultiDrawArraysSUN_client_proc_t retval = glMultiDrawArraysSUN; glMultiDrawArraysSUN = f; return retval;}
+	virtual glMultiDrawElementsSUN_client_proc_t set_glMultiDrawElementsSUN(glMultiDrawElementsSUN_client_proc_t f) { glMultiDrawElementsSUN_client_proc_t retval = glMultiDrawElementsSUN; glMultiDrawElementsSUN = f; return retval;}
+	virtual glRenderbufferStorageMultisampleIMG_client_proc_t set_glRenderbufferStorageMultisampleIMG(glRenderbufferStorageMultisampleIMG_client_proc_t f) { glRenderbufferStorageMultisampleIMG_client_proc_t retval = glRenderbufferStorageMultisampleIMG; glRenderbufferStorageMultisampleIMG = f; return retval;}
+	virtual glFramebufferTexture2DMultisampleIMG_client_proc_t set_glFramebufferTexture2DMultisampleIMG(glFramebufferTexture2DMultisampleIMG_client_proc_t f) { glFramebufferTexture2DMultisampleIMG_client_proc_t retval = glFramebufferTexture2DMultisampleIMG; glFramebufferTexture2DMultisampleIMG = f; return retval;}
+	virtual glDeleteFencesNV_client_proc_t set_glDeleteFencesNV(glDeleteFencesNV_client_proc_t f) { glDeleteFencesNV_client_proc_t retval = glDeleteFencesNV; glDeleteFencesNV = f; return retval;}
+	virtual glGenFencesNV_client_proc_t set_glGenFencesNV(glGenFencesNV_client_proc_t f) { glGenFencesNV_client_proc_t retval = glGenFencesNV; glGenFencesNV = f; return retval;}
+	virtual glIsFenceNV_client_proc_t set_glIsFenceNV(glIsFenceNV_client_proc_t f) { glIsFenceNV_client_proc_t retval = glIsFenceNV; glIsFenceNV = f; return retval;}
+	virtual glTestFenceNV_client_proc_t set_glTestFenceNV(glTestFenceNV_client_proc_t f) { glTestFenceNV_client_proc_t retval = glTestFenceNV; glTestFenceNV = f; return retval;}
+	virtual glGetFenceivNV_client_proc_t set_glGetFenceivNV(glGetFenceivNV_client_proc_t f) { glGetFenceivNV_client_proc_t retval = glGetFenceivNV; glGetFenceivNV = f; return retval;}
+	virtual glFinishFenceNV_client_proc_t set_glFinishFenceNV(glFinishFenceNV_client_proc_t f) { glFinishFenceNV_client_proc_t retval = glFinishFenceNV; glFinishFenceNV = f; return retval;}
+	virtual glSetFenceNV_client_proc_t set_glSetFenceNV(glSetFenceNV_client_proc_t f) { glSetFenceNV_client_proc_t retval = glSetFenceNV; glSetFenceNV = f; return retval;}
+	virtual glGetDriverControlsQCOM_client_proc_t set_glGetDriverControlsQCOM(glGetDriverControlsQCOM_client_proc_t f) { glGetDriverControlsQCOM_client_proc_t retval = glGetDriverControlsQCOM; glGetDriverControlsQCOM = f; return retval;}
+	virtual glGetDriverControlStringQCOM_client_proc_t set_glGetDriverControlStringQCOM(glGetDriverControlStringQCOM_client_proc_t f) { glGetDriverControlStringQCOM_client_proc_t retval = glGetDriverControlStringQCOM; glGetDriverControlStringQCOM = f; return retval;}
+	virtual glEnableDriverControlQCOM_client_proc_t set_glEnableDriverControlQCOM(glEnableDriverControlQCOM_client_proc_t f) { glEnableDriverControlQCOM_client_proc_t retval = glEnableDriverControlQCOM; glEnableDriverControlQCOM = f; return retval;}
+	virtual glDisableDriverControlQCOM_client_proc_t set_glDisableDriverControlQCOM(glDisableDriverControlQCOM_client_proc_t f) { glDisableDriverControlQCOM_client_proc_t retval = glDisableDriverControlQCOM; glDisableDriverControlQCOM = f; return retval;}
+	virtual glExtGetTexturesQCOM_client_proc_t set_glExtGetTexturesQCOM(glExtGetTexturesQCOM_client_proc_t f) { glExtGetTexturesQCOM_client_proc_t retval = glExtGetTexturesQCOM; glExtGetTexturesQCOM = f; return retval;}
+	virtual glExtGetBuffersQCOM_client_proc_t set_glExtGetBuffersQCOM(glExtGetBuffersQCOM_client_proc_t f) { glExtGetBuffersQCOM_client_proc_t retval = glExtGetBuffersQCOM; glExtGetBuffersQCOM = f; return retval;}
+	virtual glExtGetRenderbuffersQCOM_client_proc_t set_glExtGetRenderbuffersQCOM(glExtGetRenderbuffersQCOM_client_proc_t f) { glExtGetRenderbuffersQCOM_client_proc_t retval = glExtGetRenderbuffersQCOM; glExtGetRenderbuffersQCOM = f; return retval;}
+	virtual glExtGetFramebuffersQCOM_client_proc_t set_glExtGetFramebuffersQCOM(glExtGetFramebuffersQCOM_client_proc_t f) { glExtGetFramebuffersQCOM_client_proc_t retval = glExtGetFramebuffersQCOM; glExtGetFramebuffersQCOM = f; return retval;}
+	virtual glExtGetTexLevelParameterivQCOM_client_proc_t set_glExtGetTexLevelParameterivQCOM(glExtGetTexLevelParameterivQCOM_client_proc_t f) { glExtGetTexLevelParameterivQCOM_client_proc_t retval = glExtGetTexLevelParameterivQCOM; glExtGetTexLevelParameterivQCOM = f; return retval;}
+	virtual glExtTexObjectStateOverrideiQCOM_client_proc_t set_glExtTexObjectStateOverrideiQCOM(glExtTexObjectStateOverrideiQCOM_client_proc_t f) { glExtTexObjectStateOverrideiQCOM_client_proc_t retval = glExtTexObjectStateOverrideiQCOM; glExtTexObjectStateOverrideiQCOM = f; return retval;}
+	virtual glExtGetTexSubImageQCOM_client_proc_t set_glExtGetTexSubImageQCOM(glExtGetTexSubImageQCOM_client_proc_t f) { glExtGetTexSubImageQCOM_client_proc_t retval = glExtGetTexSubImageQCOM; glExtGetTexSubImageQCOM = f; return retval;}
+	virtual glExtGetBufferPointervQCOM_client_proc_t set_glExtGetBufferPointervQCOM(glExtGetBufferPointervQCOM_client_proc_t f) { glExtGetBufferPointervQCOM_client_proc_t retval = glExtGetBufferPointervQCOM; glExtGetBufferPointervQCOM = f; return retval;}
+	virtual glExtGetShadersQCOM_client_proc_t set_glExtGetShadersQCOM(glExtGetShadersQCOM_client_proc_t f) { glExtGetShadersQCOM_client_proc_t retval = glExtGetShadersQCOM; glExtGetShadersQCOM = f; return retval;}
+	virtual glExtGetProgramsQCOM_client_proc_t set_glExtGetProgramsQCOM(glExtGetProgramsQCOM_client_proc_t f) { glExtGetProgramsQCOM_client_proc_t retval = glExtGetProgramsQCOM; glExtGetProgramsQCOM = f; return retval;}
+	virtual glExtIsProgramBinaryQCOM_client_proc_t set_glExtIsProgramBinaryQCOM(glExtIsProgramBinaryQCOM_client_proc_t f) { glExtIsProgramBinaryQCOM_client_proc_t retval = glExtIsProgramBinaryQCOM; glExtIsProgramBinaryQCOM = f; return retval;}
+	virtual glExtGetProgramBinarySourceQCOM_client_proc_t set_glExtGetProgramBinarySourceQCOM(glExtGetProgramBinarySourceQCOM_client_proc_t f) { glExtGetProgramBinarySourceQCOM_client_proc_t retval = glExtGetProgramBinarySourceQCOM; glExtGetProgramBinarySourceQCOM = f; return retval;}
+	virtual glStartTilingQCOM_client_proc_t set_glStartTilingQCOM(glStartTilingQCOM_client_proc_t f) { glStartTilingQCOM_client_proc_t retval = glStartTilingQCOM; glStartTilingQCOM = f; return retval;}
+	virtual glEndTilingQCOM_client_proc_t set_glEndTilingQCOM(glEndTilingQCOM_client_proc_t f) { glEndTilingQCOM_client_proc_t retval = glEndTilingQCOM; glEndTilingQCOM = f; return retval;}
+	 virtual ~gl_client_context_t() {}
+
+	typedef gl_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
+	static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
+	int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+	virtual void setError(unsigned int  error){};
+	virtual unsigned int getError(){ return 0; };
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl_client_proc.h b/tools/emulator/opengl/system/GLESv1_enc/gl_client_proc.h
new file mode 100644
index 0000000..a188657
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_client_proc.h
@@ -0,0 +1,305 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __gl_client_proc_t_h
+#define __gl_client_proc_t_h
+
+
+
+#include "gl_types.h"
+#ifndef gl_APIENTRY
+#define gl_APIENTRY 
+#endif
+typedef void (gl_APIENTRY *glAlphaFunc_client_proc_t) (void * ctx, GLenum, GLclampf);
+typedef void (gl_APIENTRY *glClearColor_client_proc_t) (void * ctx, GLclampf, GLclampf, GLclampf, GLclampf);
+typedef void (gl_APIENTRY *glClearDepthf_client_proc_t) (void * ctx, GLclampf);
+typedef void (gl_APIENTRY *glClipPlanef_client_proc_t) (void * ctx, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glColor4f_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glDepthRangef_client_proc_t) (void * ctx, GLclampf, GLclampf);
+typedef void (gl_APIENTRY *glFogf_client_proc_t) (void * ctx, GLenum, GLfloat);
+typedef void (gl_APIENTRY *glFogfv_client_proc_t) (void * ctx, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glFrustumf_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glGetClipPlanef_client_proc_t) (void * ctx, GLenum, GLfloat*);
+typedef void (gl_APIENTRY *glGetFloatv_client_proc_t) (void * ctx, GLenum, GLfloat*);
+typedef void (gl_APIENTRY *glGetLightfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*);
+typedef void (gl_APIENTRY *glGetMaterialfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*);
+typedef void (gl_APIENTRY *glGetTexEnvfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*);
+typedef void (gl_APIENTRY *glGetTexParameterfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*);
+typedef void (gl_APIENTRY *glLightModelf_client_proc_t) (void * ctx, GLenum, GLfloat);
+typedef void (gl_APIENTRY *glLightModelfv_client_proc_t) (void * ctx, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glLightf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat);
+typedef void (gl_APIENTRY *glLightfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glLineWidth_client_proc_t) (void * ctx, GLfloat);
+typedef void (gl_APIENTRY *glLoadMatrixf_client_proc_t) (void * ctx, const GLfloat*);
+typedef void (gl_APIENTRY *glMaterialf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat);
+typedef void (gl_APIENTRY *glMaterialfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glMultMatrixf_client_proc_t) (void * ctx, const GLfloat*);
+typedef void (gl_APIENTRY *glMultiTexCoord4f_client_proc_t) (void * ctx, GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glNormal3f_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glOrthof_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glPointParameterf_client_proc_t) (void * ctx, GLenum, GLfloat);
+typedef void (gl_APIENTRY *glPointParameterfv_client_proc_t) (void * ctx, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glPointSize_client_proc_t) (void * ctx, GLfloat);
+typedef void (gl_APIENTRY *glPolygonOffset_client_proc_t) (void * ctx, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glRotatef_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glScalef_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glTexEnvf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat);
+typedef void (gl_APIENTRY *glTexEnvfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glTexParameterf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat);
+typedef void (gl_APIENTRY *glTexParameterfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glTranslatef_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glActiveTexture_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glAlphaFuncx_client_proc_t) (void * ctx, GLenum, GLclampx);
+typedef void (gl_APIENTRY *glBindBuffer_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl_APIENTRY *glBindTexture_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl_APIENTRY *glBlendFunc_client_proc_t) (void * ctx, GLenum, GLenum);
+typedef void (gl_APIENTRY *glBufferData_client_proc_t) (void * ctx, GLenum, GLsizeiptr, const GLvoid*, GLenum);
+typedef void (gl_APIENTRY *glBufferSubData_client_proc_t) (void * ctx, GLenum, GLintptr, GLsizeiptr, const GLvoid*);
+typedef void (gl_APIENTRY *glClear_client_proc_t) (void * ctx, GLbitfield);
+typedef void (gl_APIENTRY *glClearColorx_client_proc_t) (void * ctx, GLclampx, GLclampx, GLclampx, GLclampx);
+typedef void (gl_APIENTRY *glClearDepthx_client_proc_t) (void * ctx, GLclampx);
+typedef void (gl_APIENTRY *glClearStencil_client_proc_t) (void * ctx, GLint);
+typedef void (gl_APIENTRY *glClientActiveTexture_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glColor4ub_client_proc_t) (void * ctx, GLubyte, GLubyte, GLubyte, GLubyte);
+typedef void (gl_APIENTRY *glColor4x_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glColorMask_client_proc_t) (void * ctx, GLboolean, GLboolean, GLboolean, GLboolean);
+typedef void (gl_APIENTRY *glColorPointer_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*);
+typedef void (gl_APIENTRY *glCompressedTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*);
+typedef void (gl_APIENTRY *glCompressedTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*);
+typedef void (gl_APIENTRY *glCopyTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+typedef void (gl_APIENTRY *glCopyTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+typedef void (gl_APIENTRY *glCullFace_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glDeleteBuffers_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl_APIENTRY *glDeleteTextures_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl_APIENTRY *glDepthFunc_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glDepthMask_client_proc_t) (void * ctx, GLboolean);
+typedef void (gl_APIENTRY *glDepthRangex_client_proc_t) (void * ctx, GLclampx, GLclampx);
+typedef void (gl_APIENTRY *glDisable_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glDisableClientState_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glDrawArrays_client_proc_t) (void * ctx, GLenum, GLint, GLsizei);
+typedef void (gl_APIENTRY *glDrawElements_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, const GLvoid*);
+typedef void (gl_APIENTRY *glEnable_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glEnableClientState_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glFinish_client_proc_t) (void * ctx);
+typedef void (gl_APIENTRY *glFlush_client_proc_t) (void * ctx);
+typedef void (gl_APIENTRY *glFogx_client_proc_t) (void * ctx, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glFogxv_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glFrontFace_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glFrustumx_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glGetBooleanv_client_proc_t) (void * ctx, GLenum, GLboolean*);
+typedef void (gl_APIENTRY *glGetBufferParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*);
+typedef void (gl_APIENTRY *glClipPlanex_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glGenBuffers_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef void (gl_APIENTRY *glGenTextures_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef GLenum (gl_APIENTRY *glGetError_client_proc_t) (void * ctx);
+typedef void (gl_APIENTRY *glGetFixedv_client_proc_t) (void * ctx, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetIntegerv_client_proc_t) (void * ctx, GLenum, GLint*);
+typedef void (gl_APIENTRY *glGetLightxv_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetMaterialxv_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetPointerv_client_proc_t) (void * ctx, GLenum, GLvoid**);
+typedef const GLubyte* (gl_APIENTRY *glGetString_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glGetTexEnviv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*);
+typedef void (gl_APIENTRY *glGetTexEnvxv_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetTexParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*);
+typedef void (gl_APIENTRY *glGetTexParameterxv_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glHint_client_proc_t) (void * ctx, GLenum, GLenum);
+typedef GLboolean (gl_APIENTRY *glIsBuffer_client_proc_t) (void * ctx, GLuint);
+typedef GLboolean (gl_APIENTRY *glIsEnabled_client_proc_t) (void * ctx, GLenum);
+typedef GLboolean (gl_APIENTRY *glIsTexture_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glLightModelx_client_proc_t) (void * ctx, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glLightModelxv_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glLightx_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glLightxv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glLineWidthx_client_proc_t) (void * ctx, GLfixed);
+typedef void (gl_APIENTRY *glLoadIdentity_client_proc_t) (void * ctx);
+typedef void (gl_APIENTRY *glLoadMatrixx_client_proc_t) (void * ctx, const GLfixed*);
+typedef void (gl_APIENTRY *glLogicOp_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glMaterialx_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glMaterialxv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glMatrixMode_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glMultMatrixx_client_proc_t) (void * ctx, const GLfixed*);
+typedef void (gl_APIENTRY *glMultiTexCoord4x_client_proc_t) (void * ctx, GLenum, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glNormal3x_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glNormalPointer_client_proc_t) (void * ctx, GLenum, GLsizei, const GLvoid*);
+typedef void (gl_APIENTRY *glOrthox_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glPixelStorei_client_proc_t) (void * ctx, GLenum, GLint);
+typedef void (gl_APIENTRY *glPointParameterx_client_proc_t) (void * ctx, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glPointParameterxv_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glPointSizex_client_proc_t) (void * ctx, GLfixed);
+typedef void (gl_APIENTRY *glPolygonOffsetx_client_proc_t) (void * ctx, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glPopMatrix_client_proc_t) (void * ctx);
+typedef void (gl_APIENTRY *glPushMatrix_client_proc_t) (void * ctx);
+typedef void (gl_APIENTRY *glReadPixels_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*);
+typedef void (gl_APIENTRY *glRotatex_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glSampleCoverage_client_proc_t) (void * ctx, GLclampf, GLboolean);
+typedef void (gl_APIENTRY *glSampleCoveragex_client_proc_t) (void * ctx, GLclampx, GLboolean);
+typedef void (gl_APIENTRY *glScalex_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glScissor_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei);
+typedef void (gl_APIENTRY *glShadeModel_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glStencilFunc_client_proc_t) (void * ctx, GLenum, GLint, GLuint);
+typedef void (gl_APIENTRY *glStencilMask_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glStencilOp_client_proc_t) (void * ctx, GLenum, GLenum, GLenum);
+typedef void (gl_APIENTRY *glTexCoordPointer_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*);
+typedef void (gl_APIENTRY *glTexEnvi_client_proc_t) (void * ctx, GLenum, GLenum, GLint);
+typedef void (gl_APIENTRY *glTexEnvx_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glTexEnviv_client_proc_t) (void * ctx, GLenum, GLenum, const GLint*);
+typedef void (gl_APIENTRY *glTexEnvxv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*);
+typedef void (gl_APIENTRY *glTexParameteri_client_proc_t) (void * ctx, GLenum, GLenum, GLint);
+typedef void (gl_APIENTRY *glTexParameterx_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glTexParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, const GLint*);
+typedef void (gl_APIENTRY *glTexParameterxv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*);
+typedef void (gl_APIENTRY *glTranslatex_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glVertexPointer_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*);
+typedef void (gl_APIENTRY *glViewport_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei);
+typedef void (gl_APIENTRY *glPointSizePointerOES_client_proc_t) (void * ctx, GLenum, GLsizei, const GLvoid*);
+typedef void (gl_APIENTRY *glVertexPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint);
+typedef void (gl_APIENTRY *glColorPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint);
+typedef void (gl_APIENTRY *glNormalPointerOffset_client_proc_t) (void * ctx, GLenum, GLsizei, GLuint);
+typedef void (gl_APIENTRY *glPointSizePointerOffset_client_proc_t) (void * ctx, GLenum, GLsizei, GLuint);
+typedef void (gl_APIENTRY *glTexCoordPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint);
+typedef void (gl_APIENTRY *glWeightPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint);
+typedef void (gl_APIENTRY *glMatrixIndexPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint);
+typedef void (gl_APIENTRY *glVertexPointerData_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, void*, GLuint);
+typedef void (gl_APIENTRY *glColorPointerData_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, void*, GLuint);
+typedef void (gl_APIENTRY *glNormalPointerData_client_proc_t) (void * ctx, GLenum, GLsizei, void*, GLuint);
+typedef void (gl_APIENTRY *glTexCoordPointerData_client_proc_t) (void * ctx, GLint, GLint, GLenum, GLsizei, void*, GLuint);
+typedef void (gl_APIENTRY *glPointSizePointerData_client_proc_t) (void * ctx, GLenum, GLsizei, void*, GLuint);
+typedef void (gl_APIENTRY *glWeightPointerData_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, void*, GLuint);
+typedef void (gl_APIENTRY *glMatrixIndexPointerData_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, void*, GLuint);
+typedef void (gl_APIENTRY *glDrawElementsOffset_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, GLuint);
+typedef void (gl_APIENTRY *glDrawElementsData_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, void*, GLuint);
+typedef void (gl_APIENTRY *glGetCompressedTextureFormats_client_proc_t) (void * ctx, int, GLint*);
+typedef int (gl_APIENTRY *glFinishRoundTrip_client_proc_t) (void * ctx);
+typedef void (gl_APIENTRY *glBlendEquationSeparateOES_client_proc_t) (void * ctx, GLenum, GLenum);
+typedef void (gl_APIENTRY *glBlendFuncSeparateOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLenum);
+typedef void (gl_APIENTRY *glBlendEquationOES_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glDrawTexsOES_client_proc_t) (void * ctx, GLshort, GLshort, GLshort, GLshort, GLshort);
+typedef void (gl_APIENTRY *glDrawTexiOES_client_proc_t) (void * ctx, GLint, GLint, GLint, GLint, GLint);
+typedef void (gl_APIENTRY *glDrawTexxOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glDrawTexsvOES_client_proc_t) (void * ctx, const GLshort*);
+typedef void (gl_APIENTRY *glDrawTexivOES_client_proc_t) (void * ctx, const GLint*);
+typedef void (gl_APIENTRY *glDrawTexxvOES_client_proc_t) (void * ctx, const GLfixed*);
+typedef void (gl_APIENTRY *glDrawTexfOES_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glDrawTexfvOES_client_proc_t) (void * ctx, const GLfloat*);
+typedef void (gl_APIENTRY *glEGLImageTargetTexture2DOES_client_proc_t) (void * ctx, GLenum, GLeglImageOES);
+typedef void (gl_APIENTRY *glEGLImageTargetRenderbufferStorageOES_client_proc_t) (void * ctx, GLenum, GLeglImageOES);
+typedef void (gl_APIENTRY *glAlphaFuncxOES_client_proc_t) (void * ctx, GLenum, GLclampx);
+typedef void (gl_APIENTRY *glClearColorxOES_client_proc_t) (void * ctx, GLclampx, GLclampx, GLclampx, GLclampx);
+typedef void (gl_APIENTRY *glClearDepthxOES_client_proc_t) (void * ctx, GLclampx);
+typedef void (gl_APIENTRY *glClipPlanexOES_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glClipPlanexIMG_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glColor4xOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glDepthRangexOES_client_proc_t) (void * ctx, GLclampx, GLclampx);
+typedef void (gl_APIENTRY *glFogxOES_client_proc_t) (void * ctx, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glFogxvOES_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glFrustumxOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glGetClipPlanexOES_client_proc_t) (void * ctx, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetClipPlanex_client_proc_t) (void * ctx, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetFixedvOES_client_proc_t) (void * ctx, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetLightxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetMaterialxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetTexEnvxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glGetTexParameterxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glLightModelxOES_client_proc_t) (void * ctx, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glLightModelxvOES_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glLightxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glLightxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glLineWidthxOES_client_proc_t) (void * ctx, GLfixed);
+typedef void (gl_APIENTRY *glLoadMatrixxOES_client_proc_t) (void * ctx, const GLfixed*);
+typedef void (gl_APIENTRY *glMaterialxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glMaterialxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glMultMatrixxOES_client_proc_t) (void * ctx, const GLfixed*);
+typedef void (gl_APIENTRY *glMultiTexCoord4xOES_client_proc_t) (void * ctx, GLenum, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glNormal3xOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glOrthoxOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glPointParameterxOES_client_proc_t) (void * ctx, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glPointParameterxvOES_client_proc_t) (void * ctx, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glPointSizexOES_client_proc_t) (void * ctx, GLfixed);
+typedef void (gl_APIENTRY *glPolygonOffsetxOES_client_proc_t) (void * ctx, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glRotatexOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glSampleCoveragexOES_client_proc_t) (void * ctx, GLclampx, GLboolean);
+typedef void (gl_APIENTRY *glScalexOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed);
+typedef void (gl_APIENTRY *glTexEnvxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glTexEnvxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glTexParameterxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glTexParameterxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glTranslatexOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed);
+typedef GLboolean (gl_APIENTRY *glIsRenderbufferOES_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glBindRenderbufferOES_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl_APIENTRY *glDeleteRenderbuffersOES_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl_APIENTRY *glGenRenderbuffersOES_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef void (gl_APIENTRY *glRenderbufferStorageOES_client_proc_t) (void * ctx, GLenum, GLenum, GLsizei, GLsizei);
+typedef void (gl_APIENTRY *glGetRenderbufferParameterivOES_client_proc_t) (void * ctx, GLenum, GLenum, GLint*);
+typedef GLboolean (gl_APIENTRY *glIsFramebufferOES_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glBindFramebufferOES_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl_APIENTRY *glDeleteFramebuffersOES_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl_APIENTRY *glGenFramebuffersOES_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef GLenum (gl_APIENTRY *glCheckFramebufferStatusOES_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glFramebufferRenderbufferOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint);
+typedef void (gl_APIENTRY *glFramebufferTexture2DOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint);
+typedef void (gl_APIENTRY *glGetFramebufferAttachmentParameterivOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLint*);
+typedef void (gl_APIENTRY *glGenerateMipmapOES_client_proc_t) (void * ctx, GLenum);
+typedef void* (gl_APIENTRY *glMapBufferOES_client_proc_t) (void * ctx, GLenum, GLenum);
+typedef GLboolean (gl_APIENTRY *glUnmapBufferOES_client_proc_t) (void * ctx, GLenum);
+typedef void (gl_APIENTRY *glGetBufferPointervOES_client_proc_t) (void * ctx, GLenum, GLenum, GLvoid**);
+typedef void (gl_APIENTRY *glCurrentPaletteMatrixOES_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glLoadPaletteFromModelViewMatrixOES_client_proc_t) (void * ctx);
+typedef void (gl_APIENTRY *glMatrixIndexPointerOES_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*);
+typedef void (gl_APIENTRY *glWeightPointerOES_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*);
+typedef GLbitfield (gl_APIENTRY *glQueryMatrixxOES_client_proc_t) (void * ctx, GLfixed*, GLint*);
+typedef void (gl_APIENTRY *glDepthRangefOES_client_proc_t) (void * ctx, GLclampf, GLclampf);
+typedef void (gl_APIENTRY *glFrustumfOES_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glOrthofOES_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl_APIENTRY *glClipPlanefOES_client_proc_t) (void * ctx, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glClipPlanefIMG_client_proc_t) (void * ctx, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glGetClipPlanefOES_client_proc_t) (void * ctx, GLenum, GLfloat*);
+typedef void (gl_APIENTRY *glClearDepthfOES_client_proc_t) (void * ctx, GLclampf);
+typedef void (gl_APIENTRY *glTexGenfOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat);
+typedef void (gl_APIENTRY *glTexGenfvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*);
+typedef void (gl_APIENTRY *glTexGeniOES_client_proc_t) (void * ctx, GLenum, GLenum, GLint);
+typedef void (gl_APIENTRY *glTexGenivOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLint*);
+typedef void (gl_APIENTRY *glTexGenxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed);
+typedef void (gl_APIENTRY *glTexGenxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*);
+typedef void (gl_APIENTRY *glGetTexGenfvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*);
+typedef void (gl_APIENTRY *glGetTexGenivOES_client_proc_t) (void * ctx, GLenum, GLenum, GLint*);
+typedef void (gl_APIENTRY *glGetTexGenxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*);
+typedef void (gl_APIENTRY *glBindVertexArrayOES_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glDeleteVertexArraysOES_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl_APIENTRY *glGenVertexArraysOES_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef GLboolean (gl_APIENTRY *glIsVertexArrayOES_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glDiscardFramebufferEXT_client_proc_t) (void * ctx, GLenum, GLsizei, const GLenum*);
+typedef void (gl_APIENTRY *glMultiDrawArraysEXT_client_proc_t) (void * ctx, GLenum, GLint*, GLsizei*, GLsizei);
+typedef void (gl_APIENTRY *glMultiDrawElementsEXT_client_proc_t) (void * ctx, GLenum, const GLsizei*, GLenum, const GLvoid**, GLsizei);
+typedef void (gl_APIENTRY *glMultiDrawArraysSUN_client_proc_t) (void * ctx, GLenum, GLint*, GLsizei*, GLsizei);
+typedef void (gl_APIENTRY *glMultiDrawElementsSUN_client_proc_t) (void * ctx, GLenum, const GLsizei*, GLenum, const GLvoid**, GLsizei);
+typedef void (gl_APIENTRY *glRenderbufferStorageMultisampleIMG_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+typedef void (gl_APIENTRY *glFramebufferTexture2DMultisampleIMG_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+typedef void (gl_APIENTRY *glDeleteFencesNV_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl_APIENTRY *glGenFencesNV_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef GLboolean (gl_APIENTRY *glIsFenceNV_client_proc_t) (void * ctx, GLuint);
+typedef GLboolean (gl_APIENTRY *glTestFenceNV_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glGetFenceivNV_client_proc_t) (void * ctx, GLuint, GLenum, GLint*);
+typedef void (gl_APIENTRY *glFinishFenceNV_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glSetFenceNV_client_proc_t) (void * ctx, GLuint, GLenum);
+typedef void (gl_APIENTRY *glGetDriverControlsQCOM_client_proc_t) (void * ctx, GLint*, GLsizei, GLuint*);
+typedef void (gl_APIENTRY *glGetDriverControlStringQCOM_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*);
+typedef void (gl_APIENTRY *glEnableDriverControlQCOM_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glDisableDriverControlQCOM_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glExtGetTexturesQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl_APIENTRY *glExtGetBuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl_APIENTRY *glExtGetRenderbuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl_APIENTRY *glExtGetFramebuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl_APIENTRY *glExtGetTexLevelParameterivQCOM_client_proc_t) (void * ctx, GLuint, GLenum, GLint, GLenum, GLint*);
+typedef void (gl_APIENTRY *glExtTexObjectStateOverrideiQCOM_client_proc_t) (void * ctx, GLenum, GLenum, GLint);
+typedef void (gl_APIENTRY *glExtGetTexSubImageQCOM_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoid*);
+typedef void (gl_APIENTRY *glExtGetBufferPointervQCOM_client_proc_t) (void * ctx, GLenum, GLvoid**);
+typedef void (gl_APIENTRY *glExtGetShadersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl_APIENTRY *glExtGetProgramsQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef GLboolean (gl_APIENTRY *glExtIsProgramBinaryQCOM_client_proc_t) (void * ctx, GLuint);
+typedef void (gl_APIENTRY *glExtGetProgramBinarySourceQCOM_client_proc_t) (void * ctx, GLuint, GLenum, GLchar*, GLint*);
+typedef void (gl_APIENTRY *glStartTilingQCOM_client_proc_t) (void * ctx, GLuint, GLuint, GLuint, GLuint, GLbitfield);
+typedef void (gl_APIENTRY *glEndTilingQCOM_client_proc_t) (void * ctx, GLbitfield);
+
+
+#endif
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl_enc.cpp b/tools/emulator/opengl/system/GLESv1_enc/gl_enc.cpp
new file mode 100644
index 0000000..0a343df
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_enc.cpp
@@ -0,0 +1,5184 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "gl_opcodes.h"
+
+#include "gl_enc.h"
+
+
+#include <stdio.h>
+static void enc_unsupported()
+{
+	ALOGE("Function is unsupported\n");
+}
+
+void glAlphaFunc_enc(void *self , GLenum func, GLclampf ref)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &func, 4); ptr += 4;
+		memcpy(ptr, &ref, 4); ptr += 4;
+}
+
+void glClearColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearColor;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 4); ptr += 4;
+		memcpy(ptr, &green, 4); ptr += 4;
+		memcpy(ptr, &blue, 4); ptr += 4;
+		memcpy(ptr, &alpha, 4); ptr += 4;
+}
+
+void glClearDepthf_enc(void *self , GLclampf depth)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearDepthf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &depth, 4); ptr += 4;
+}
+
+void glClipPlanef_enc(void *self , GLenum plane, const GLfloat* equation)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_equation =  (4 * sizeof(float));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_equation + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClipPlanef;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &plane, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_equation; ptr += 4;
+	memcpy(ptr, equation, __size_equation);ptr += __size_equation;
+}
+
+void glColor4f_enc(void *self , GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glColor4f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 4); ptr += 4;
+		memcpy(ptr, &green, 4); ptr += 4;
+		memcpy(ptr, &blue, 4); ptr += 4;
+		memcpy(ptr, &alpha, 4); ptr += 4;
+}
+
+void glDepthRangef_enc(void *self , GLclampf zNear, GLclampf zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthRangef;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glFogf_enc(void *self , GLenum pname, GLfloat param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFogf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glFogfv_enc(void *self , GLenum pname, const GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFogfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glFrustumf_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFrustumf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &left, 4); ptr += 4;
+		memcpy(ptr, &right, 4); ptr += 4;
+		memcpy(ptr, &bottom, 4); ptr += 4;
+		memcpy(ptr, &top, 4); ptr += 4;
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glGetClipPlanef_enc(void *self , GLenum pname, GLfloat* eqn)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_eqn =  (4 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_eqn + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetClipPlanef;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_eqn; ptr += 4;
+	stream->readback(eqn, __size_eqn);
+}
+
+void glGetFloatv_enc(void *self , GLenum pname, GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetFloatv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetLightfv_enc(void *self , GLenum light, GLenum pname, GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetLightfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetMaterialfv_enc(void *self , GLenum face, GLenum pname, GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetMaterialfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexEnvfv_enc(void *self , GLenum env, GLenum pname, GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexEnvfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &env, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexParameterfv_enc(void *self , GLenum target, GLenum pname, GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glLightModelf_enc(void *self , GLenum pname, GLfloat param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightModelf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glLightModelfv_enc(void *self , GLenum pname, const GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightModelfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glLightf_enc(void *self , GLenum light, GLenum pname, GLfloat param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glLightfv_enc(void *self , GLenum light, GLenum pname, const GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glLineWidth_enc(void *self , GLfloat width)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLineWidth;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &width, 4); ptr += 4;
+}
+
+void glLoadMatrixf_enc(void *self , const GLfloat* m)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_m =  (16 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_m + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLoadMatrixf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_m; ptr += 4;
+	memcpy(ptr, m, __size_m);ptr += __size_m;
+}
+
+void glMaterialf_enc(void *self , GLenum face, GLenum pname, GLfloat param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMaterialf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glMaterialfv_enc(void *self , GLenum face, GLenum pname, const GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMaterialfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glMultMatrixf_enc(void *self , const GLfloat* m)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_m =  (16 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_m + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMultMatrixf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_m; ptr += 4;
+	memcpy(ptr, m, __size_m);ptr += __size_m;
+}
+
+void glMultiTexCoord4f_enc(void *self , GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMultiTexCoord4f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &s, 4); ptr += 4;
+		memcpy(ptr, &t, 4); ptr += 4;
+		memcpy(ptr, &r, 4); ptr += 4;
+		memcpy(ptr, &q, 4); ptr += 4;
+}
+
+void glNormal3f_enc(void *self , GLfloat nx, GLfloat ny, GLfloat nz)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glNormal3f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &nx, 4); ptr += 4;
+		memcpy(ptr, &ny, 4); ptr += 4;
+		memcpy(ptr, &nz, 4); ptr += 4;
+}
+
+void glOrthof_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glOrthof;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &left, 4); ptr += 4;
+		memcpy(ptr, &right, 4); ptr += 4;
+		memcpy(ptr, &bottom, 4); ptr += 4;
+		memcpy(ptr, &top, 4); ptr += 4;
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glPointParameterf_enc(void *self , GLenum pname, GLfloat param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointParameterf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glPointParameterfv_enc(void *self , GLenum pname, const GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointParameterfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glPointSize_enc(void *self , GLfloat size)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointSize;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+}
+
+void glPolygonOffset_enc(void *self , GLfloat factor, GLfloat units)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPolygonOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &factor, 4); ptr += 4;
+		memcpy(ptr, &units, 4); ptr += 4;
+}
+
+void glRotatef_enc(void *self , GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glRotatef;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &angle, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glScalef_enc(void *self , GLfloat x, GLfloat y, GLfloat z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glScalef;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glTexEnvf_enc(void *self , GLenum target, GLenum pname, GLfloat param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexEnvf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexEnvfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexEnvfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexParameterf_enc(void *self , GLenum target, GLenum pname, GLfloat param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameterf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexParameterfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTranslatef_enc(void *self , GLfloat x, GLfloat y, GLfloat z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTranslatef;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glActiveTexture_enc(void *self , GLenum texture)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glActiveTexture;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &texture, 4); ptr += 4;
+}
+
+void glAlphaFuncx_enc(void *self , GLenum func, GLclampx ref)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glAlphaFuncx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &func, 4); ptr += 4;
+		memcpy(ptr, &ref, 4); ptr += 4;
+}
+
+void glBindBuffer_enc(void *self , GLenum target, GLuint buffer)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &buffer, 4); ptr += 4;
+}
+
+void glBindTexture_enc(void *self , GLenum target, GLuint texture)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindTexture;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &texture, 4); ptr += 4;
+}
+
+void glBlendFunc_enc(void *self , GLenum sfactor, GLenum dfactor)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &sfactor, 4); ptr += 4;
+		memcpy(ptr, &dfactor, 4); ptr += 4;
+}
+
+void glBufferData_enc(void *self , GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  size;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBufferData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &size, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	memcpy(ptr, data, __size_data);ptr += __size_data;
+		memcpy(ptr, &usage, 4); ptr += 4;
+}
+
+void glBufferSubData_enc(void *self , GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  size;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_data + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBufferSubData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+		memcpy(ptr, &size, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	memcpy(ptr, data, __size_data);ptr += __size_data;
+}
+
+void glClear_enc(void *self , GLbitfield mask)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClear;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mask, 4); ptr += 4;
+}
+
+void glClearColorx_enc(void *self , GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearColorx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 4); ptr += 4;
+		memcpy(ptr, &green, 4); ptr += 4;
+		memcpy(ptr, &blue, 4); ptr += 4;
+		memcpy(ptr, &alpha, 4); ptr += 4;
+}
+
+void glClearDepthx_enc(void *self , GLclampx depth)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearDepthx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &depth, 4); ptr += 4;
+}
+
+void glClearStencil_enc(void *self , GLint s)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearStencil;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &s, 4); ptr += 4;
+}
+
+void glClientActiveTexture_enc(void *self , GLenum texture)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClientActiveTexture;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &texture, 4); ptr += 4;
+}
+
+void glColor4ub_enc(void *self , GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 1 + 1 + 1 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glColor4ub;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 1); ptr += 1;
+		memcpy(ptr, &green, 1); ptr += 1;
+		memcpy(ptr, &blue, 1); ptr += 1;
+		memcpy(ptr, &alpha, 1); ptr += 1;
+}
+
+void glColor4x_enc(void *self , GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glColor4x;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 4); ptr += 4;
+		memcpy(ptr, &green, 4); ptr += 4;
+		memcpy(ptr, &blue, 4); ptr += 4;
+		memcpy(ptr, &alpha, 4); ptr += 4;
+}
+
+void glColorMask_enc(void *self , GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 1 + 1 + 1 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glColorMask;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 1); ptr += 1;
+		memcpy(ptr, &green, 1); ptr += 1;
+		memcpy(ptr, &blue, 1); ptr += 1;
+		memcpy(ptr, &alpha, 1); ptr += 1;
+}
+
+void glCompressedTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data = ((data != NULL) ?  imageSize : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCompressedTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &border, 4); ptr += 4;
+		memcpy(ptr, &imageSize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	if (data != NULL) memcpy(ptr, data, __size_data);ptr += __size_data;
+}
+
+void glCompressedTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  imageSize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCompressedTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &imageSize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	memcpy(ptr, data, __size_data);ptr += __size_data;
+}
+
+void glCopyTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCopyTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &border, 4); ptr += 4;
+}
+
+void glCopyTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCopyTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glCullFace_enc(void *self , GLenum mode)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCullFace;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+void glDeleteBuffers_enc(void *self , GLsizei n, const GLuint* buffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_buffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_buffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteBuffers;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_buffers; ptr += 4;
+	memcpy(ptr, buffers, __size_buffers);ptr += __size_buffers;
+}
+
+void glDeleteTextures_enc(void *self , GLsizei n, const GLuint* textures)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_textures =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_textures + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteTextures;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_textures; ptr += 4;
+	memcpy(ptr, textures, __size_textures);ptr += __size_textures;
+}
+
+void glDepthFunc_enc(void *self , GLenum func)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &func, 4); ptr += 4;
+}
+
+void glDepthMask_enc(void *self , GLboolean flag)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthMask;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &flag, 1); ptr += 1;
+}
+
+void glDepthRangex_enc(void *self , GLclampx zNear, GLclampx zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthRangex;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glDisable_enc(void *self , GLenum cap)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDisable;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &cap, 4); ptr += 4;
+}
+
+void glDisableClientState_enc(void *self , GLenum array)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDisableClientState;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &array, 4); ptr += 4;
+}
+
+void glDrawArrays_enc(void *self , GLenum mode, GLint first, GLsizei count)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawArrays;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+		memcpy(ptr, &first, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+}
+
+void glEnable_enc(void *self , GLenum cap)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEnable;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &cap, 4); ptr += 4;
+}
+
+void glEnableClientState_enc(void *self , GLenum array)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEnableClientState;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &array, 4); ptr += 4;
+}
+
+void glFinish_enc(void *self )
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFinish;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+void glFlush_enc(void *self )
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFlush;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+void glFogx_enc(void *self , GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFogx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glFogxv_enc(void *self , GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFogxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glFrontFace_enc(void *self , GLenum mode)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFrontFace;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+void glFrustumx_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFrustumx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &left, 4); ptr += 4;
+		memcpy(ptr, &right, 4); ptr += 4;
+		memcpy(ptr, &bottom, 4); ptr += 4;
+		memcpy(ptr, &top, 4); ptr += 4;
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glGetBooleanv_enc(void *self , GLenum pname, GLboolean* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLboolean));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetBooleanv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetBufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetBufferParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glClipPlanex_enc(void *self , GLenum pname, const GLfixed* eqn)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_eqn =  (4 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_eqn + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClipPlanex;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_eqn; ptr += 4;
+	memcpy(ptr, eqn, __size_eqn);ptr += __size_eqn;
+}
+
+void glGenBuffers_enc(void *self , GLsizei n, GLuint* buffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_buffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_buffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenBuffers;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_buffers; ptr += 4;
+	stream->readback(buffers, __size_buffers);
+}
+
+void glGenTextures_enc(void *self , GLsizei n, GLuint* textures)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_textures =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_textures + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenTextures;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_textures; ptr += 4;
+	stream->readback(textures, __size_textures);
+}
+
+GLenum glGetError_enc(void *self )
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetError;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+
+	GLenum retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glGetFixedv_enc(void *self , GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetFixedv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetIntegerv_enc(void *self , GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetIntegerv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetLightxv_enc(void *self , GLenum light, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetLightxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetMaterialxv_enc(void *self , GLenum face, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetMaterialxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexEnviv_enc(void *self , GLenum env, GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexEnviv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &env, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexEnvxv_enc(void *self , GLenum env, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexEnvxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &env, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexParameterxv_enc(void *self , GLenum target, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexParameterxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glHint_enc(void *self , GLenum target, GLenum mode)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glHint;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+GLboolean glIsBuffer_enc(void *self , GLuint buffer)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &buffer, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glIsEnabled_enc(void *self , GLenum cap)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsEnabled;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &cap, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glIsTexture_enc(void *self , GLuint texture)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsTexture;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &texture, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glLightModelx_enc(void *self , GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightModelx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glLightModelxv_enc(void *self , GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightModelxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glLightx_enc(void *self , GLenum light, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glLightxv_enc(void *self , GLenum light, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glLineWidthx_enc(void *self , GLfixed width)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLineWidthx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &width, 4); ptr += 4;
+}
+
+void glLoadIdentity_enc(void *self )
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLoadIdentity;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+void glLoadMatrixx_enc(void *self , const GLfixed* m)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_m =  (16 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_m + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLoadMatrixx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_m; ptr += 4;
+	memcpy(ptr, m, __size_m);ptr += __size_m;
+}
+
+void glLogicOp_enc(void *self , GLenum opcode)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLogicOp;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &opcode, 4); ptr += 4;
+}
+
+void glMaterialx_enc(void *self , GLenum face, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMaterialx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glMaterialxv_enc(void *self , GLenum face, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMaterialxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glMatrixMode_enc(void *self , GLenum mode)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMatrixMode;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+void glMultMatrixx_enc(void *self , const GLfixed* m)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_m =  (16 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_m + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMultMatrixx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_m; ptr += 4;
+	memcpy(ptr, m, __size_m);ptr += __size_m;
+}
+
+void glMultiTexCoord4x_enc(void *self , GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMultiTexCoord4x;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &s, 4); ptr += 4;
+		memcpy(ptr, &t, 4); ptr += 4;
+		memcpy(ptr, &r, 4); ptr += 4;
+		memcpy(ptr, &q, 4); ptr += 4;
+}
+
+void glNormal3x_enc(void *self , GLfixed nx, GLfixed ny, GLfixed nz)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glNormal3x;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &nx, 4); ptr += 4;
+		memcpy(ptr, &ny, 4); ptr += 4;
+		memcpy(ptr, &nz, 4); ptr += 4;
+}
+
+void glOrthox_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glOrthox;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &left, 4); ptr += 4;
+		memcpy(ptr, &right, 4); ptr += 4;
+		memcpy(ptr, &bottom, 4); ptr += 4;
+		memcpy(ptr, &top, 4); ptr += 4;
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glPixelStorei_enc(void *self , GLenum pname, GLint param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPixelStorei;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glPointParameterx_enc(void *self , GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointParameterx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glPointParameterxv_enc(void *self , GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointParameterxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glPointSizex_enc(void *self , GLfixed size)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointSizex;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+}
+
+void glPolygonOffsetx_enc(void *self , GLfixed factor, GLfixed units)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPolygonOffsetx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &factor, 4); ptr += 4;
+		memcpy(ptr, &units, 4); ptr += 4;
+}
+
+void glPopMatrix_enc(void *self )
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPopMatrix;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+void glPushMatrix_enc(void *self )
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPushMatrix;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+void glReadPixels_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels =  pixelDataSize(self, width, height, format, type, 1);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glReadPixels;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_pixels; ptr += 4;
+	stream->readback(pixels, __size_pixels);
+}
+
+void glRotatex_enc(void *self , GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glRotatex;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &angle, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glSampleCoverage_enc(void *self , GLclampf value, GLboolean invert)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glSampleCoverage;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &value, 4); ptr += 4;
+		memcpy(ptr, &invert, 1); ptr += 1;
+}
+
+void glSampleCoveragex_enc(void *self , GLclampx value, GLboolean invert)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glSampleCoveragex;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &value, 4); ptr += 4;
+		memcpy(ptr, &invert, 1); ptr += 1;
+}
+
+void glScalex_enc(void *self , GLfixed x, GLfixed y, GLfixed z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glScalex;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glScissor_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glScissor;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glShadeModel_enc(void *self , GLenum mode)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glShadeModel;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+void glStencilFunc_enc(void *self , GLenum func, GLint ref, GLuint mask)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &func, 4); ptr += 4;
+		memcpy(ptr, &ref, 4); ptr += 4;
+		memcpy(ptr, &mask, 4); ptr += 4;
+}
+
+void glStencilMask_enc(void *self , GLuint mask)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilMask;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mask, 4); ptr += 4;
+}
+
+void glStencilOp_enc(void *self , GLenum fail, GLenum zfail, GLenum zpass)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilOp;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &fail, 4); ptr += 4;
+		memcpy(ptr, &zfail, 4); ptr += 4;
+		memcpy(ptr, &zpass, 4); ptr += 4;
+}
+
+void glTexEnvi_enc(void *self , GLenum target, GLenum pname, GLint param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexEnvi;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexEnvx_enc(void *self , GLenum target, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexEnvx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexEnviv_enc(void *self , GLenum target, GLenum pname, const GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexEnviv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexEnvxv_enc(void *self , GLenum target, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexEnvxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexImage2D_enc(void *self , GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels = ((pixels != NULL) ?  pixelDataSize(self, width, height, format, type, 0) : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &border, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_pixels,4);
+	if (pixels != NULL) stream->writeFully(pixels, __size_pixels);
+}
+
+void glTexParameteri_enc(void *self , GLenum target, GLenum pname, GLint param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameteri;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexParameterx_enc(void *self , GLenum target, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameterx;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexParameteriv_enc(void *self , GLenum target, GLenum pname, const GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexParameterxv_enc(void *self , GLenum target, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameterxv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels =  pixelDataSize(self, width, height, format, type, 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_pixels,4);
+	stream->writeFully(pixels, __size_pixels);
+}
+
+void glTranslatex_enc(void *self , GLfixed x, GLfixed y, GLfixed z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTranslatex;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glViewport_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glViewport;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glVertexPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glColorPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glColorPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glNormalPointerOffset_enc(void *self , GLenum type, GLsizei stride, GLuint offset)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glNormalPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glPointSizePointerOffset_enc(void *self , GLenum type, GLsizei stride, GLuint offset)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointSizePointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glTexCoordPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexCoordPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glWeightPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glWeightPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glMatrixIndexPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMatrixIndexPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glVertexPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexPointerData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glColorPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glColorPointerData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glNormalPointerData_enc(void *self , GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glNormalPointerData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 3, type, stride, datalen);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glTexCoordPointerData_enc(void *self , GLint unit, GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexCoordPointerData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &unit, 4); ptr += 4;
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glPointSizePointerData_enc(void *self , GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointSizePointerData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 1, type, stride, datalen);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glWeightPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glWeightPointerData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glMatrixIndexPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMatrixIndexPointerData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &stride, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glDrawElementsOffset_enc(void *self , GLenum mode, GLsizei count, GLenum type, GLuint offset)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawElementsOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glDrawElementsData_enc(void *self , GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawElementsData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	memcpy(ptr, data, __size_data);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glGetCompressedTextureFormats_enc(void *self , int count, GLint* formats)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_formats =  (count * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_formats + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetCompressedTextureFormats;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_formats; ptr += 4;
+	stream->readback(formats, __size_formats);
+}
+
+int glFinishRoundTrip_enc(void *self )
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFinishRoundTrip;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+
+	int retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glBlendEquationSeparateOES_enc(void *self , GLenum modeRGB, GLenum modeAlpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendEquationSeparateOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &modeRGB, 4); ptr += 4;
+		memcpy(ptr, &modeAlpha, 4); ptr += 4;
+}
+
+void glBlendFuncSeparateOES_enc(void *self , GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendFuncSeparateOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &srcRGB, 4); ptr += 4;
+		memcpy(ptr, &dstRGB, 4); ptr += 4;
+		memcpy(ptr, &srcAlpha, 4); ptr += 4;
+		memcpy(ptr, &dstAlpha, 4); ptr += 4;
+}
+
+void glBlendEquationOES_enc(void *self , GLenum mode)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendEquationOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+void glDrawTexsOES_enc(void *self , GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 2 + 2 + 2 + 2 + 2;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawTexsOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 2); ptr += 2;
+		memcpy(ptr, &y, 2); ptr += 2;
+		memcpy(ptr, &z, 2); ptr += 2;
+		memcpy(ptr, &width, 2); ptr += 2;
+		memcpy(ptr, &height, 2); ptr += 2;
+}
+
+void glDrawTexiOES_enc(void *self , GLint x, GLint y, GLint z, GLint width, GLint height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawTexiOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glDrawTexxOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawTexxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glDrawTexsvOES_enc(void *self , const GLshort* coords)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_coords =  (5 * sizeof(GLshort));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_coords + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawTexsvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_coords; ptr += 4;
+	memcpy(ptr, coords, __size_coords);ptr += __size_coords;
+}
+
+void glDrawTexivOES_enc(void *self , const GLint* coords)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_coords =  (5 * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_coords + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawTexivOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_coords; ptr += 4;
+	memcpy(ptr, coords, __size_coords);ptr += __size_coords;
+}
+
+void glDrawTexxvOES_enc(void *self , const GLfixed* coords)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_coords =  (5 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_coords + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawTexxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_coords; ptr += 4;
+	memcpy(ptr, coords, __size_coords);ptr += __size_coords;
+}
+
+void glDrawTexfOES_enc(void *self , GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawTexfOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glDrawTexfvOES_enc(void *self , const GLfloat* coords)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_coords =  (5 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_coords + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawTexfvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_coords; ptr += 4;
+	memcpy(ptr, coords, __size_coords);ptr += __size_coords;
+}
+
+void glEGLImageTargetTexture2DOES_enc(void *self , GLenum target, GLeglImageOES image)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEGLImageTargetTexture2DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &image, 4); ptr += 4;
+}
+
+void glEGLImageTargetRenderbufferStorageOES_enc(void *self , GLenum target, GLeglImageOES image)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEGLImageTargetRenderbufferStorageOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &image, 4); ptr += 4;
+}
+
+void glAlphaFuncxOES_enc(void *self , GLenum func, GLclampx ref)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glAlphaFuncxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &func, 4); ptr += 4;
+		memcpy(ptr, &ref, 4); ptr += 4;
+}
+
+void glClearColorxOES_enc(void *self , GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearColorxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 4); ptr += 4;
+		memcpy(ptr, &green, 4); ptr += 4;
+		memcpy(ptr, &blue, 4); ptr += 4;
+		memcpy(ptr, &alpha, 4); ptr += 4;
+}
+
+void glClearDepthxOES_enc(void *self , GLclampx depth)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearDepthxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &depth, 4); ptr += 4;
+}
+
+void glClipPlanexOES_enc(void *self , GLenum plane, const GLfixed* equation)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_equation =  (4 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_equation + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClipPlanexOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &plane, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_equation; ptr += 4;
+	memcpy(ptr, equation, __size_equation);ptr += __size_equation;
+}
+
+void glClipPlanexIMG_enc(void *self , GLenum plane, const GLfixed* equation)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_equation =  (4 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_equation + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClipPlanexIMG;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &plane, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_equation; ptr += 4;
+	memcpy(ptr, equation, __size_equation);ptr += __size_equation;
+}
+
+void glColor4xOES_enc(void *self , GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glColor4xOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 4); ptr += 4;
+		memcpy(ptr, &green, 4); ptr += 4;
+		memcpy(ptr, &blue, 4); ptr += 4;
+		memcpy(ptr, &alpha, 4); ptr += 4;
+}
+
+void glDepthRangexOES_enc(void *self , GLclampx zNear, GLclampx zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthRangexOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glFogxOES_enc(void *self , GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFogxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glFogxvOES_enc(void *self , GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFogxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glFrustumxOES_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFrustumxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &left, 4); ptr += 4;
+		memcpy(ptr, &right, 4); ptr += 4;
+		memcpy(ptr, &bottom, 4); ptr += 4;
+		memcpy(ptr, &top, 4); ptr += 4;
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glGetClipPlanexOES_enc(void *self , GLenum pname, GLfixed* eqn)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_eqn =  (4 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_eqn + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetClipPlanexOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_eqn; ptr += 4;
+	stream->readback(eqn, __size_eqn);
+}
+
+void glGetClipPlanex_enc(void *self , GLenum pname, GLfixed* eqn)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_eqn =  (4 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_eqn + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetClipPlanex;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_eqn; ptr += 4;
+	stream->readback(eqn, __size_eqn);
+}
+
+void glGetFixedvOES_enc(void *self , GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetFixedvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetLightxvOES_enc(void *self , GLenum light, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetLightxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetMaterialxvOES_enc(void *self , GLenum face, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetMaterialxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexEnvxvOES_enc(void *self , GLenum env, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexEnvxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &env, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexParameterxvOES_enc(void *self , GLenum target, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexParameterxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glLightModelxOES_enc(void *self , GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightModelxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glLightModelxvOES_enc(void *self , GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightModelxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glLightxOES_enc(void *self , GLenum light, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glLightxvOES_enc(void *self , GLenum light, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLightxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &light, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glLineWidthxOES_enc(void *self , GLfixed width)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLineWidthxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &width, 4); ptr += 4;
+}
+
+void glLoadMatrixxOES_enc(void *self , const GLfixed* m)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_m =  (16 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_m + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLoadMatrixxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_m; ptr += 4;
+	memcpy(ptr, m, __size_m);ptr += __size_m;
+}
+
+void glMaterialxOES_enc(void *self , GLenum face, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMaterialxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glMaterialxvOES_enc(void *self , GLenum face, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMaterialxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glMultMatrixxOES_enc(void *self , const GLfixed* m)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_m =  (16 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_m + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMultMatrixxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_m; ptr += 4;
+	memcpy(ptr, m, __size_m);ptr += __size_m;
+}
+
+void glMultiTexCoord4xOES_enc(void *self , GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glMultiTexCoord4xOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &s, 4); ptr += 4;
+		memcpy(ptr, &t, 4); ptr += 4;
+		memcpy(ptr, &r, 4); ptr += 4;
+		memcpy(ptr, &q, 4); ptr += 4;
+}
+
+void glNormal3xOES_enc(void *self , GLfixed nx, GLfixed ny, GLfixed nz)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glNormal3xOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &nx, 4); ptr += 4;
+		memcpy(ptr, &ny, 4); ptr += 4;
+		memcpy(ptr, &nz, 4); ptr += 4;
+}
+
+void glOrthoxOES_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glOrthoxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &left, 4); ptr += 4;
+		memcpy(ptr, &right, 4); ptr += 4;
+		memcpy(ptr, &bottom, 4); ptr += 4;
+		memcpy(ptr, &top, 4); ptr += 4;
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glPointParameterxOES_enc(void *self , GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointParameterxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glPointParameterxvOES_enc(void *self , GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointParameterxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glPointSizexOES_enc(void *self , GLfixed size)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPointSizexOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &size, 4); ptr += 4;
+}
+
+void glPolygonOffsetxOES_enc(void *self , GLfixed factor, GLfixed units)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPolygonOffsetxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &factor, 4); ptr += 4;
+		memcpy(ptr, &units, 4); ptr += 4;
+}
+
+void glRotatexOES_enc(void *self , GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glRotatexOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &angle, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glSampleCoveragexOES_enc(void *self , GLclampx value, GLboolean invert)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glSampleCoveragexOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &value, 4); ptr += 4;
+		memcpy(ptr, &invert, 1); ptr += 1;
+}
+
+void glScalexOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glScalexOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glTexEnvxOES_enc(void *self , GLenum target, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexEnvxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexEnvxvOES_enc(void *self , GLenum target, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexEnvxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexParameterxOES_enc(void *self , GLenum target, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameterxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexParameterxvOES_enc(void *self , GLenum target, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameterxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTranslatexOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTranslatexOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+GLboolean glIsRenderbufferOES_enc(void *self , GLuint renderbuffer)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsRenderbufferOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &renderbuffer, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glBindRenderbufferOES_enc(void *self , GLenum target, GLuint renderbuffer)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindRenderbufferOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &renderbuffer, 4); ptr += 4;
+}
+
+void glDeleteRenderbuffersOES_enc(void *self , GLsizei n, const GLuint* renderbuffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_renderbuffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_renderbuffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteRenderbuffersOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4;
+	memcpy(ptr, renderbuffers, __size_renderbuffers);ptr += __size_renderbuffers;
+}
+
+void glGenRenderbuffersOES_enc(void *self , GLsizei n, GLuint* renderbuffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_renderbuffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_renderbuffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenRenderbuffersOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4;
+	stream->readback(renderbuffers, __size_renderbuffers);
+}
+
+void glRenderbufferStorageOES_enc(void *self , GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glRenderbufferStorageOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glGetRenderbufferParameterivOES_enc(void *self , GLenum target, GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetRenderbufferParameterivOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+GLboolean glIsFramebufferOES_enc(void *self , GLuint framebuffer)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsFramebufferOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &framebuffer, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glBindFramebufferOES_enc(void *self , GLenum target, GLuint framebuffer)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindFramebufferOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &framebuffer, 4); ptr += 4;
+}
+
+void glDeleteFramebuffersOES_enc(void *self , GLsizei n, const GLuint* framebuffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_framebuffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_framebuffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteFramebuffersOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_framebuffers; ptr += 4;
+	memcpy(ptr, framebuffers, __size_framebuffers);ptr += __size_framebuffers;
+}
+
+void glGenFramebuffersOES_enc(void *self , GLsizei n, GLuint* framebuffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_framebuffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_framebuffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenFramebuffersOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_framebuffers; ptr += 4;
+	stream->readback(framebuffers, __size_framebuffers);
+}
+
+GLenum glCheckFramebufferStatusOES_enc(void *self , GLenum target)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCheckFramebufferStatusOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+
+	GLenum retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glFramebufferRenderbufferOES_enc(void *self , GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFramebufferRenderbufferOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &attachment, 4); ptr += 4;
+		memcpy(ptr, &renderbuffertarget, 4); ptr += 4;
+		memcpy(ptr, &renderbuffer, 4); ptr += 4;
+}
+
+void glFramebufferTexture2DOES_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFramebufferTexture2DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &attachment, 4); ptr += 4;
+		memcpy(ptr, &textarget, 4); ptr += 4;
+		memcpy(ptr, &texture, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+}
+
+void glGetFramebufferAttachmentParameterivOES_enc(void *self , GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetFramebufferAttachmentParameterivOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &attachment, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGenerateMipmapOES_enc(void *self , GLenum target)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenerateMipmapOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+}
+
+GLboolean glUnmapBufferOES_enc(void *self , GLenum target)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUnmapBufferOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glCurrentPaletteMatrixOES_enc(void *self , GLuint matrixpaletteindex)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCurrentPaletteMatrixOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &matrixpaletteindex, 4); ptr += 4;
+}
+
+void glLoadPaletteFromModelViewMatrixOES_enc(void *self )
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLoadPaletteFromModelViewMatrixOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+GLbitfield glQueryMatrixxOES_enc(void *self , GLfixed* mantissa, GLint* exponent)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_mantissa =  (16 * sizeof(GLfixed));
+	const unsigned int __size_exponent =  (16 * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_mantissa + __size_exponent + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glQueryMatrixxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_mantissa; ptr += 4;
+	*(unsigned int *)(ptr) = __size_exponent; ptr += 4;
+	stream->readback(mantissa, __size_mantissa);
+	stream->readback(exponent, __size_exponent);
+
+	GLbitfield retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glDepthRangefOES_enc(void *self , GLclampf zNear, GLclampf zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthRangefOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glFrustumfOES_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFrustumfOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &left, 4); ptr += 4;
+		memcpy(ptr, &right, 4); ptr += 4;
+		memcpy(ptr, &bottom, 4); ptr += 4;
+		memcpy(ptr, &top, 4); ptr += 4;
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glOrthofOES_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glOrthofOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &left, 4); ptr += 4;
+		memcpy(ptr, &right, 4); ptr += 4;
+		memcpy(ptr, &bottom, 4); ptr += 4;
+		memcpy(ptr, &top, 4); ptr += 4;
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glClipPlanefOES_enc(void *self , GLenum plane, const GLfloat* equation)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_equation =  (4 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_equation + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClipPlanefOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &plane, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_equation; ptr += 4;
+	memcpy(ptr, equation, __size_equation);ptr += __size_equation;
+}
+
+void glClipPlanefIMG_enc(void *self , GLenum plane, const GLfloat* equation)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_equation =  (4 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_equation + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClipPlanefIMG;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &plane, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_equation; ptr += 4;
+	memcpy(ptr, equation, __size_equation);ptr += __size_equation;
+}
+
+void glGetClipPlanefOES_enc(void *self , GLenum pname, GLfloat* eqn)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_eqn =  (4 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_eqn + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetClipPlanefOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_eqn; ptr += 4;
+	stream->readback(eqn, __size_eqn);
+}
+
+void glClearDepthfOES_enc(void *self , GLclampf depth)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearDepthfOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &depth, 4); ptr += 4;
+}
+
+void glTexGenfOES_enc(void *self , GLenum coord, GLenum pname, GLfloat param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexGenfOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexGenfvOES_enc(void *self , GLenum coord, GLenum pname, const GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexGenfvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexGeniOES_enc(void *self , GLenum coord, GLenum pname, GLint param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexGeniOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexGenivOES_enc(void *self , GLenum coord, GLenum pname, const GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexGenivOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexGenxOES_enc(void *self , GLenum coord, GLenum pname, GLfixed param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexGenxOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexGenxvOES_enc(void *self , GLenum coord, GLenum pname, const GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexGenxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glGetTexGenfvOES_enc(void *self , GLenum coord, GLenum pname, GLfloat* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexGenfvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glGetTexGenivOES_enc(void *self , GLenum coord, GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexGenivOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glGetTexGenxvOES_enc(void *self , GLenum coord, GLenum pname, GLfixed* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfixed));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexGenxvOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &coord, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glBindVertexArrayOES_enc(void *self , GLuint array)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &array, 4); ptr += 4;
+}
+
+void glDeleteVertexArraysOES_enc(void *self , GLsizei n, const GLuint* arrays)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_arrays =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_arrays + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_arrays; ptr += 4;
+	memcpy(ptr, arrays, __size_arrays);ptr += __size_arrays;
+}
+
+void glGenVertexArraysOES_enc(void *self , GLsizei n, GLuint* arrays)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_arrays =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_arrays + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_arrays; ptr += 4;
+	stream->readback(arrays, __size_arrays);
+}
+
+GLboolean glIsVertexArrayOES_enc(void *self , GLuint array)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &array, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glDiscardFramebufferEXT_enc(void *self , GLenum target, GLsizei numAttachments, const GLenum* attachments)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_attachments =  (numAttachments * sizeof(const GLenum));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_attachments + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDiscardFramebufferEXT;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &numAttachments, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_attachments; ptr += 4;
+	memcpy(ptr, attachments, __size_attachments);ptr += __size_attachments;
+}
+
+void glRenderbufferStorageMultisampleIMG_enc(void *self , GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glRenderbufferStorageMultisampleIMG;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &samples, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glFramebufferTexture2DMultisampleIMG_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFramebufferTexture2DMultisampleIMG;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &attachment, 4); ptr += 4;
+		memcpy(ptr, &textarget, 4); ptr += 4;
+		memcpy(ptr, &texture, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &samples, 4); ptr += 4;
+}
+
+void glDeleteFencesNV_enc(void *self , GLsizei n, const GLuint* fences)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_fences =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_fences + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteFencesNV;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_fences; ptr += 4;
+	memcpy(ptr, fences, __size_fences);ptr += __size_fences;
+}
+
+void glGenFencesNV_enc(void *self , GLsizei n, GLuint* fences)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_fences =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_fences + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenFencesNV;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_fences; ptr += 4;
+	memcpy(ptr, fences, __size_fences);ptr += __size_fences;
+}
+
+GLboolean glIsFenceNV_enc(void *self , GLuint fence)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsFenceNV;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &fence, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glTestFenceNV_enc(void *self , GLuint fence)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTestFenceNV;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &fence, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glGetFenceivNV_enc(void *self , GLuint fence, GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetFenceivNV;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &fence, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glFinishFenceNV_enc(void *self , GLuint fence)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFinishFenceNV;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &fence, 4); ptr += 4;
+}
+
+void glSetFenceNV_enc(void *self , GLuint fence, GLenum condition)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glSetFenceNV;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &fence, 4); ptr += 4;
+		memcpy(ptr, &condition, 4); ptr += 4;
+}
+
+void glGetDriverControlsQCOM_enc(void *self , GLint* num, GLsizei size, GLuint* driverControls)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_num =  (1 * sizeof(GLint));
+	const unsigned int __size_driverControls =  (size * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_num + 4 + __size_driverControls + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetDriverControlsQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_num; ptr += 4;
+		memcpy(ptr, &size, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_driverControls; ptr += 4;
+	stream->readback(num, __size_num);
+	stream->readback(driverControls, __size_driverControls);
+}
+
+void glGetDriverControlStringQCOM_enc(void *self , GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_length =  (1 * sizeof(GLsizei));
+	const unsigned int __size_driverControlString =  (1 * sizeof(GLchar));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_length + __size_driverControlString + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetDriverControlStringQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &driverControl, 4); ptr += 4;
+		memcpy(ptr, &bufSize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_length; ptr += 4;
+	*(unsigned int *)(ptr) = __size_driverControlString; ptr += 4;
+	stream->readback(length, __size_length);
+	stream->readback(driverControlString, __size_driverControlString);
+}
+
+void glEnableDriverControlQCOM_enc(void *self , GLuint driverControl)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEnableDriverControlQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &driverControl, 4); ptr += 4;
+}
+
+void glDisableDriverControlQCOM_enc(void *self , GLuint driverControl)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDisableDriverControlQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &driverControl, 4); ptr += 4;
+}
+
+void glExtGetTexturesQCOM_enc(void *self , GLuint* textures, GLint maxTextures, GLint* numTextures)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_textures =  (maxTextures * sizeof(GLuint));
+	const unsigned int __size_numTextures =  (1 * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_textures + 4 + __size_numTextures + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtGetTexturesQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_textures; ptr += 4;
+		memcpy(ptr, &maxTextures, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_numTextures; ptr += 4;
+	stream->readback(textures, __size_textures);
+	stream->readback(numTextures, __size_numTextures);
+}
+
+void glExtGetBuffersQCOM_enc(void *self , GLuint* buffers, GLint maxBuffers, GLint* numBuffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_buffers =  (maxBuffers * sizeof(GLuint));
+	const unsigned int __size_numBuffers =  (1 * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_buffers + 4 + __size_numBuffers + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtGetBuffersQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_buffers; ptr += 4;
+		memcpy(ptr, &maxBuffers, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_numBuffers; ptr += 4;
+	stream->readback(buffers, __size_buffers);
+	stream->readback(numBuffers, __size_numBuffers);
+}
+
+void glExtGetRenderbuffersQCOM_enc(void *self , GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_renderbuffers =  (maxRenderbuffers * sizeof(GLuint));
+	const unsigned int __size_numRenderbuffers =  (1 * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_renderbuffers + 4 + __size_numRenderbuffers + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtGetRenderbuffersQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4;
+		memcpy(ptr, &maxRenderbuffers, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_numRenderbuffers; ptr += 4;
+	stream->readback(renderbuffers, __size_renderbuffers);
+	stream->readback(numRenderbuffers, __size_numRenderbuffers);
+}
+
+void glExtGetFramebuffersQCOM_enc(void *self , GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_framebuffers =  (maxFramebuffers * sizeof(GLuint));
+	const unsigned int __size_numFramebuffers =  (1 * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_framebuffers + 4 + __size_numFramebuffers + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtGetFramebuffersQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_framebuffers; ptr += 4;
+		memcpy(ptr, &maxFramebuffers, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_numFramebuffers; ptr += 4;
+	stream->readback(framebuffers, __size_framebuffers);
+	stream->readback(numFramebuffers, __size_numFramebuffers);
+}
+
+void glExtGetTexLevelParameterivQCOM_enc(void *self , GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtGetTexLevelParameterivQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &texture, 4); ptr += 4;
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glExtTexObjectStateOverrideiQCOM_enc(void *self , GLenum target, GLenum pname, GLint param)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtTexObjectStateOverrideiQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glExtGetTexSubImageQCOM_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* texels)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_texels =  (depth * pixelDataSize(self, width, height, format, type, 0));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_texels + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtGetTexSubImageQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &zoffset, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &depth, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_texels; ptr += 4;
+	stream->readback(texels, __size_texels);
+}
+
+void glExtGetShadersQCOM_enc(void *self , GLuint* shaders, GLint maxShaders, GLint* numShaders)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_shaders =  (maxShaders * sizeof(GLuint));
+	const unsigned int __size_numShaders =  (1 * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_shaders + 4 + __size_numShaders + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtGetShadersQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_shaders; ptr += 4;
+		memcpy(ptr, &maxShaders, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_numShaders; ptr += 4;
+	stream->readback(shaders, __size_shaders);
+	stream->readback(numShaders, __size_numShaders);
+}
+
+void glExtGetProgramsQCOM_enc(void *self , GLuint* programs, GLint maxPrograms, GLint* numPrograms)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_programs =  (maxPrograms * sizeof(GLuint));
+	const unsigned int __size_numPrograms =  (1 * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_programs + 4 + __size_numPrograms + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtGetProgramsQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_programs; ptr += 4;
+		memcpy(ptr, &maxPrograms, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_numPrograms; ptr += 4;
+	stream->readback(programs, __size_programs);
+	stream->readback(numPrograms, __size_numPrograms);
+}
+
+GLboolean glExtIsProgramBinaryQCOM_enc(void *self , GLuint program)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glExtIsProgramBinaryQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glStartTilingQCOM_enc(void *self , GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStartTilingQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &preserveMask, 4); ptr += 4;
+}
+
+void glEndTilingQCOM_enc(void *self , GLbitfield preserveMask)
+{
+
+	gl_encoder_context_t *ctx = (gl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEndTilingQCOM;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &preserveMask, 4); ptr += 4;
+}
+
+gl_encoder_context_t::gl_encoder_context_t(IOStream *stream)
+{
+	m_stream = stream;
+
+	set_glAlphaFunc(glAlphaFunc_enc);
+	set_glClearColor(glClearColor_enc);
+	set_glClearDepthf(glClearDepthf_enc);
+	set_glClipPlanef(glClipPlanef_enc);
+	set_glColor4f(glColor4f_enc);
+	set_glDepthRangef(glDepthRangef_enc);
+	set_glFogf(glFogf_enc);
+	set_glFogfv(glFogfv_enc);
+	set_glFrustumf(glFrustumf_enc);
+	set_glGetClipPlanef(glGetClipPlanef_enc);
+	set_glGetFloatv(glGetFloatv_enc);
+	set_glGetLightfv(glGetLightfv_enc);
+	set_glGetMaterialfv(glGetMaterialfv_enc);
+	set_glGetTexEnvfv(glGetTexEnvfv_enc);
+	set_glGetTexParameterfv(glGetTexParameterfv_enc);
+	set_glLightModelf(glLightModelf_enc);
+	set_glLightModelfv(glLightModelfv_enc);
+	set_glLightf(glLightf_enc);
+	set_glLightfv(glLightfv_enc);
+	set_glLineWidth(glLineWidth_enc);
+	set_glLoadMatrixf(glLoadMatrixf_enc);
+	set_glMaterialf(glMaterialf_enc);
+	set_glMaterialfv(glMaterialfv_enc);
+	set_glMultMatrixf(glMultMatrixf_enc);
+	set_glMultiTexCoord4f(glMultiTexCoord4f_enc);
+	set_glNormal3f(glNormal3f_enc);
+	set_glOrthof(glOrthof_enc);
+	set_glPointParameterf(glPointParameterf_enc);
+	set_glPointParameterfv(glPointParameterfv_enc);
+	set_glPointSize(glPointSize_enc);
+	set_glPolygonOffset(glPolygonOffset_enc);
+	set_glRotatef(glRotatef_enc);
+	set_glScalef(glScalef_enc);
+	set_glTexEnvf(glTexEnvf_enc);
+	set_glTexEnvfv(glTexEnvfv_enc);
+	set_glTexParameterf(glTexParameterf_enc);
+	set_glTexParameterfv(glTexParameterfv_enc);
+	set_glTranslatef(glTranslatef_enc);
+	set_glActiveTexture(glActiveTexture_enc);
+	set_glAlphaFuncx(glAlphaFuncx_enc);
+	set_glBindBuffer(glBindBuffer_enc);
+	set_glBindTexture(glBindTexture_enc);
+	set_glBlendFunc(glBlendFunc_enc);
+	set_glBufferData(glBufferData_enc);
+	set_glBufferSubData(glBufferSubData_enc);
+	set_glClear(glClear_enc);
+	set_glClearColorx(glClearColorx_enc);
+	set_glClearDepthx(glClearDepthx_enc);
+	set_glClearStencil(glClearStencil_enc);
+	set_glClientActiveTexture(glClientActiveTexture_enc);
+	set_glColor4ub(glColor4ub_enc);
+	set_glColor4x(glColor4x_enc);
+	set_glColorMask(glColorMask_enc);
+	set_glColorPointer((glColorPointer_client_proc_t)(enc_unsupported));
+	set_glCompressedTexImage2D(glCompressedTexImage2D_enc);
+	set_glCompressedTexSubImage2D(glCompressedTexSubImage2D_enc);
+	set_glCopyTexImage2D(glCopyTexImage2D_enc);
+	set_glCopyTexSubImage2D(glCopyTexSubImage2D_enc);
+	set_glCullFace(glCullFace_enc);
+	set_glDeleteBuffers(glDeleteBuffers_enc);
+	set_glDeleteTextures(glDeleteTextures_enc);
+	set_glDepthFunc(glDepthFunc_enc);
+	set_glDepthMask(glDepthMask_enc);
+	set_glDepthRangex(glDepthRangex_enc);
+	set_glDisable(glDisable_enc);
+	set_glDisableClientState(glDisableClientState_enc);
+	set_glDrawArrays(glDrawArrays_enc);
+	set_glDrawElements((glDrawElements_client_proc_t)(enc_unsupported));
+	set_glEnable(glEnable_enc);
+	set_glEnableClientState(glEnableClientState_enc);
+	set_glFinish(glFinish_enc);
+	set_glFlush(glFlush_enc);
+	set_glFogx(glFogx_enc);
+	set_glFogxv(glFogxv_enc);
+	set_glFrontFace(glFrontFace_enc);
+	set_glFrustumx(glFrustumx_enc);
+	set_glGetBooleanv(glGetBooleanv_enc);
+	set_glGetBufferParameteriv(glGetBufferParameteriv_enc);
+	set_glClipPlanex(glClipPlanex_enc);
+	set_glGenBuffers(glGenBuffers_enc);
+	set_glGenTextures(glGenTextures_enc);
+	set_glGetError(glGetError_enc);
+	set_glGetFixedv(glGetFixedv_enc);
+	set_glGetIntegerv(glGetIntegerv_enc);
+	set_glGetLightxv(glGetLightxv_enc);
+	set_glGetMaterialxv(glGetMaterialxv_enc);
+	set_glGetPointerv((glGetPointerv_client_proc_t)(enc_unsupported));
+	set_glGetString((glGetString_client_proc_t)(enc_unsupported));
+	set_glGetTexEnviv(glGetTexEnviv_enc);
+	set_glGetTexEnvxv(glGetTexEnvxv_enc);
+	set_glGetTexParameteriv(glGetTexParameteriv_enc);
+	set_glGetTexParameterxv(glGetTexParameterxv_enc);
+	set_glHint(glHint_enc);
+	set_glIsBuffer(glIsBuffer_enc);
+	set_glIsEnabled(glIsEnabled_enc);
+	set_glIsTexture(glIsTexture_enc);
+	set_glLightModelx(glLightModelx_enc);
+	set_glLightModelxv(glLightModelxv_enc);
+	set_glLightx(glLightx_enc);
+	set_glLightxv(glLightxv_enc);
+	set_glLineWidthx(glLineWidthx_enc);
+	set_glLoadIdentity(glLoadIdentity_enc);
+	set_glLoadMatrixx(glLoadMatrixx_enc);
+	set_glLogicOp(glLogicOp_enc);
+	set_glMaterialx(glMaterialx_enc);
+	set_glMaterialxv(glMaterialxv_enc);
+	set_glMatrixMode(glMatrixMode_enc);
+	set_glMultMatrixx(glMultMatrixx_enc);
+	set_glMultiTexCoord4x(glMultiTexCoord4x_enc);
+	set_glNormal3x(glNormal3x_enc);
+	set_glNormalPointer((glNormalPointer_client_proc_t)(enc_unsupported));
+	set_glOrthox(glOrthox_enc);
+	set_glPixelStorei(glPixelStorei_enc);
+	set_glPointParameterx(glPointParameterx_enc);
+	set_glPointParameterxv(glPointParameterxv_enc);
+	set_glPointSizex(glPointSizex_enc);
+	set_glPolygonOffsetx(glPolygonOffsetx_enc);
+	set_glPopMatrix(glPopMatrix_enc);
+	set_glPushMatrix(glPushMatrix_enc);
+	set_glReadPixels(glReadPixels_enc);
+	set_glRotatex(glRotatex_enc);
+	set_glSampleCoverage(glSampleCoverage_enc);
+	set_glSampleCoveragex(glSampleCoveragex_enc);
+	set_glScalex(glScalex_enc);
+	set_glScissor(glScissor_enc);
+	set_glShadeModel(glShadeModel_enc);
+	set_glStencilFunc(glStencilFunc_enc);
+	set_glStencilMask(glStencilMask_enc);
+	set_glStencilOp(glStencilOp_enc);
+	set_glTexCoordPointer((glTexCoordPointer_client_proc_t)(enc_unsupported));
+	set_glTexEnvi(glTexEnvi_enc);
+	set_glTexEnvx(glTexEnvx_enc);
+	set_glTexEnviv(glTexEnviv_enc);
+	set_glTexEnvxv(glTexEnvxv_enc);
+	set_glTexImage2D(glTexImage2D_enc);
+	set_glTexParameteri(glTexParameteri_enc);
+	set_glTexParameterx(glTexParameterx_enc);
+	set_glTexParameteriv(glTexParameteriv_enc);
+	set_glTexParameterxv(glTexParameterxv_enc);
+	set_glTexSubImage2D(glTexSubImage2D_enc);
+	set_glTranslatex(glTranslatex_enc);
+	set_glVertexPointer((glVertexPointer_client_proc_t)(enc_unsupported));
+	set_glViewport(glViewport_enc);
+	set_glPointSizePointerOES((glPointSizePointerOES_client_proc_t)(enc_unsupported));
+	set_glVertexPointerOffset(glVertexPointerOffset_enc);
+	set_glColorPointerOffset(glColorPointerOffset_enc);
+	set_glNormalPointerOffset(glNormalPointerOffset_enc);
+	set_glPointSizePointerOffset(glPointSizePointerOffset_enc);
+	set_glTexCoordPointerOffset(glTexCoordPointerOffset_enc);
+	set_glWeightPointerOffset(glWeightPointerOffset_enc);
+	set_glMatrixIndexPointerOffset(glMatrixIndexPointerOffset_enc);
+	set_glVertexPointerData(glVertexPointerData_enc);
+	set_glColorPointerData(glColorPointerData_enc);
+	set_glNormalPointerData(glNormalPointerData_enc);
+	set_glTexCoordPointerData(glTexCoordPointerData_enc);
+	set_glPointSizePointerData(glPointSizePointerData_enc);
+	set_glWeightPointerData(glWeightPointerData_enc);
+	set_glMatrixIndexPointerData(glMatrixIndexPointerData_enc);
+	set_glDrawElementsOffset(glDrawElementsOffset_enc);
+	set_glDrawElementsData(glDrawElementsData_enc);
+	set_glGetCompressedTextureFormats(glGetCompressedTextureFormats_enc);
+	set_glFinishRoundTrip(glFinishRoundTrip_enc);
+	set_glBlendEquationSeparateOES(glBlendEquationSeparateOES_enc);
+	set_glBlendFuncSeparateOES(glBlendFuncSeparateOES_enc);
+	set_glBlendEquationOES(glBlendEquationOES_enc);
+	set_glDrawTexsOES(glDrawTexsOES_enc);
+	set_glDrawTexiOES(glDrawTexiOES_enc);
+	set_glDrawTexxOES(glDrawTexxOES_enc);
+	set_glDrawTexsvOES(glDrawTexsvOES_enc);
+	set_glDrawTexivOES(glDrawTexivOES_enc);
+	set_glDrawTexxvOES(glDrawTexxvOES_enc);
+	set_glDrawTexfOES(glDrawTexfOES_enc);
+	set_glDrawTexfvOES(glDrawTexfvOES_enc);
+	set_glEGLImageTargetTexture2DOES(glEGLImageTargetTexture2DOES_enc);
+	set_glEGLImageTargetRenderbufferStorageOES(glEGLImageTargetRenderbufferStorageOES_enc);
+	set_glAlphaFuncxOES(glAlphaFuncxOES_enc);
+	set_glClearColorxOES(glClearColorxOES_enc);
+	set_glClearDepthxOES(glClearDepthxOES_enc);
+	set_glClipPlanexOES(glClipPlanexOES_enc);
+	set_glClipPlanexIMG(glClipPlanexIMG_enc);
+	set_glColor4xOES(glColor4xOES_enc);
+	set_glDepthRangexOES(glDepthRangexOES_enc);
+	set_glFogxOES(glFogxOES_enc);
+	set_glFogxvOES(glFogxvOES_enc);
+	set_glFrustumxOES(glFrustumxOES_enc);
+	set_glGetClipPlanexOES(glGetClipPlanexOES_enc);
+	set_glGetClipPlanex(glGetClipPlanex_enc);
+	set_glGetFixedvOES(glGetFixedvOES_enc);
+	set_glGetLightxvOES(glGetLightxvOES_enc);
+	set_glGetMaterialxvOES(glGetMaterialxvOES_enc);
+	set_glGetTexEnvxvOES(glGetTexEnvxvOES_enc);
+	set_glGetTexParameterxvOES(glGetTexParameterxvOES_enc);
+	set_glLightModelxOES(glLightModelxOES_enc);
+	set_glLightModelxvOES(glLightModelxvOES_enc);
+	set_glLightxOES(glLightxOES_enc);
+	set_glLightxvOES(glLightxvOES_enc);
+	set_glLineWidthxOES(glLineWidthxOES_enc);
+	set_glLoadMatrixxOES(glLoadMatrixxOES_enc);
+	set_glMaterialxOES(glMaterialxOES_enc);
+	set_glMaterialxvOES(glMaterialxvOES_enc);
+	set_glMultMatrixxOES(glMultMatrixxOES_enc);
+	set_glMultiTexCoord4xOES(glMultiTexCoord4xOES_enc);
+	set_glNormal3xOES(glNormal3xOES_enc);
+	set_glOrthoxOES(glOrthoxOES_enc);
+	set_glPointParameterxOES(glPointParameterxOES_enc);
+	set_glPointParameterxvOES(glPointParameterxvOES_enc);
+	set_glPointSizexOES(glPointSizexOES_enc);
+	set_glPolygonOffsetxOES(glPolygonOffsetxOES_enc);
+	set_glRotatexOES(glRotatexOES_enc);
+	set_glSampleCoveragexOES(glSampleCoveragexOES_enc);
+	set_glScalexOES(glScalexOES_enc);
+	set_glTexEnvxOES(glTexEnvxOES_enc);
+	set_glTexEnvxvOES(glTexEnvxvOES_enc);
+	set_glTexParameterxOES(glTexParameterxOES_enc);
+	set_glTexParameterxvOES(glTexParameterxvOES_enc);
+	set_glTranslatexOES(glTranslatexOES_enc);
+	set_glIsRenderbufferOES(glIsRenderbufferOES_enc);
+	set_glBindRenderbufferOES(glBindRenderbufferOES_enc);
+	set_glDeleteRenderbuffersOES(glDeleteRenderbuffersOES_enc);
+	set_glGenRenderbuffersOES(glGenRenderbuffersOES_enc);
+	set_glRenderbufferStorageOES(glRenderbufferStorageOES_enc);
+	set_glGetRenderbufferParameterivOES(glGetRenderbufferParameterivOES_enc);
+	set_glIsFramebufferOES(glIsFramebufferOES_enc);
+	set_glBindFramebufferOES(glBindFramebufferOES_enc);
+	set_glDeleteFramebuffersOES(glDeleteFramebuffersOES_enc);
+	set_glGenFramebuffersOES(glGenFramebuffersOES_enc);
+	set_glCheckFramebufferStatusOES(glCheckFramebufferStatusOES_enc);
+	set_glFramebufferRenderbufferOES(glFramebufferRenderbufferOES_enc);
+	set_glFramebufferTexture2DOES(glFramebufferTexture2DOES_enc);
+	set_glGetFramebufferAttachmentParameterivOES(glGetFramebufferAttachmentParameterivOES_enc);
+	set_glGenerateMipmapOES(glGenerateMipmapOES_enc);
+	set_glMapBufferOES((glMapBufferOES_client_proc_t)(enc_unsupported));
+	set_glUnmapBufferOES(glUnmapBufferOES_enc);
+	set_glGetBufferPointervOES((glGetBufferPointervOES_client_proc_t)(enc_unsupported));
+	set_glCurrentPaletteMatrixOES(glCurrentPaletteMatrixOES_enc);
+	set_glLoadPaletteFromModelViewMatrixOES(glLoadPaletteFromModelViewMatrixOES_enc);
+	set_glMatrixIndexPointerOES((glMatrixIndexPointerOES_client_proc_t)(enc_unsupported));
+	set_glWeightPointerOES((glWeightPointerOES_client_proc_t)(enc_unsupported));
+	set_glQueryMatrixxOES(glQueryMatrixxOES_enc);
+	set_glDepthRangefOES(glDepthRangefOES_enc);
+	set_glFrustumfOES(glFrustumfOES_enc);
+	set_glOrthofOES(glOrthofOES_enc);
+	set_glClipPlanefOES(glClipPlanefOES_enc);
+	set_glClipPlanefIMG(glClipPlanefIMG_enc);
+	set_glGetClipPlanefOES(glGetClipPlanefOES_enc);
+	set_glClearDepthfOES(glClearDepthfOES_enc);
+	set_glTexGenfOES(glTexGenfOES_enc);
+	set_glTexGenfvOES(glTexGenfvOES_enc);
+	set_glTexGeniOES(glTexGeniOES_enc);
+	set_glTexGenivOES(glTexGenivOES_enc);
+	set_glTexGenxOES(glTexGenxOES_enc);
+	set_glTexGenxvOES(glTexGenxvOES_enc);
+	set_glGetTexGenfvOES(glGetTexGenfvOES_enc);
+	set_glGetTexGenivOES(glGetTexGenivOES_enc);
+	set_glGetTexGenxvOES(glGetTexGenxvOES_enc);
+	set_glBindVertexArrayOES(glBindVertexArrayOES_enc);
+	set_glDeleteVertexArraysOES(glDeleteVertexArraysOES_enc);
+	set_glGenVertexArraysOES(glGenVertexArraysOES_enc);
+	set_glIsVertexArrayOES(glIsVertexArrayOES_enc);
+	set_glDiscardFramebufferEXT(glDiscardFramebufferEXT_enc);
+	set_glMultiDrawArraysEXT((glMultiDrawArraysEXT_client_proc_t)(enc_unsupported));
+	set_glMultiDrawElementsEXT((glMultiDrawElementsEXT_client_proc_t)(enc_unsupported));
+	set_glMultiDrawArraysSUN((glMultiDrawArraysSUN_client_proc_t)(enc_unsupported));
+	set_glMultiDrawElementsSUN((glMultiDrawElementsSUN_client_proc_t)(enc_unsupported));
+	set_glRenderbufferStorageMultisampleIMG(glRenderbufferStorageMultisampleIMG_enc);
+	set_glFramebufferTexture2DMultisampleIMG(glFramebufferTexture2DMultisampleIMG_enc);
+	set_glDeleteFencesNV(glDeleteFencesNV_enc);
+	set_glGenFencesNV(glGenFencesNV_enc);
+	set_glIsFenceNV(glIsFenceNV_enc);
+	set_glTestFenceNV(glTestFenceNV_enc);
+	set_glGetFenceivNV(glGetFenceivNV_enc);
+	set_glFinishFenceNV(glFinishFenceNV_enc);
+	set_glSetFenceNV(glSetFenceNV_enc);
+	set_glGetDriverControlsQCOM(glGetDriverControlsQCOM_enc);
+	set_glGetDriverControlStringQCOM(glGetDriverControlStringQCOM_enc);
+	set_glEnableDriverControlQCOM(glEnableDriverControlQCOM_enc);
+	set_glDisableDriverControlQCOM(glDisableDriverControlQCOM_enc);
+	set_glExtGetTexturesQCOM(glExtGetTexturesQCOM_enc);
+	set_glExtGetBuffersQCOM(glExtGetBuffersQCOM_enc);
+	set_glExtGetRenderbuffersQCOM(glExtGetRenderbuffersQCOM_enc);
+	set_glExtGetFramebuffersQCOM(glExtGetFramebuffersQCOM_enc);
+	set_glExtGetTexLevelParameterivQCOM(glExtGetTexLevelParameterivQCOM_enc);
+	set_glExtTexObjectStateOverrideiQCOM(glExtTexObjectStateOverrideiQCOM_enc);
+	set_glExtGetTexSubImageQCOM(glExtGetTexSubImageQCOM_enc);
+	set_glExtGetBufferPointervQCOM((glExtGetBufferPointervQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetShadersQCOM(glExtGetShadersQCOM_enc);
+	set_glExtGetProgramsQCOM(glExtGetProgramsQCOM_enc);
+	set_glExtIsProgramBinaryQCOM(glExtIsProgramBinaryQCOM_enc);
+	set_glExtGetProgramBinarySourceQCOM((glExtGetProgramBinarySourceQCOM_client_proc_t)(enc_unsupported));
+	set_glStartTilingQCOM(glStartTilingQCOM_enc);
+	set_glEndTilingQCOM(glEndTilingQCOM_enc);
+}
+
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl_enc.h b/tools/emulator/opengl/system/GLESv1_enc/gl_enc.h
new file mode 100644
index 0000000..d8a23e4
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_enc.h
@@ -0,0 +1,316 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+#ifndef GUARD_gl_encoder_context_t
+#define GUARD_gl_encoder_context_t
+
+#include "IOStream.h"
+#include "gl_client_context.h"
+
+
+#include "glUtils.h"
+#include "GLEncoderUtils.h"
+
+struct gl_encoder_context_t : public gl_client_context_t {
+
+	IOStream *m_stream;
+
+	gl_encoder_context_t(IOStream *stream);
+
+
+};
+
+extern "C" {
+	void glAlphaFunc_enc(void *self , GLenum func, GLclampf ref);
+	void glClearColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+	void glClearDepthf_enc(void *self , GLclampf depth);
+	void glClipPlanef_enc(void *self , GLenum plane, const GLfloat* equation);
+	void glColor4f_enc(void *self , GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+	void glDepthRangef_enc(void *self , GLclampf zNear, GLclampf zFar);
+	void glFogf_enc(void *self , GLenum pname, GLfloat param);
+	void glFogfv_enc(void *self , GLenum pname, const GLfloat* params);
+	void glFrustumf_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+	void glGetClipPlanef_enc(void *self , GLenum pname, GLfloat* eqn);
+	void glGetFloatv_enc(void *self , GLenum pname, GLfloat* params);
+	void glGetLightfv_enc(void *self , GLenum light, GLenum pname, GLfloat* params);
+	void glGetMaterialfv_enc(void *self , GLenum face, GLenum pname, GLfloat* params);
+	void glGetTexEnvfv_enc(void *self , GLenum env, GLenum pname, GLfloat* params);
+	void glGetTexParameterfv_enc(void *self , GLenum target, GLenum pname, GLfloat* params);
+	void glLightModelf_enc(void *self , GLenum pname, GLfloat param);
+	void glLightModelfv_enc(void *self , GLenum pname, const GLfloat* params);
+	void glLightf_enc(void *self , GLenum light, GLenum pname, GLfloat param);
+	void glLightfv_enc(void *self , GLenum light, GLenum pname, const GLfloat* params);
+	void glLineWidth_enc(void *self , GLfloat width);
+	void glLoadMatrixf_enc(void *self , const GLfloat* m);
+	void glMaterialf_enc(void *self , GLenum face, GLenum pname, GLfloat param);
+	void glMaterialfv_enc(void *self , GLenum face, GLenum pname, const GLfloat* params);
+	void glMultMatrixf_enc(void *self , const GLfloat* m);
+	void glMultiTexCoord4f_enc(void *self , GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+	void glNormal3f_enc(void *self , GLfloat nx, GLfloat ny, GLfloat nz);
+	void glOrthof_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+	void glPointParameterf_enc(void *self , GLenum pname, GLfloat param);
+	void glPointParameterfv_enc(void *self , GLenum pname, const GLfloat* params);
+	void glPointSize_enc(void *self , GLfloat size);
+	void glPolygonOffset_enc(void *self , GLfloat factor, GLfloat units);
+	void glRotatef_enc(void *self , GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+	void glScalef_enc(void *self , GLfloat x, GLfloat y, GLfloat z);
+	void glTexEnvf_enc(void *self , GLenum target, GLenum pname, GLfloat param);
+	void glTexEnvfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params);
+	void glTexParameterf_enc(void *self , GLenum target, GLenum pname, GLfloat param);
+	void glTexParameterfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params);
+	void glTranslatef_enc(void *self , GLfloat x, GLfloat y, GLfloat z);
+	void glActiveTexture_enc(void *self , GLenum texture);
+	void glAlphaFuncx_enc(void *self , GLenum func, GLclampx ref);
+	void glBindBuffer_enc(void *self , GLenum target, GLuint buffer);
+	void glBindTexture_enc(void *self , GLenum target, GLuint texture);
+	void glBlendFunc_enc(void *self , GLenum sfactor, GLenum dfactor);
+	void glBufferData_enc(void *self , GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
+	void glBufferSubData_enc(void *self , GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+	void glClear_enc(void *self , GLbitfield mask);
+	void glClearColorx_enc(void *self , GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+	void glClearDepthx_enc(void *self , GLclampx depth);
+	void glClearStencil_enc(void *self , GLint s);
+	void glClientActiveTexture_enc(void *self , GLenum texture);
+	void glColor4ub_enc(void *self , GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+	void glColor4x_enc(void *self , GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+	void glColorMask_enc(void *self , GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+	void glColorPointer_enc(void *self , GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glCompressedTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
+	void glCompressedTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
+	void glCopyTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+	void glCopyTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+	void glCullFace_enc(void *self , GLenum mode);
+	void glDeleteBuffers_enc(void *self , GLsizei n, const GLuint* buffers);
+	void glDeleteTextures_enc(void *self , GLsizei n, const GLuint* textures);
+	void glDepthFunc_enc(void *self , GLenum func);
+	void glDepthMask_enc(void *self , GLboolean flag);
+	void glDepthRangex_enc(void *self , GLclampx zNear, GLclampx zFar);
+	void glDisable_enc(void *self , GLenum cap);
+	void glDisableClientState_enc(void *self , GLenum array);
+	void glDrawArrays_enc(void *self , GLenum mode, GLint first, GLsizei count);
+	void glDrawElements_enc(void *self , GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+	void glEnable_enc(void *self , GLenum cap);
+	void glEnableClientState_enc(void *self , GLenum array);
+	void glFinish_enc(void *self );
+	void glFlush_enc(void *self );
+	void glFogx_enc(void *self , GLenum pname, GLfixed param);
+	void glFogxv_enc(void *self , GLenum pname, const GLfixed* params);
+	void glFrontFace_enc(void *self , GLenum mode);
+	void glFrustumx_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+	void glGetBooleanv_enc(void *self , GLenum pname, GLboolean* params);
+	void glGetBufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params);
+	void glClipPlanex_enc(void *self , GLenum pname, const GLfixed* eqn);
+	void glGenBuffers_enc(void *self , GLsizei n, GLuint* buffers);
+	void glGenTextures_enc(void *self , GLsizei n, GLuint* textures);
+	GLenum glGetError_enc(void *self );
+	void glGetFixedv_enc(void *self , GLenum pname, GLfixed* params);
+	void glGetIntegerv_enc(void *self , GLenum pname, GLint* params);
+	void glGetLightxv_enc(void *self , GLenum light, GLenum pname, GLfixed* params);
+	void glGetMaterialxv_enc(void *self , GLenum face, GLenum pname, GLfixed* params);
+	void glGetPointerv_enc(void *self , GLenum pname, GLvoid** params);
+	const GLubyte* glGetString_enc(void *self , GLenum name);
+	void glGetTexEnviv_enc(void *self , GLenum env, GLenum pname, GLint* params);
+	void glGetTexEnvxv_enc(void *self , GLenum env, GLenum pname, GLfixed* params);
+	void glGetTexParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params);
+	void glGetTexParameterxv_enc(void *self , GLenum target, GLenum pname, GLfixed* params);
+	void glHint_enc(void *self , GLenum target, GLenum mode);
+	GLboolean glIsBuffer_enc(void *self , GLuint buffer);
+	GLboolean glIsEnabled_enc(void *self , GLenum cap);
+	GLboolean glIsTexture_enc(void *self , GLuint texture);
+	void glLightModelx_enc(void *self , GLenum pname, GLfixed param);
+	void glLightModelxv_enc(void *self , GLenum pname, const GLfixed* params);
+	void glLightx_enc(void *self , GLenum light, GLenum pname, GLfixed param);
+	void glLightxv_enc(void *self , GLenum light, GLenum pname, const GLfixed* params);
+	void glLineWidthx_enc(void *self , GLfixed width);
+	void glLoadIdentity_enc(void *self );
+	void glLoadMatrixx_enc(void *self , const GLfixed* m);
+	void glLogicOp_enc(void *self , GLenum opcode);
+	void glMaterialx_enc(void *self , GLenum face, GLenum pname, GLfixed param);
+	void glMaterialxv_enc(void *self , GLenum face, GLenum pname, const GLfixed* params);
+	void glMatrixMode_enc(void *self , GLenum mode);
+	void glMultMatrixx_enc(void *self , const GLfixed* m);
+	void glMultiTexCoord4x_enc(void *self , GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+	void glNormal3x_enc(void *self , GLfixed nx, GLfixed ny, GLfixed nz);
+	void glNormalPointer_enc(void *self , GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glOrthox_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+	void glPixelStorei_enc(void *self , GLenum pname, GLint param);
+	void glPointParameterx_enc(void *self , GLenum pname, GLfixed param);
+	void glPointParameterxv_enc(void *self , GLenum pname, const GLfixed* params);
+	void glPointSizex_enc(void *self , GLfixed size);
+	void glPolygonOffsetx_enc(void *self , GLfixed factor, GLfixed units);
+	void glPopMatrix_enc(void *self );
+	void glPushMatrix_enc(void *self );
+	void glReadPixels_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+	void glRotatex_enc(void *self , GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+	void glSampleCoverage_enc(void *self , GLclampf value, GLboolean invert);
+	void glSampleCoveragex_enc(void *self , GLclampx value, GLboolean invert);
+	void glScalex_enc(void *self , GLfixed x, GLfixed y, GLfixed z);
+	void glScissor_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height);
+	void glShadeModel_enc(void *self , GLenum mode);
+	void glStencilFunc_enc(void *self , GLenum func, GLint ref, GLuint mask);
+	void glStencilMask_enc(void *self , GLuint mask);
+	void glStencilOp_enc(void *self , GLenum fail, GLenum zfail, GLenum zpass);
+	void glTexCoordPointer_enc(void *self , GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glTexEnvi_enc(void *self , GLenum target, GLenum pname, GLint param);
+	void glTexEnvx_enc(void *self , GLenum target, GLenum pname, GLfixed param);
+	void glTexEnviv_enc(void *self , GLenum target, GLenum pname, const GLint* params);
+	void glTexEnvxv_enc(void *self , GLenum target, GLenum pname, const GLfixed* params);
+	void glTexImage2D_enc(void *self , GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+	void glTexParameteri_enc(void *self , GLenum target, GLenum pname, GLint param);
+	void glTexParameterx_enc(void *self , GLenum target, GLenum pname, GLfixed param);
+	void glTexParameteriv_enc(void *self , GLenum target, GLenum pname, const GLint* params);
+	void glTexParameterxv_enc(void *self , GLenum target, GLenum pname, const GLfixed* params);
+	void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+	void glTranslatex_enc(void *self , GLfixed x, GLfixed y, GLfixed z);
+	void glVertexPointer_enc(void *self , GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glViewport_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height);
+	void glPointSizePointerOES_enc(void *self , GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glVertexPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glColorPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glNormalPointerOffset_enc(void *self , GLenum type, GLsizei stride, GLuint offset);
+	void glPointSizePointerOffset_enc(void *self , GLenum type, GLsizei stride, GLuint offset);
+	void glTexCoordPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glWeightPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glMatrixIndexPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glVertexPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glColorPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glNormalPointerData_enc(void *self , GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glTexCoordPointerData_enc(void *self , GLint unit, GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glPointSizePointerData_enc(void *self , GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glWeightPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glMatrixIndexPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glDrawElementsOffset_enc(void *self , GLenum mode, GLsizei count, GLenum type, GLuint offset);
+	void glDrawElementsData_enc(void *self , GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen);
+	void glGetCompressedTextureFormats_enc(void *self , int count, GLint* formats);
+	int glFinishRoundTrip_enc(void *self );
+	void glBlendEquationSeparateOES_enc(void *self , GLenum modeRGB, GLenum modeAlpha);
+	void glBlendFuncSeparateOES_enc(void *self , GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+	void glBlendEquationOES_enc(void *self , GLenum mode);
+	void glDrawTexsOES_enc(void *self , GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
+	void glDrawTexiOES_enc(void *self , GLint x, GLint y, GLint z, GLint width, GLint height);
+	void glDrawTexxOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
+	void glDrawTexsvOES_enc(void *self , const GLshort* coords);
+	void glDrawTexivOES_enc(void *self , const GLint* coords);
+	void glDrawTexxvOES_enc(void *self , const GLfixed* coords);
+	void glDrawTexfOES_enc(void *self , GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
+	void glDrawTexfvOES_enc(void *self , const GLfloat* coords);
+	void glEGLImageTargetTexture2DOES_enc(void *self , GLenum target, GLeglImageOES image);
+	void glEGLImageTargetRenderbufferStorageOES_enc(void *self , GLenum target, GLeglImageOES image);
+	void glAlphaFuncxOES_enc(void *self , GLenum func, GLclampx ref);
+	void glClearColorxOES_enc(void *self , GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+	void glClearDepthxOES_enc(void *self , GLclampx depth);
+	void glClipPlanexOES_enc(void *self , GLenum plane, const GLfixed* equation);
+	void glClipPlanexIMG_enc(void *self , GLenum plane, const GLfixed* equation);
+	void glColor4xOES_enc(void *self , GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+	void glDepthRangexOES_enc(void *self , GLclampx zNear, GLclampx zFar);
+	void glFogxOES_enc(void *self , GLenum pname, GLfixed param);
+	void glFogxvOES_enc(void *self , GLenum pname, const GLfixed* params);
+	void glFrustumxOES_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+	void glGetClipPlanexOES_enc(void *self , GLenum pname, GLfixed* eqn);
+	void glGetClipPlanex_enc(void *self , GLenum pname, GLfixed* eqn);
+	void glGetFixedvOES_enc(void *self , GLenum pname, GLfixed* params);
+	void glGetLightxvOES_enc(void *self , GLenum light, GLenum pname, GLfixed* params);
+	void glGetMaterialxvOES_enc(void *self , GLenum face, GLenum pname, GLfixed* params);
+	void glGetTexEnvxvOES_enc(void *self , GLenum env, GLenum pname, GLfixed* params);
+	void glGetTexParameterxvOES_enc(void *self , GLenum target, GLenum pname, GLfixed* params);
+	void glLightModelxOES_enc(void *self , GLenum pname, GLfixed param);
+	void glLightModelxvOES_enc(void *self , GLenum pname, const GLfixed* params);
+	void glLightxOES_enc(void *self , GLenum light, GLenum pname, GLfixed param);
+	void glLightxvOES_enc(void *self , GLenum light, GLenum pname, const GLfixed* params);
+	void glLineWidthxOES_enc(void *self , GLfixed width);
+	void glLoadMatrixxOES_enc(void *self , const GLfixed* m);
+	void glMaterialxOES_enc(void *self , GLenum face, GLenum pname, GLfixed param);
+	void glMaterialxvOES_enc(void *self , GLenum face, GLenum pname, const GLfixed* params);
+	void glMultMatrixxOES_enc(void *self , const GLfixed* m);
+	void glMultiTexCoord4xOES_enc(void *self , GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+	void glNormal3xOES_enc(void *self , GLfixed nx, GLfixed ny, GLfixed nz);
+	void glOrthoxOES_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+	void glPointParameterxOES_enc(void *self , GLenum pname, GLfixed param);
+	void glPointParameterxvOES_enc(void *self , GLenum pname, const GLfixed* params);
+	void glPointSizexOES_enc(void *self , GLfixed size);
+	void glPolygonOffsetxOES_enc(void *self , GLfixed factor, GLfixed units);
+	void glRotatexOES_enc(void *self , GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+	void glSampleCoveragexOES_enc(void *self , GLclampx value, GLboolean invert);
+	void glScalexOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z);
+	void glTexEnvxOES_enc(void *self , GLenum target, GLenum pname, GLfixed param);
+	void glTexEnvxvOES_enc(void *self , GLenum target, GLenum pname, const GLfixed* params);
+	void glTexParameterxOES_enc(void *self , GLenum target, GLenum pname, GLfixed param);
+	void glTexParameterxvOES_enc(void *self , GLenum target, GLenum pname, const GLfixed* params);
+	void glTranslatexOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z);
+	GLboolean glIsRenderbufferOES_enc(void *self , GLuint renderbuffer);
+	void glBindRenderbufferOES_enc(void *self , GLenum target, GLuint renderbuffer);
+	void glDeleteRenderbuffersOES_enc(void *self , GLsizei n, const GLuint* renderbuffers);
+	void glGenRenderbuffersOES_enc(void *self , GLsizei n, GLuint* renderbuffers);
+	void glRenderbufferStorageOES_enc(void *self , GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+	void glGetRenderbufferParameterivOES_enc(void *self , GLenum target, GLenum pname, GLint* params);
+	GLboolean glIsFramebufferOES_enc(void *self , GLuint framebuffer);
+	void glBindFramebufferOES_enc(void *self , GLenum target, GLuint framebuffer);
+	void glDeleteFramebuffersOES_enc(void *self , GLsizei n, const GLuint* framebuffers);
+	void glGenFramebuffersOES_enc(void *self , GLsizei n, GLuint* framebuffers);
+	GLenum glCheckFramebufferStatusOES_enc(void *self , GLenum target);
+	void glFramebufferRenderbufferOES_enc(void *self , GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+	void glFramebufferTexture2DOES_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+	void glGetFramebufferAttachmentParameterivOES_enc(void *self , GLenum target, GLenum attachment, GLenum pname, GLint* params);
+	void glGenerateMipmapOES_enc(void *self , GLenum target);
+	void* glMapBufferOES_enc(void *self , GLenum target, GLenum access);
+	GLboolean glUnmapBufferOES_enc(void *self , GLenum target);
+	void glGetBufferPointervOES_enc(void *self , GLenum target, GLenum pname, GLvoid** params);
+	void glCurrentPaletteMatrixOES_enc(void *self , GLuint matrixpaletteindex);
+	void glLoadPaletteFromModelViewMatrixOES_enc(void *self );
+	void glMatrixIndexPointerOES_enc(void *self , GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glWeightPointerOES_enc(void *self , GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	GLbitfield glQueryMatrixxOES_enc(void *self , GLfixed* mantissa, GLint* exponent);
+	void glDepthRangefOES_enc(void *self , GLclampf zNear, GLclampf zFar);
+	void glFrustumfOES_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+	void glOrthofOES_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+	void glClipPlanefOES_enc(void *self , GLenum plane, const GLfloat* equation);
+	void glClipPlanefIMG_enc(void *self , GLenum plane, const GLfloat* equation);
+	void glGetClipPlanefOES_enc(void *self , GLenum pname, GLfloat* eqn);
+	void glClearDepthfOES_enc(void *self , GLclampf depth);
+	void glTexGenfOES_enc(void *self , GLenum coord, GLenum pname, GLfloat param);
+	void glTexGenfvOES_enc(void *self , GLenum coord, GLenum pname, const GLfloat* params);
+	void glTexGeniOES_enc(void *self , GLenum coord, GLenum pname, GLint param);
+	void glTexGenivOES_enc(void *self , GLenum coord, GLenum pname, const GLint* params);
+	void glTexGenxOES_enc(void *self , GLenum coord, GLenum pname, GLfixed param);
+	void glTexGenxvOES_enc(void *self , GLenum coord, GLenum pname, const GLfixed* params);
+	void glGetTexGenfvOES_enc(void *self , GLenum coord, GLenum pname, GLfloat* params);
+	void glGetTexGenivOES_enc(void *self , GLenum coord, GLenum pname, GLint* params);
+	void glGetTexGenxvOES_enc(void *self , GLenum coord, GLenum pname, GLfixed* params);
+	void glBindVertexArrayOES_enc(void *self , GLuint array);
+	void glDeleteVertexArraysOES_enc(void *self , GLsizei n, const GLuint* arrays);
+	void glGenVertexArraysOES_enc(void *self , GLsizei n, GLuint* arrays);
+	GLboolean glIsVertexArrayOES_enc(void *self , GLuint array);
+	void glDiscardFramebufferEXT_enc(void *self , GLenum target, GLsizei numAttachments, const GLenum* attachments);
+	void glMultiDrawArraysEXT_enc(void *self , GLenum mode, GLint* first, GLsizei* count, GLsizei primcount);
+	void glMultiDrawElementsEXT_enc(void *self , GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount);
+	void glMultiDrawArraysSUN_enc(void *self , GLenum mode, GLint* first, GLsizei* count, GLsizei primcount);
+	void glMultiDrawElementsSUN_enc(void *self , GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount);
+	void glRenderbufferStorageMultisampleIMG_enc(void *self , GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+	void glFramebufferTexture2DMultisampleIMG_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+	void glDeleteFencesNV_enc(void *self , GLsizei n, const GLuint* fences);
+	void glGenFencesNV_enc(void *self , GLsizei n, GLuint* fences);
+	GLboolean glIsFenceNV_enc(void *self , GLuint fence);
+	GLboolean glTestFenceNV_enc(void *self , GLuint fence);
+	void glGetFenceivNV_enc(void *self , GLuint fence, GLenum pname, GLint* params);
+	void glFinishFenceNV_enc(void *self , GLuint fence);
+	void glSetFenceNV_enc(void *self , GLuint fence, GLenum condition);
+	void glGetDriverControlsQCOM_enc(void *self , GLint* num, GLsizei size, GLuint* driverControls);
+	void glGetDriverControlStringQCOM_enc(void *self , GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString);
+	void glEnableDriverControlQCOM_enc(void *self , GLuint driverControl);
+	void glDisableDriverControlQCOM_enc(void *self , GLuint driverControl);
+	void glExtGetTexturesQCOM_enc(void *self , GLuint* textures, GLint maxTextures, GLint* numTextures);
+	void glExtGetBuffersQCOM_enc(void *self , GLuint* buffers, GLint maxBuffers, GLint* numBuffers);
+	void glExtGetRenderbuffersQCOM_enc(void *self , GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers);
+	void glExtGetFramebuffersQCOM_enc(void *self , GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers);
+	void glExtGetTexLevelParameterivQCOM_enc(void *self , GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params);
+	void glExtTexObjectStateOverrideiQCOM_enc(void *self , GLenum target, GLenum pname, GLint param);
+	void glExtGetTexSubImageQCOM_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* texels);
+	void glExtGetBufferPointervQCOM_enc(void *self , GLenum target, GLvoid** params);
+	void glExtGetShadersQCOM_enc(void *self , GLuint* shaders, GLint maxShaders, GLint* numShaders);
+	void glExtGetProgramsQCOM_enc(void *self , GLuint* programs, GLint maxPrograms, GLint* numPrograms);
+	GLboolean glExtIsProgramBinaryQCOM_enc(void *self , GLuint program);
+	void glExtGetProgramBinarySourceQCOM_enc(void *self , GLuint program, GLenum shadertype, GLchar* source, GLint* length);
+	void glStartTilingQCOM_enc(void *self , GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+	void glEndTilingQCOM_enc(void *self , GLbitfield preserveMask);
+};
+#endif
\ No newline at end of file
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl_entry.cpp b/tools/emulator/opengl/system/GLESv1_enc/gl_entry.cpp
new file mode 100644
index 0000000..b43df09
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_entry.cpp
@@ -0,0 +1,2066 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#include <stdio.h>
+#include <stdlib.h>
+#include "gl_client_context.h"
+
+#ifndef GL_TRUE
+extern "C" {
+	void glAlphaFunc(GLenum func, GLclampf ref);
+	void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+	void glClearDepthf(GLclampf depth);
+	void glClipPlanef(GLenum plane, const GLfloat* equation);
+	void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+	void glDepthRangef(GLclampf zNear, GLclampf zFar);
+	void glFogf(GLenum pname, GLfloat param);
+	void glFogfv(GLenum pname, const GLfloat* params);
+	void glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+	void glGetClipPlanef(GLenum pname, GLfloat* eqn);
+	void glGetFloatv(GLenum pname, GLfloat* params);
+	void glGetLightfv(GLenum light, GLenum pname, GLfloat* params);
+	void glGetMaterialfv(GLenum face, GLenum pname, GLfloat* params);
+	void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat* params);
+	void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params);
+	void glLightModelf(GLenum pname, GLfloat param);
+	void glLightModelfv(GLenum pname, const GLfloat* params);
+	void glLightf(GLenum light, GLenum pname, GLfloat param);
+	void glLightfv(GLenum light, GLenum pname, const GLfloat* params);
+	void glLineWidth(GLfloat width);
+	void glLoadMatrixf(const GLfloat* m);
+	void glMaterialf(GLenum face, GLenum pname, GLfloat param);
+	void glMaterialfv(GLenum face, GLenum pname, const GLfloat* params);
+	void glMultMatrixf(const GLfloat* m);
+	void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+	void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
+	void glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+	void glPointParameterf(GLenum pname, GLfloat param);
+	void glPointParameterfv(GLenum pname, const GLfloat* params);
+	void glPointSize(GLfloat size);
+	void glPolygonOffset(GLfloat factor, GLfloat units);
+	void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+	void glScalef(GLfloat x, GLfloat y, GLfloat z);
+	void glTexEnvf(GLenum target, GLenum pname, GLfloat param);
+	void glTexEnvfv(GLenum target, GLenum pname, const GLfloat* params);
+	void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
+	void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params);
+	void glTranslatef(GLfloat x, GLfloat y, GLfloat z);
+	void glActiveTexture(GLenum texture);
+	void glAlphaFuncx(GLenum func, GLclampx ref);
+	void glBindBuffer(GLenum target, GLuint buffer);
+	void glBindTexture(GLenum target, GLuint texture);
+	void glBlendFunc(GLenum sfactor, GLenum dfactor);
+	void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
+	void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+	void glClear(GLbitfield mask);
+	void glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+	void glClearDepthx(GLclampx depth);
+	void glClearStencil(GLint s);
+	void glClientActiveTexture(GLenum texture);
+	void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+	void glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+	void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+	void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
+	void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
+	void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+	void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+	void glCullFace(GLenum mode);
+	void glDeleteBuffers(GLsizei n, const GLuint* buffers);
+	void glDeleteTextures(GLsizei n, const GLuint* textures);
+	void glDepthFunc(GLenum func);
+	void glDepthMask(GLboolean flag);
+	void glDepthRangex(GLclampx zNear, GLclampx zFar);
+	void glDisable(GLenum cap);
+	void glDisableClientState(GLenum array);
+	void glDrawArrays(GLenum mode, GLint first, GLsizei count);
+	void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+	void glEnable(GLenum cap);
+	void glEnableClientState(GLenum array);
+	void glFinish();
+	void glFlush();
+	void glFogx(GLenum pname, GLfixed param);
+	void glFogxv(GLenum pname, const GLfixed* params);
+	void glFrontFace(GLenum mode);
+	void glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+	void glGetBooleanv(GLenum pname, GLboolean* params);
+	void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
+	void glClipPlanex(GLenum pname, const GLfixed* eqn);
+	void glGenBuffers(GLsizei n, GLuint* buffers);
+	void glGenTextures(GLsizei n, GLuint* textures);
+	GLenum glGetError();
+	void glGetFixedv(GLenum pname, GLfixed* params);
+	void glGetIntegerv(GLenum pname, GLint* params);
+	void glGetLightxv(GLenum light, GLenum pname, GLfixed* params);
+	void glGetMaterialxv(GLenum face, GLenum pname, GLfixed* params);
+	void glGetPointerv(GLenum pname, GLvoid** params);
+	const GLubyte* glGetString(GLenum name);
+	void glGetTexEnviv(GLenum env, GLenum pname, GLint* params);
+	void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed* params);
+	void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params);
+	void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed* params);
+	void glHint(GLenum target, GLenum mode);
+	GLboolean glIsBuffer(GLuint buffer);
+	GLboolean glIsEnabled(GLenum cap);
+	GLboolean glIsTexture(GLuint texture);
+	void glLightModelx(GLenum pname, GLfixed param);
+	void glLightModelxv(GLenum pname, const GLfixed* params);
+	void glLightx(GLenum light, GLenum pname, GLfixed param);
+	void glLightxv(GLenum light, GLenum pname, const GLfixed* params);
+	void glLineWidthx(GLfixed width);
+	void glLoadIdentity();
+	void glLoadMatrixx(const GLfixed* m);
+	void glLogicOp(GLenum opcode);
+	void glMaterialx(GLenum face, GLenum pname, GLfixed param);
+	void glMaterialxv(GLenum face, GLenum pname, const GLfixed* params);
+	void glMatrixMode(GLenum mode);
+	void glMultMatrixx(const GLfixed* m);
+	void glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+	void glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz);
+	void glNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+	void glPixelStorei(GLenum pname, GLint param);
+	void glPointParameterx(GLenum pname, GLfixed param);
+	void glPointParameterxv(GLenum pname, const GLfixed* params);
+	void glPointSizex(GLfixed size);
+	void glPolygonOffsetx(GLfixed factor, GLfixed units);
+	void glPopMatrix();
+	void glPushMatrix();
+	void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+	void glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+	void glSampleCoverage(GLclampf value, GLboolean invert);
+	void glSampleCoveragex(GLclampx value, GLboolean invert);
+	void glScalex(GLfixed x, GLfixed y, GLfixed z);
+	void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
+	void glShadeModel(GLenum mode);
+	void glStencilFunc(GLenum func, GLint ref, GLuint mask);
+	void glStencilMask(GLuint mask);
+	void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
+	void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glTexEnvi(GLenum target, GLenum pname, GLint param);
+	void glTexEnvx(GLenum target, GLenum pname, GLfixed param);
+	void glTexEnviv(GLenum target, GLenum pname, const GLint* params);
+	void glTexEnvxv(GLenum target, GLenum pname, const GLfixed* params);
+	void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+	void glTexParameteri(GLenum target, GLenum pname, GLint param);
+	void glTexParameterx(GLenum target, GLenum pname, GLfixed param);
+	void glTexParameteriv(GLenum target, GLenum pname, const GLint* params);
+	void glTexParameterxv(GLenum target, GLenum pname, const GLfixed* params);
+	void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+	void glTranslatex(GLfixed x, GLfixed y, GLfixed z);
+	void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
+	void glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glVertexPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glColorPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glNormalPointerOffset(GLenum type, GLsizei stride, GLuint offset);
+	void glPointSizePointerOffset(GLenum type, GLsizei stride, GLuint offset);
+	void glTexCoordPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glWeightPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glMatrixIndexPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset);
+	void glVertexPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glColorPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glNormalPointerData(GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glTexCoordPointerData(GLint unit, GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glPointSizePointerData(GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glWeightPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glMatrixIndexPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen);
+	void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset);
+	void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen);
+	void glGetCompressedTextureFormats(int count, GLint* formats);
+	int glFinishRoundTrip();
+	void glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha);
+	void glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+	void glBlendEquationOES(GLenum mode);
+	void glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
+	void glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height);
+	void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
+	void glDrawTexsvOES(const GLshort* coords);
+	void glDrawTexivOES(const GLint* coords);
+	void glDrawTexxvOES(const GLfixed* coords);
+	void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
+	void glDrawTexfvOES(const GLfloat* coords);
+	void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
+	void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
+	void glAlphaFuncxOES(GLenum func, GLclampx ref);
+	void glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+	void glClearDepthxOES(GLclampx depth);
+	void glClipPlanexOES(GLenum plane, const GLfixed* equation);
+	void glClipPlanexIMG(GLenum plane, const GLfixed* equation);
+	void glColor4xOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+	void glDepthRangexOES(GLclampx zNear, GLclampx zFar);
+	void glFogxOES(GLenum pname, GLfixed param);
+	void glFogxvOES(GLenum pname, const GLfixed* params);
+	void glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+	void glGetClipPlanexOES(GLenum pname, GLfixed* eqn);
+	void glGetClipPlanex(GLenum pname, GLfixed* eqn);
+	void glGetFixedvOES(GLenum pname, GLfixed* params);
+	void glGetLightxvOES(GLenum light, GLenum pname, GLfixed* params);
+	void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed* params);
+	void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed* params);
+	void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed* params);
+	void glLightModelxOES(GLenum pname, GLfixed param);
+	void glLightModelxvOES(GLenum pname, const GLfixed* params);
+	void glLightxOES(GLenum light, GLenum pname, GLfixed param);
+	void glLightxvOES(GLenum light, GLenum pname, const GLfixed* params);
+	void glLineWidthxOES(GLfixed width);
+	void glLoadMatrixxOES(const GLfixed* m);
+	void glMaterialxOES(GLenum face, GLenum pname, GLfixed param);
+	void glMaterialxvOES(GLenum face, GLenum pname, const GLfixed* params);
+	void glMultMatrixxOES(const GLfixed* m);
+	void glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+	void glNormal3xOES(GLfixed nx, GLfixed ny, GLfixed nz);
+	void glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+	void glPointParameterxOES(GLenum pname, GLfixed param);
+	void glPointParameterxvOES(GLenum pname, const GLfixed* params);
+	void glPointSizexOES(GLfixed size);
+	void glPolygonOffsetxOES(GLfixed factor, GLfixed units);
+	void glRotatexOES(GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+	void glSampleCoveragexOES(GLclampx value, GLboolean invert);
+	void glScalexOES(GLfixed x, GLfixed y, GLfixed z);
+	void glTexEnvxOES(GLenum target, GLenum pname, GLfixed param);
+	void glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed* params);
+	void glTexParameterxOES(GLenum target, GLenum pname, GLfixed param);
+	void glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed* params);
+	void glTranslatexOES(GLfixed x, GLfixed y, GLfixed z);
+	GLboolean glIsRenderbufferOES(GLuint renderbuffer);
+	void glBindRenderbufferOES(GLenum target, GLuint renderbuffer);
+	void glDeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers);
+	void glGenRenderbuffersOES(GLsizei n, GLuint* renderbuffers);
+	void glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+	void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params);
+	GLboolean glIsFramebufferOES(GLuint framebuffer);
+	void glBindFramebufferOES(GLenum target, GLuint framebuffer);
+	void glDeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers);
+	void glGenFramebuffersOES(GLsizei n, GLuint* framebuffers);
+	GLenum glCheckFramebufferStatusOES(GLenum target);
+	void glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+	void glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+	void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+	void glGenerateMipmapOES(GLenum target);
+	void* glMapBufferOES(GLenum target, GLenum access);
+	GLboolean glUnmapBufferOES(GLenum target);
+	void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid** params);
+	void glCurrentPaletteMatrixOES(GLuint matrixpaletteindex);
+	void glLoadPaletteFromModelViewMatrixOES();
+	void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+	GLbitfield glQueryMatrixxOES(GLfixed* mantissa, GLint* exponent);
+	void glDepthRangefOES(GLclampf zNear, GLclampf zFar);
+	void glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+	void glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+	void glClipPlanefOES(GLenum plane, const GLfloat* equation);
+	void glClipPlanefIMG(GLenum plane, const GLfloat* equation);
+	void glGetClipPlanefOES(GLenum pname, GLfloat* eqn);
+	void glClearDepthfOES(GLclampf depth);
+	void glTexGenfOES(GLenum coord, GLenum pname, GLfloat param);
+	void glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat* params);
+	void glTexGeniOES(GLenum coord, GLenum pname, GLint param);
+	void glTexGenivOES(GLenum coord, GLenum pname, const GLint* params);
+	void glTexGenxOES(GLenum coord, GLenum pname, GLfixed param);
+	void glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed* params);
+	void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat* params);
+	void glGetTexGenivOES(GLenum coord, GLenum pname, GLint* params);
+	void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed* params);
+	void glBindVertexArrayOES(GLuint array);
+	void glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays);
+	void glGenVertexArraysOES(GLsizei n, GLuint* arrays);
+	GLboolean glIsVertexArrayOES(GLuint array);
+	void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum* attachments);
+	void glMultiDrawArraysEXT(GLenum mode, GLint* first, GLsizei* count, GLsizei primcount);
+	void glMultiDrawElementsEXT(GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount);
+	void glMultiDrawArraysSUN(GLenum mode, GLint* first, GLsizei* count, GLsizei primcount);
+	void glMultiDrawElementsSUN(GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount);
+	void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+	void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+	void glDeleteFencesNV(GLsizei n, const GLuint* fences);
+	void glGenFencesNV(GLsizei n, GLuint* fences);
+	GLboolean glIsFenceNV(GLuint fence);
+	GLboolean glTestFenceNV(GLuint fence);
+	void glGetFenceivNV(GLuint fence, GLenum pname, GLint* params);
+	void glFinishFenceNV(GLuint fence);
+	void glSetFenceNV(GLuint fence, GLenum condition);
+	void glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls);
+	void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString);
+	void glEnableDriverControlQCOM(GLuint driverControl);
+	void glDisableDriverControlQCOM(GLuint driverControl);
+	void glExtGetTexturesQCOM(GLuint* textures, GLint maxTextures, GLint* numTextures);
+	void glExtGetBuffersQCOM(GLuint* buffers, GLint maxBuffers, GLint* numBuffers);
+	void glExtGetRenderbuffersQCOM(GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers);
+	void glExtGetFramebuffersQCOM(GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers);
+	void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params);
+	void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint 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);
+	void glExtGetBufferPointervQCOM(GLenum target, GLvoid** params);
+	void glExtGetShadersQCOM(GLuint* shaders, GLint maxShaders, GLint* numShaders);
+	void glExtGetProgramsQCOM(GLuint* programs, GLint maxPrograms, GLint* numPrograms);
+	GLboolean glExtIsProgramBinaryQCOM(GLuint program);
+	void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar* source, GLint* length);
+	void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+	void glEndTilingQCOM(GLbitfield preserveMask);
+};
+
+#endif
+#ifndef GET_CONTEXT
+static gl_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
+void gl_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
+#define GET_CONTEXT gl_client_context_t * ctx = getCurrentContext() 
+#endif
+
+void glAlphaFunc(GLenum func, GLclampf ref)
+{
+	GET_CONTEXT; 
+	 ctx->glAlphaFunc(ctx, func, ref);
+}
+
+void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glClearColor(ctx, red, green, blue, alpha);
+}
+
+void glClearDepthf(GLclampf depth)
+{
+	GET_CONTEXT; 
+	 ctx->glClearDepthf(ctx, depth);
+}
+
+void glClipPlanef(GLenum plane, const GLfloat* equation)
+{
+	GET_CONTEXT; 
+	 ctx->glClipPlanef(ctx, plane, equation);
+}
+
+void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glColor4f(ctx, red, green, blue, alpha);
+}
+
+void glDepthRangef(GLclampf zNear, GLclampf zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthRangef(ctx, zNear, zFar);
+}
+
+void glFogf(GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glFogf(ctx, pname, param);
+}
+
+void glFogfv(GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glFogfv(ctx, pname, params);
+}
+
+void glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glFrustumf(ctx, left, right, bottom, top, zNear, zFar);
+}
+
+void glGetClipPlanef(GLenum pname, GLfloat* eqn)
+{
+	GET_CONTEXT; 
+	 ctx->glGetClipPlanef(ctx, pname, eqn);
+}
+
+void glGetFloatv(GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetFloatv(ctx, pname, params);
+}
+
+void glGetLightfv(GLenum light, GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetLightfv(ctx, light, pname, params);
+}
+
+void glGetMaterialfv(GLenum face, GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetMaterialfv(ctx, face, pname, params);
+}
+
+void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexEnvfv(ctx, env, pname, params);
+}
+
+void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexParameterfv(ctx, target, pname, params);
+}
+
+void glLightModelf(GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glLightModelf(ctx, pname, param);
+}
+
+void glLightModelfv(GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glLightModelfv(ctx, pname, params);
+}
+
+void glLightf(GLenum light, GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glLightf(ctx, light, pname, param);
+}
+
+void glLightfv(GLenum light, GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glLightfv(ctx, light, pname, params);
+}
+
+void glLineWidth(GLfloat width)
+{
+	GET_CONTEXT; 
+	 ctx->glLineWidth(ctx, width);
+}
+
+void glLoadMatrixf(const GLfloat* m)
+{
+	GET_CONTEXT; 
+	 ctx->glLoadMatrixf(ctx, m);
+}
+
+void glMaterialf(GLenum face, GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glMaterialf(ctx, face, pname, param);
+}
+
+void glMaterialfv(GLenum face, GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glMaterialfv(ctx, face, pname, params);
+}
+
+void glMultMatrixf(const GLfloat* m)
+{
+	GET_CONTEXT; 
+	 ctx->glMultMatrixf(ctx, m);
+}
+
+void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiTexCoord4f(ctx, target, s, t, r, q);
+}
+
+void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
+{
+	GET_CONTEXT; 
+	 ctx->glNormal3f(ctx, nx, ny, nz);
+}
+
+void glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glOrthof(ctx, left, right, bottom, top, zNear, zFar);
+}
+
+void glPointParameterf(GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glPointParameterf(ctx, pname, param);
+}
+
+void glPointParameterfv(GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glPointParameterfv(ctx, pname, params);
+}
+
+void glPointSize(GLfloat size)
+{
+	GET_CONTEXT; 
+	 ctx->glPointSize(ctx, size);
+}
+
+void glPolygonOffset(GLfloat factor, GLfloat units)
+{
+	GET_CONTEXT; 
+	 ctx->glPolygonOffset(ctx, factor, units);
+}
+
+void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+{
+	GET_CONTEXT; 
+	 ctx->glRotatef(ctx, angle, x, y, z);
+}
+
+void glScalef(GLfloat x, GLfloat y, GLfloat z)
+{
+	GET_CONTEXT; 
+	 ctx->glScalef(ctx, x, y, z);
+}
+
+void glTexEnvf(GLenum target, GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexEnvf(ctx, target, pname, param);
+}
+
+void glTexEnvfv(GLenum target, GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexEnvfv(ctx, target, pname, params);
+}
+
+void glTexParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameterf(ctx, target, pname, param);
+}
+
+void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameterfv(ctx, target, pname, params);
+}
+
+void glTranslatef(GLfloat x, GLfloat y, GLfloat z)
+{
+	GET_CONTEXT; 
+	 ctx->glTranslatef(ctx, x, y, z);
+}
+
+void glActiveTexture(GLenum texture)
+{
+	GET_CONTEXT; 
+	 ctx->glActiveTexture(ctx, texture);
+}
+
+void glAlphaFuncx(GLenum func, GLclampx ref)
+{
+	GET_CONTEXT; 
+	 ctx->glAlphaFuncx(ctx, func, ref);
+}
+
+void glBindBuffer(GLenum target, GLuint buffer)
+{
+	GET_CONTEXT; 
+	 ctx->glBindBuffer(ctx, target, buffer);
+}
+
+void glBindTexture(GLenum target, GLuint texture)
+{
+	GET_CONTEXT; 
+	 ctx->glBindTexture(ctx, target, texture);
+}
+
+void glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendFunc(ctx, sfactor, dfactor);
+}
+
+void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
+{
+	GET_CONTEXT; 
+	 ctx->glBufferData(ctx, target, size, data, usage);
+}
+
+void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
+{
+	GET_CONTEXT; 
+	 ctx->glBufferSubData(ctx, target, offset, size, data);
+}
+
+void glClear(GLbitfield mask)
+{
+	GET_CONTEXT; 
+	 ctx->glClear(ctx, mask);
+}
+
+void glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glClearColorx(ctx, red, green, blue, alpha);
+}
+
+void glClearDepthx(GLclampx depth)
+{
+	GET_CONTEXT; 
+	 ctx->glClearDepthx(ctx, depth);
+}
+
+void glClearStencil(GLint s)
+{
+	GET_CONTEXT; 
+	 ctx->glClearStencil(ctx, s);
+}
+
+void glClientActiveTexture(GLenum texture)
+{
+	GET_CONTEXT; 
+	 ctx->glClientActiveTexture(ctx, texture);
+}
+
+void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glColor4ub(ctx, red, green, blue, alpha);
+}
+
+void glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glColor4x(ctx, red, green, blue, alpha);
+}
+
+void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glColorMask(ctx, red, green, blue, alpha);
+}
+
+void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+	GET_CONTEXT; 
+	 ctx->glColorPointer(ctx, size, type, stride, pointer);
+}
+
+void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+	GET_CONTEXT; 
+	 ctx->glCompressedTexImage2D(ctx, 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)
+{
+	GET_CONTEXT; 
+	 ctx->glCompressedTexSubImage2D(ctx, 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)
+{
+	GET_CONTEXT; 
+	 ctx->glCopyTexImage2D(ctx, 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)
+{
+	GET_CONTEXT; 
+	 ctx->glCopyTexSubImage2D(ctx, target, level, xoffset, yoffset, x, y, width, height);
+}
+
+void glCullFace(GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glCullFace(ctx, mode);
+}
+
+void glDeleteBuffers(GLsizei n, const GLuint* buffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteBuffers(ctx, n, buffers);
+}
+
+void glDeleteTextures(GLsizei n, const GLuint* textures)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteTextures(ctx, n, textures);
+}
+
+void glDepthFunc(GLenum func)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthFunc(ctx, func);
+}
+
+void glDepthMask(GLboolean flag)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthMask(ctx, flag);
+}
+
+void glDepthRangex(GLclampx zNear, GLclampx zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthRangex(ctx, zNear, zFar);
+}
+
+void glDisable(GLenum cap)
+{
+	GET_CONTEXT; 
+	 ctx->glDisable(ctx, cap);
+}
+
+void glDisableClientState(GLenum array)
+{
+	GET_CONTEXT; 
+	 ctx->glDisableClientState(ctx, array);
+}
+
+void glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawArrays(ctx, mode, first, count);
+}
+
+void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawElements(ctx, mode, count, type, indices);
+}
+
+void glEnable(GLenum cap)
+{
+	GET_CONTEXT; 
+	 ctx->glEnable(ctx, cap);
+}
+
+void glEnableClientState(GLenum array)
+{
+	GET_CONTEXT; 
+	 ctx->glEnableClientState(ctx, array);
+}
+
+void glFinish()
+{
+	GET_CONTEXT; 
+	 ctx->glFinish(ctx);
+}
+
+void glFlush()
+{
+	GET_CONTEXT; 
+	 ctx->glFlush(ctx);
+}
+
+void glFogx(GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glFogx(ctx, pname, param);
+}
+
+void glFogxv(GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glFogxv(ctx, pname, params);
+}
+
+void glFrontFace(GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glFrontFace(ctx, mode);
+}
+
+void glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glFrustumx(ctx, left, right, bottom, top, zNear, zFar);
+}
+
+void glGetBooleanv(GLenum pname, GLboolean* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetBooleanv(ctx, pname, params);
+}
+
+void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetBufferParameteriv(ctx, target, pname, params);
+}
+
+void glClipPlanex(GLenum pname, const GLfixed* eqn)
+{
+	GET_CONTEXT; 
+	 ctx->glClipPlanex(ctx, pname, eqn);
+}
+
+void glGenBuffers(GLsizei n, GLuint* buffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenBuffers(ctx, n, buffers);
+}
+
+void glGenTextures(GLsizei n, GLuint* textures)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenTextures(ctx, n, textures);
+}
+
+GLenum glGetError()
+{
+	GET_CONTEXT; 
+	 return ctx->glGetError(ctx);
+}
+
+void glGetFixedv(GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetFixedv(ctx, pname, params);
+}
+
+void glGetIntegerv(GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetIntegerv(ctx, pname, params);
+}
+
+void glGetLightxv(GLenum light, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetLightxv(ctx, light, pname, params);
+}
+
+void glGetMaterialxv(GLenum face, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetMaterialxv(ctx, face, pname, params);
+}
+
+void glGetPointerv(GLenum pname, GLvoid** params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetPointerv(ctx, pname, params);
+}
+
+const GLubyte* glGetString(GLenum name)
+{
+	GET_CONTEXT; 
+	 return ctx->glGetString(ctx, name);
+}
+
+void glGetTexEnviv(GLenum env, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexEnviv(ctx, env, pname, params);
+}
+
+void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexEnvxv(ctx, env, pname, params);
+}
+
+void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexParameteriv(ctx, target, pname, params);
+}
+
+void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexParameterxv(ctx, target, pname, params);
+}
+
+void glHint(GLenum target, GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glHint(ctx, target, mode);
+}
+
+GLboolean glIsBuffer(GLuint buffer)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsBuffer(ctx, buffer);
+}
+
+GLboolean glIsEnabled(GLenum cap)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsEnabled(ctx, cap);
+}
+
+GLboolean glIsTexture(GLuint texture)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsTexture(ctx, texture);
+}
+
+void glLightModelx(GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glLightModelx(ctx, pname, param);
+}
+
+void glLightModelxv(GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glLightModelxv(ctx, pname, params);
+}
+
+void glLightx(GLenum light, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glLightx(ctx, light, pname, param);
+}
+
+void glLightxv(GLenum light, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glLightxv(ctx, light, pname, params);
+}
+
+void glLineWidthx(GLfixed width)
+{
+	GET_CONTEXT; 
+	 ctx->glLineWidthx(ctx, width);
+}
+
+void glLoadIdentity()
+{
+	GET_CONTEXT; 
+	 ctx->glLoadIdentity(ctx);
+}
+
+void glLoadMatrixx(const GLfixed* m)
+{
+	GET_CONTEXT; 
+	 ctx->glLoadMatrixx(ctx, m);
+}
+
+void glLogicOp(GLenum opcode)
+{
+	GET_CONTEXT; 
+	 ctx->glLogicOp(ctx, opcode);
+}
+
+void glMaterialx(GLenum face, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glMaterialx(ctx, face, pname, param);
+}
+
+void glMaterialxv(GLenum face, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glMaterialxv(ctx, face, pname, params);
+}
+
+void glMatrixMode(GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glMatrixMode(ctx, mode);
+}
+
+void glMultMatrixx(const GLfixed* m)
+{
+	GET_CONTEXT; 
+	 ctx->glMultMatrixx(ctx, m);
+}
+
+void glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiTexCoord4x(ctx, target, s, t, r, q);
+}
+
+void glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz)
+{
+	GET_CONTEXT; 
+	 ctx->glNormal3x(ctx, nx, ny, nz);
+}
+
+void glNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+	GET_CONTEXT; 
+	 ctx->glNormalPointer(ctx, type, stride, pointer);
+}
+
+void glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glOrthox(ctx, left, right, bottom, top, zNear, zFar);
+}
+
+void glPixelStorei(GLenum pname, GLint param)
+{
+	GET_CONTEXT; 
+	 ctx->glPixelStorei(ctx, pname, param);
+}
+
+void glPointParameterx(GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glPointParameterx(ctx, pname, param);
+}
+
+void glPointParameterxv(GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glPointParameterxv(ctx, pname, params);
+}
+
+void glPointSizex(GLfixed size)
+{
+	GET_CONTEXT; 
+	 ctx->glPointSizex(ctx, size);
+}
+
+void glPolygonOffsetx(GLfixed factor, GLfixed units)
+{
+	GET_CONTEXT; 
+	 ctx->glPolygonOffsetx(ctx, factor, units);
+}
+
+void glPopMatrix()
+{
+	GET_CONTEXT; 
+	 ctx->glPopMatrix(ctx);
+}
+
+void glPushMatrix()
+{
+	GET_CONTEXT; 
+	 ctx->glPushMatrix(ctx);
+}
+
+void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->glReadPixels(ctx, x, y, width, height, format, type, pixels);
+}
+
+void glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+{
+	GET_CONTEXT; 
+	 ctx->glRotatex(ctx, angle, x, y, z);
+}
+
+void glSampleCoverage(GLclampf value, GLboolean invert)
+{
+	GET_CONTEXT; 
+	 ctx->glSampleCoverage(ctx, value, invert);
+}
+
+void glSampleCoveragex(GLclampx value, GLboolean invert)
+{
+	GET_CONTEXT; 
+	 ctx->glSampleCoveragex(ctx, value, invert);
+}
+
+void glScalex(GLfixed x, GLfixed y, GLfixed z)
+{
+	GET_CONTEXT; 
+	 ctx->glScalex(ctx, x, y, z);
+}
+
+void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glScissor(ctx, x, y, width, height);
+}
+
+void glShadeModel(GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glShadeModel(ctx, mode);
+}
+
+void glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilFunc(ctx, func, ref, mask);
+}
+
+void glStencilMask(GLuint mask)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilMask(ctx, mask);
+}
+
+void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilOp(ctx, fail, zfail, zpass);
+}
+
+void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+	GET_CONTEXT; 
+	 ctx->glTexCoordPointer(ctx, size, type, stride, pointer);
+}
+
+void glTexEnvi(GLenum target, GLenum pname, GLint param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexEnvi(ctx, target, pname, param);
+}
+
+void glTexEnvx(GLenum target, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexEnvx(ctx, target, pname, param);
+}
+
+void glTexEnviv(GLenum target, GLenum pname, const GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexEnviv(ctx, target, pname, params);
+}
+
+void glTexEnvxv(GLenum target, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexEnvxv(ctx, target, pname, params);
+}
+
+void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->glTexImage2D(ctx, target, level, internalformat, width, height, border, format, type, pixels);
+}
+
+void glTexParameteri(GLenum target, GLenum pname, GLint param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameteri(ctx, target, pname, param);
+}
+
+void glTexParameterx(GLenum target, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameterx(ctx, target, pname, param);
+}
+
+void glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameteriv(ctx, target, pname, params);
+}
+
+void glTexParameterxv(GLenum target, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameterxv(ctx, target, pname, params);
+}
+
+void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->glTexSubImage2D(ctx, target, level, xoffset, yoffset, width, height, format, type, pixels);
+}
+
+void glTranslatex(GLfixed x, GLfixed y, GLfixed z)
+{
+	GET_CONTEXT; 
+	 ctx->glTranslatex(ctx, x, y, z);
+}
+
+void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexPointer(ctx, size, type, stride, pointer);
+}
+
+void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glViewport(ctx, x, y, width, height);
+}
+
+void glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+	GET_CONTEXT; 
+	 ctx->glPointSizePointerOES(ctx, type, stride, pointer);
+}
+
+void glVertexPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexPointerOffset(ctx, size, type, stride, offset);
+}
+
+void glColorPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glColorPointerOffset(ctx, size, type, stride, offset);
+}
+
+void glNormalPointerOffset(GLenum type, GLsizei stride, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glNormalPointerOffset(ctx, type, stride, offset);
+}
+
+void glPointSizePointerOffset(GLenum type, GLsizei stride, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glPointSizePointerOffset(ctx, type, stride, offset);
+}
+
+void glTexCoordPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glTexCoordPointerOffset(ctx, size, type, stride, offset);
+}
+
+void glWeightPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glWeightPointerOffset(ctx, size, type, stride, offset);
+}
+
+void glMatrixIndexPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glMatrixIndexPointerOffset(ctx, size, type, stride, offset);
+}
+
+void glVertexPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexPointerData(ctx, size, type, stride, data, datalen);
+}
+
+void glColorPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glColorPointerData(ctx, size, type, stride, data, datalen);
+}
+
+void glNormalPointerData(GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glNormalPointerData(ctx, type, stride, data, datalen);
+}
+
+void glTexCoordPointerData(GLint unit, GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glTexCoordPointerData(ctx, unit, size, type, stride, data, datalen);
+}
+
+void glPointSizePointerData(GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glPointSizePointerData(ctx, type, stride, data, datalen);
+}
+
+void glWeightPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glWeightPointerData(ctx, size, type, stride, data, datalen);
+}
+
+void glMatrixIndexPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glMatrixIndexPointerData(ctx, size, type, stride, data, datalen);
+}
+
+void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawElementsOffset(ctx, mode, count, type, offset);
+}
+
+void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawElementsData(ctx, mode, count, type, data, datalen);
+}
+
+void glGetCompressedTextureFormats(int count, GLint* formats)
+{
+	GET_CONTEXT; 
+	 ctx->glGetCompressedTextureFormats(ctx, count, formats);
+}
+
+int glFinishRoundTrip()
+{
+	GET_CONTEXT; 
+	 return ctx->glFinishRoundTrip(ctx);
+}
+
+void glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendEquationSeparateOES(ctx, modeRGB, modeAlpha);
+}
+
+void glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendFuncSeparateOES(ctx, srcRGB, dstRGB, srcAlpha, dstAlpha);
+}
+
+void glBlendEquationOES(GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendEquationOES(ctx, mode);
+}
+
+void glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawTexsOES(ctx, x, y, z, width, height);
+}
+
+void glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawTexiOES(ctx, x, y, z, width, height);
+}
+
+void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawTexxOES(ctx, x, y, z, width, height);
+}
+
+void glDrawTexsvOES(const GLshort* coords)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawTexsvOES(ctx, coords);
+}
+
+void glDrawTexivOES(const GLint* coords)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawTexivOES(ctx, coords);
+}
+
+void glDrawTexxvOES(const GLfixed* coords)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawTexxvOES(ctx, coords);
+}
+
+void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawTexfOES(ctx, x, y, z, width, height);
+}
+
+void glDrawTexfvOES(const GLfloat* coords)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawTexfvOES(ctx, coords);
+}
+
+void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+	GET_CONTEXT; 
+	 ctx->glEGLImageTargetTexture2DOES(ctx, target, image);
+}
+
+void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+	GET_CONTEXT; 
+	 ctx->glEGLImageTargetRenderbufferStorageOES(ctx, target, image);
+}
+
+void glAlphaFuncxOES(GLenum func, GLclampx ref)
+{
+	GET_CONTEXT; 
+	 ctx->glAlphaFuncxOES(ctx, func, ref);
+}
+
+void glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glClearColorxOES(ctx, red, green, blue, alpha);
+}
+
+void glClearDepthxOES(GLclampx depth)
+{
+	GET_CONTEXT; 
+	 ctx->glClearDepthxOES(ctx, depth);
+}
+
+void glClipPlanexOES(GLenum plane, const GLfixed* equation)
+{
+	GET_CONTEXT; 
+	 ctx->glClipPlanexOES(ctx, plane, equation);
+}
+
+void glClipPlanexIMG(GLenum plane, const GLfixed* equation)
+{
+	GET_CONTEXT; 
+	 ctx->glClipPlanexIMG(ctx, plane, equation);
+}
+
+void glColor4xOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glColor4xOES(ctx, red, green, blue, alpha);
+}
+
+void glDepthRangexOES(GLclampx zNear, GLclampx zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthRangexOES(ctx, zNear, zFar);
+}
+
+void glFogxOES(GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glFogxOES(ctx, pname, param);
+}
+
+void glFogxvOES(GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glFogxvOES(ctx, pname, params);
+}
+
+void glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glFrustumxOES(ctx, left, right, bottom, top, zNear, zFar);
+}
+
+void glGetClipPlanexOES(GLenum pname, GLfixed* eqn)
+{
+	GET_CONTEXT; 
+	 ctx->glGetClipPlanexOES(ctx, pname, eqn);
+}
+
+void glGetClipPlanex(GLenum pname, GLfixed* eqn)
+{
+	GET_CONTEXT; 
+	 ctx->glGetClipPlanex(ctx, pname, eqn);
+}
+
+void glGetFixedvOES(GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetFixedvOES(ctx, pname, params);
+}
+
+void glGetLightxvOES(GLenum light, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetLightxvOES(ctx, light, pname, params);
+}
+
+void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetMaterialxvOES(ctx, face, pname, params);
+}
+
+void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexEnvxvOES(ctx, env, pname, params);
+}
+
+void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexParameterxvOES(ctx, target, pname, params);
+}
+
+void glLightModelxOES(GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glLightModelxOES(ctx, pname, param);
+}
+
+void glLightModelxvOES(GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glLightModelxvOES(ctx, pname, params);
+}
+
+void glLightxOES(GLenum light, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glLightxOES(ctx, light, pname, param);
+}
+
+void glLightxvOES(GLenum light, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glLightxvOES(ctx, light, pname, params);
+}
+
+void glLineWidthxOES(GLfixed width)
+{
+	GET_CONTEXT; 
+	 ctx->glLineWidthxOES(ctx, width);
+}
+
+void glLoadMatrixxOES(const GLfixed* m)
+{
+	GET_CONTEXT; 
+	 ctx->glLoadMatrixxOES(ctx, m);
+}
+
+void glMaterialxOES(GLenum face, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glMaterialxOES(ctx, face, pname, param);
+}
+
+void glMaterialxvOES(GLenum face, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glMaterialxvOES(ctx, face, pname, params);
+}
+
+void glMultMatrixxOES(const GLfixed* m)
+{
+	GET_CONTEXT; 
+	 ctx->glMultMatrixxOES(ctx, m);
+}
+
+void glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiTexCoord4xOES(ctx, target, s, t, r, q);
+}
+
+void glNormal3xOES(GLfixed nx, GLfixed ny, GLfixed nz)
+{
+	GET_CONTEXT; 
+	 ctx->glNormal3xOES(ctx, nx, ny, nz);
+}
+
+void glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glOrthoxOES(ctx, left, right, bottom, top, zNear, zFar);
+}
+
+void glPointParameterxOES(GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glPointParameterxOES(ctx, pname, param);
+}
+
+void glPointParameterxvOES(GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glPointParameterxvOES(ctx, pname, params);
+}
+
+void glPointSizexOES(GLfixed size)
+{
+	GET_CONTEXT; 
+	 ctx->glPointSizexOES(ctx, size);
+}
+
+void glPolygonOffsetxOES(GLfixed factor, GLfixed units)
+{
+	GET_CONTEXT; 
+	 ctx->glPolygonOffsetxOES(ctx, factor, units);
+}
+
+void glRotatexOES(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+{
+	GET_CONTEXT; 
+	 ctx->glRotatexOES(ctx, angle, x, y, z);
+}
+
+void glSampleCoveragexOES(GLclampx value, GLboolean invert)
+{
+	GET_CONTEXT; 
+	 ctx->glSampleCoveragexOES(ctx, value, invert);
+}
+
+void glScalexOES(GLfixed x, GLfixed y, GLfixed z)
+{
+	GET_CONTEXT; 
+	 ctx->glScalexOES(ctx, x, y, z);
+}
+
+void glTexEnvxOES(GLenum target, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexEnvxOES(ctx, target, pname, param);
+}
+
+void glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexEnvxvOES(ctx, target, pname, params);
+}
+
+void glTexParameterxOES(GLenum target, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameterxOES(ctx, target, pname, param);
+}
+
+void glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameterxvOES(ctx, target, pname, params);
+}
+
+void glTranslatexOES(GLfixed x, GLfixed y, GLfixed z)
+{
+	GET_CONTEXT; 
+	 ctx->glTranslatexOES(ctx, x, y, z);
+}
+
+GLboolean glIsRenderbufferOES(GLuint renderbuffer)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsRenderbufferOES(ctx, renderbuffer);
+}
+
+void glBindRenderbufferOES(GLenum target, GLuint renderbuffer)
+{
+	GET_CONTEXT; 
+	 ctx->glBindRenderbufferOES(ctx, target, renderbuffer);
+}
+
+void glDeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteRenderbuffersOES(ctx, n, renderbuffers);
+}
+
+void glGenRenderbuffersOES(GLsizei n, GLuint* renderbuffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenRenderbuffersOES(ctx, n, renderbuffers);
+}
+
+void glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glRenderbufferStorageOES(ctx, target, internalformat, width, height);
+}
+
+void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetRenderbufferParameterivOES(ctx, target, pname, params);
+}
+
+GLboolean glIsFramebufferOES(GLuint framebuffer)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsFramebufferOES(ctx, framebuffer);
+}
+
+void glBindFramebufferOES(GLenum target, GLuint framebuffer)
+{
+	GET_CONTEXT; 
+	 ctx->glBindFramebufferOES(ctx, target, framebuffer);
+}
+
+void glDeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteFramebuffersOES(ctx, n, framebuffers);
+}
+
+void glGenFramebuffersOES(GLsizei n, GLuint* framebuffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenFramebuffersOES(ctx, n, framebuffers);
+}
+
+GLenum glCheckFramebufferStatusOES(GLenum target)
+{
+	GET_CONTEXT; 
+	 return ctx->glCheckFramebufferStatusOES(ctx, target);
+}
+
+void glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+	GET_CONTEXT; 
+	 ctx->glFramebufferRenderbufferOES(ctx, target, attachment, renderbuffertarget, renderbuffer);
+}
+
+void glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+	GET_CONTEXT; 
+	 ctx->glFramebufferTexture2DOES(ctx, target, attachment, textarget, texture, level);
+}
+
+void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetFramebufferAttachmentParameterivOES(ctx, target, attachment, pname, params);
+}
+
+void glGenerateMipmapOES(GLenum target)
+{
+	GET_CONTEXT; 
+	 ctx->glGenerateMipmapOES(ctx, target);
+}
+
+void* glMapBufferOES(GLenum target, GLenum access)
+{
+	GET_CONTEXT; 
+	 return ctx->glMapBufferOES(ctx, target, access);
+}
+
+GLboolean glUnmapBufferOES(GLenum target)
+{
+	GET_CONTEXT; 
+	 return ctx->glUnmapBufferOES(ctx, target);
+}
+
+void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid** params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetBufferPointervOES(ctx, target, pname, params);
+}
+
+void glCurrentPaletteMatrixOES(GLuint matrixpaletteindex)
+{
+	GET_CONTEXT; 
+	 ctx->glCurrentPaletteMatrixOES(ctx, matrixpaletteindex);
+}
+
+void glLoadPaletteFromModelViewMatrixOES()
+{
+	GET_CONTEXT; 
+	 ctx->glLoadPaletteFromModelViewMatrixOES(ctx);
+}
+
+void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+	GET_CONTEXT; 
+	 ctx->glMatrixIndexPointerOES(ctx, size, type, stride, pointer);
+}
+
+void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+	GET_CONTEXT; 
+	 ctx->glWeightPointerOES(ctx, size, type, stride, pointer);
+}
+
+GLbitfield glQueryMatrixxOES(GLfixed* mantissa, GLint* exponent)
+{
+	GET_CONTEXT; 
+	 return ctx->glQueryMatrixxOES(ctx, mantissa, exponent);
+}
+
+void glDepthRangefOES(GLclampf zNear, GLclampf zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthRangefOES(ctx, zNear, zFar);
+}
+
+void glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glFrustumfOES(ctx, left, right, bottom, top, zNear, zFar);
+}
+
+void glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glOrthofOES(ctx, left, right, bottom, top, zNear, zFar);
+}
+
+void glClipPlanefOES(GLenum plane, const GLfloat* equation)
+{
+	GET_CONTEXT; 
+	 ctx->glClipPlanefOES(ctx, plane, equation);
+}
+
+void glClipPlanefIMG(GLenum plane, const GLfloat* equation)
+{
+	GET_CONTEXT; 
+	 ctx->glClipPlanefIMG(ctx, plane, equation);
+}
+
+void glGetClipPlanefOES(GLenum pname, GLfloat* eqn)
+{
+	GET_CONTEXT; 
+	 ctx->glGetClipPlanefOES(ctx, pname, eqn);
+}
+
+void glClearDepthfOES(GLclampf depth)
+{
+	GET_CONTEXT; 
+	 ctx->glClearDepthfOES(ctx, depth);
+}
+
+void glTexGenfOES(GLenum coord, GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexGenfOES(ctx, coord, pname, param);
+}
+
+void glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexGenfvOES(ctx, coord, pname, params);
+}
+
+void glTexGeniOES(GLenum coord, GLenum pname, GLint param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexGeniOES(ctx, coord, pname, param);
+}
+
+void glTexGenivOES(GLenum coord, GLenum pname, const GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexGenivOES(ctx, coord, pname, params);
+}
+
+void glTexGenxOES(GLenum coord, GLenum pname, GLfixed param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexGenxOES(ctx, coord, pname, param);
+}
+
+void glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexGenxvOES(ctx, coord, pname, params);
+}
+
+void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexGenfvOES(ctx, coord, pname, params);
+}
+
+void glGetTexGenivOES(GLenum coord, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexGenivOES(ctx, coord, pname, params);
+}
+
+void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexGenxvOES(ctx, coord, pname, params);
+}
+
+void glBindVertexArrayOES(GLuint array)
+{
+	GET_CONTEXT; 
+	 ctx->glBindVertexArrayOES(ctx, array);
+}
+
+void glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteVertexArraysOES(ctx, n, arrays);
+}
+
+void glGenVertexArraysOES(GLsizei n, GLuint* arrays)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenVertexArraysOES(ctx, n, arrays);
+}
+
+GLboolean glIsVertexArrayOES(GLuint array)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsVertexArrayOES(ctx, array);
+}
+
+void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum* attachments)
+{
+	GET_CONTEXT; 
+	 ctx->glDiscardFramebufferEXT(ctx, target, numAttachments, attachments);
+}
+
+void glMultiDrawArraysEXT(GLenum mode, GLint* first, GLsizei* count, GLsizei primcount)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiDrawArraysEXT(ctx, mode, first, count, primcount);
+}
+
+void glMultiDrawElementsEXT(GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiDrawElementsEXT(ctx, mode, count, type, indices, primcount);
+}
+
+void glMultiDrawArraysSUN(GLenum mode, GLint* first, GLsizei* count, GLsizei primcount)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiDrawArraysSUN(ctx, mode, first, count, primcount);
+}
+
+void glMultiDrawElementsSUN(GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiDrawElementsSUN(ctx, mode, count, type, indices, primcount);
+}
+
+void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glRenderbufferStorageMultisampleIMG(ctx, target, samples, internalformat, width, height);
+}
+
+void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
+{
+	GET_CONTEXT; 
+	 ctx->glFramebufferTexture2DMultisampleIMG(ctx, target, attachment, textarget, texture, level, samples);
+}
+
+void glDeleteFencesNV(GLsizei n, const GLuint* fences)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteFencesNV(ctx, n, fences);
+}
+
+void glGenFencesNV(GLsizei n, GLuint* fences)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenFencesNV(ctx, n, fences);
+}
+
+GLboolean glIsFenceNV(GLuint fence)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsFenceNV(ctx, fence);
+}
+
+GLboolean glTestFenceNV(GLuint fence)
+{
+	GET_CONTEXT; 
+	 return ctx->glTestFenceNV(ctx, fence);
+}
+
+void glGetFenceivNV(GLuint fence, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetFenceivNV(ctx, fence, pname, params);
+}
+
+void glFinishFenceNV(GLuint fence)
+{
+	GET_CONTEXT; 
+	 ctx->glFinishFenceNV(ctx, fence);
+}
+
+void glSetFenceNV(GLuint fence, GLenum condition)
+{
+	GET_CONTEXT; 
+	 ctx->glSetFenceNV(ctx, fence, condition);
+}
+
+void glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls)
+{
+	GET_CONTEXT; 
+	 ctx->glGetDriverControlsQCOM(ctx, num, size, driverControls);
+}
+
+void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString)
+{
+	GET_CONTEXT; 
+	 ctx->glGetDriverControlStringQCOM(ctx, driverControl, bufSize, length, driverControlString);
+}
+
+void glEnableDriverControlQCOM(GLuint driverControl)
+{
+	GET_CONTEXT; 
+	 ctx->glEnableDriverControlQCOM(ctx, driverControl);
+}
+
+void glDisableDriverControlQCOM(GLuint driverControl)
+{
+	GET_CONTEXT; 
+	 ctx->glDisableDriverControlQCOM(ctx, driverControl);
+}
+
+void glExtGetTexturesQCOM(GLuint* textures, GLint maxTextures, GLint* numTextures)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetTexturesQCOM(ctx, textures, maxTextures, numTextures);
+}
+
+void glExtGetBuffersQCOM(GLuint* buffers, GLint maxBuffers, GLint* numBuffers)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetBuffersQCOM(ctx, buffers, maxBuffers, numBuffers);
+}
+
+void glExtGetRenderbuffersQCOM(GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetRenderbuffersQCOM(ctx, renderbuffers, maxRenderbuffers, numRenderbuffers);
+}
+
+void glExtGetFramebuffersQCOM(GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetFramebuffersQCOM(ctx, framebuffers, maxFramebuffers, numFramebuffers);
+}
+
+void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetTexLevelParameterivQCOM(ctx, texture, face, level, pname, params);
+}
+
+void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param)
+{
+	GET_CONTEXT; 
+	 ctx->glExtTexObjectStateOverrideiQCOM(ctx, 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)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetTexSubImageQCOM(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels);
+}
+
+void glExtGetBufferPointervQCOM(GLenum target, GLvoid** params)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetBufferPointervQCOM(ctx, target, params);
+}
+
+void glExtGetShadersQCOM(GLuint* shaders, GLint maxShaders, GLint* numShaders)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetShadersQCOM(ctx, shaders, maxShaders, numShaders);
+}
+
+void glExtGetProgramsQCOM(GLuint* programs, GLint maxPrograms, GLint* numPrograms)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetProgramsQCOM(ctx, programs, maxPrograms, numPrograms);
+}
+
+GLboolean glExtIsProgramBinaryQCOM(GLuint program)
+{
+	GET_CONTEXT; 
+	 return ctx->glExtIsProgramBinaryQCOM(ctx, program);
+}
+
+void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar* source, GLint* length)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetProgramBinarySourceQCOM(ctx, program, shadertype, source, length);
+}
+
+void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
+{
+	GET_CONTEXT; 
+	 ctx->glStartTilingQCOM(ctx, x, y, width, height, preserveMask);
+}
+
+void glEndTilingQCOM(GLbitfield preserveMask)
+{
+	GET_CONTEXT; 
+	 ctx->glEndTilingQCOM(ctx, preserveMask);
+}
+
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl_ftable.h b/tools/emulator/opengl/system/GLESv1_enc/gl_ftable.h
new file mode 100644
index 0000000..7201e7f
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_ftable.h
@@ -0,0 +1,288 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __gl_client_ftable_t_h
+#define __gl_client_ftable_t_h
+
+
+static struct _gl_funcs_by_name {
+	const char *name;
+	void *proc;
+} gl_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},
+	{"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},
+	{"glClipPlanex", (void*)glClipPlanex},
+	{"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},
+	{"glClipPlanexIMG", (void*)glClipPlanexIMG},
+	{"glColor4xOES", (void*)glColor4xOES},
+	{"glDepthRangexOES", (void*)glDepthRangexOES},
+	{"glFogxOES", (void*)glFogxOES},
+	{"glFogxvOES", (void*)glFogxvOES},
+	{"glFrustumxOES", (void*)glFrustumxOES},
+	{"glGetClipPlanexOES", (void*)glGetClipPlanexOES},
+	{"glGetClipPlanex", (void*)glGetClipPlanex},
+	{"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},
+	{"glClipPlanefIMG", (void*)glClipPlanefIMG},
+	{"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},
+	{"glMultiDrawArraysSUN", (void*)glMultiDrawArraysSUN},
+	{"glMultiDrawElementsSUN", (void*)glMultiDrawElementsSUN},
+	{"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 gl_num_funcs = sizeof(gl_funcs_by_name) / sizeof(struct _gl_funcs_by_name);
+
+
+#endif
diff --git a/tools/emulator/opengl/system/GLESv1_enc/gl_opcodes.h b/tools/emulator/opengl/system/GLESv1_enc/gl_opcodes.h
new file mode 100644
index 0000000..319d0a1
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_opcodes.h
@@ -0,0 +1,300 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __GUARD_gl_opcodes_h_
+#define __GUARD_gl_opcodes_h_
+
+#define OP_glAlphaFunc 					1024
+#define OP_glClearColor 					1025
+#define OP_glClearDepthf 					1026
+#define OP_glClipPlanef 					1027
+#define OP_glColor4f 					1028
+#define OP_glDepthRangef 					1029
+#define OP_glFogf 					1030
+#define OP_glFogfv 					1031
+#define OP_glFrustumf 					1032
+#define OP_glGetClipPlanef 					1033
+#define OP_glGetFloatv 					1034
+#define OP_glGetLightfv 					1035
+#define OP_glGetMaterialfv 					1036
+#define OP_glGetTexEnvfv 					1037
+#define OP_glGetTexParameterfv 					1038
+#define OP_glLightModelf 					1039
+#define OP_glLightModelfv 					1040
+#define OP_glLightf 					1041
+#define OP_glLightfv 					1042
+#define OP_glLineWidth 					1043
+#define OP_glLoadMatrixf 					1044
+#define OP_glMaterialf 					1045
+#define OP_glMaterialfv 					1046
+#define OP_glMultMatrixf 					1047
+#define OP_glMultiTexCoord4f 					1048
+#define OP_glNormal3f 					1049
+#define OP_glOrthof 					1050
+#define OP_glPointParameterf 					1051
+#define OP_glPointParameterfv 					1052
+#define OP_glPointSize 					1053
+#define OP_glPolygonOffset 					1054
+#define OP_glRotatef 					1055
+#define OP_glScalef 					1056
+#define OP_glTexEnvf 					1057
+#define OP_glTexEnvfv 					1058
+#define OP_glTexParameterf 					1059
+#define OP_glTexParameterfv 					1060
+#define OP_glTranslatef 					1061
+#define OP_glActiveTexture 					1062
+#define OP_glAlphaFuncx 					1063
+#define OP_glBindBuffer 					1064
+#define OP_glBindTexture 					1065
+#define OP_glBlendFunc 					1066
+#define OP_glBufferData 					1067
+#define OP_glBufferSubData 					1068
+#define OP_glClear 					1069
+#define OP_glClearColorx 					1070
+#define OP_glClearDepthx 					1071
+#define OP_glClearStencil 					1072
+#define OP_glClientActiveTexture 					1073
+#define OP_glColor4ub 					1074
+#define OP_glColor4x 					1075
+#define OP_glColorMask 					1076
+#define OP_glColorPointer 					1077
+#define OP_glCompressedTexImage2D 					1078
+#define OP_glCompressedTexSubImage2D 					1079
+#define OP_glCopyTexImage2D 					1080
+#define OP_glCopyTexSubImage2D 					1081
+#define OP_glCullFace 					1082
+#define OP_glDeleteBuffers 					1083
+#define OP_glDeleteTextures 					1084
+#define OP_glDepthFunc 					1085
+#define OP_glDepthMask 					1086
+#define OP_glDepthRangex 					1087
+#define OP_glDisable 					1088
+#define OP_glDisableClientState 					1089
+#define OP_glDrawArrays 					1090
+#define OP_glDrawElements 					1091
+#define OP_glEnable 					1092
+#define OP_glEnableClientState 					1093
+#define OP_glFinish 					1094
+#define OP_glFlush 					1095
+#define OP_glFogx 					1096
+#define OP_glFogxv 					1097
+#define OP_glFrontFace 					1098
+#define OP_glFrustumx 					1099
+#define OP_glGetBooleanv 					1100
+#define OP_glGetBufferParameteriv 					1101
+#define OP_glClipPlanex 					1102
+#define OP_glGenBuffers 					1103
+#define OP_glGenTextures 					1104
+#define OP_glGetError 					1105
+#define OP_glGetFixedv 					1106
+#define OP_glGetIntegerv 					1107
+#define OP_glGetLightxv 					1108
+#define OP_glGetMaterialxv 					1109
+#define OP_glGetPointerv 					1110
+#define OP_glGetString 					1111
+#define OP_glGetTexEnviv 					1112
+#define OP_glGetTexEnvxv 					1113
+#define OP_glGetTexParameteriv 					1114
+#define OP_glGetTexParameterxv 					1115
+#define OP_glHint 					1116
+#define OP_glIsBuffer 					1117
+#define OP_glIsEnabled 					1118
+#define OP_glIsTexture 					1119
+#define OP_glLightModelx 					1120
+#define OP_glLightModelxv 					1121
+#define OP_glLightx 					1122
+#define OP_glLightxv 					1123
+#define OP_glLineWidthx 					1124
+#define OP_glLoadIdentity 					1125
+#define OP_glLoadMatrixx 					1126
+#define OP_glLogicOp 					1127
+#define OP_glMaterialx 					1128
+#define OP_glMaterialxv 					1129
+#define OP_glMatrixMode 					1130
+#define OP_glMultMatrixx 					1131
+#define OP_glMultiTexCoord4x 					1132
+#define OP_glNormal3x 					1133
+#define OP_glNormalPointer 					1134
+#define OP_glOrthox 					1135
+#define OP_glPixelStorei 					1136
+#define OP_glPointParameterx 					1137
+#define OP_glPointParameterxv 					1138
+#define OP_glPointSizex 					1139
+#define OP_glPolygonOffsetx 					1140
+#define OP_glPopMatrix 					1141
+#define OP_glPushMatrix 					1142
+#define OP_glReadPixels 					1143
+#define OP_glRotatex 					1144
+#define OP_glSampleCoverage 					1145
+#define OP_glSampleCoveragex 					1146
+#define OP_glScalex 					1147
+#define OP_glScissor 					1148
+#define OP_glShadeModel 					1149
+#define OP_glStencilFunc 					1150
+#define OP_glStencilMask 					1151
+#define OP_glStencilOp 					1152
+#define OP_glTexCoordPointer 					1153
+#define OP_glTexEnvi 					1154
+#define OP_glTexEnvx 					1155
+#define OP_glTexEnviv 					1156
+#define OP_glTexEnvxv 					1157
+#define OP_glTexImage2D 					1158
+#define OP_glTexParameteri 					1159
+#define OP_glTexParameterx 					1160
+#define OP_glTexParameteriv 					1161
+#define OP_glTexParameterxv 					1162
+#define OP_glTexSubImage2D 					1163
+#define OP_glTranslatex 					1164
+#define OP_glVertexPointer 					1165
+#define OP_glViewport 					1166
+#define OP_glPointSizePointerOES 					1167
+#define OP_glVertexPointerOffset 					1168
+#define OP_glColorPointerOffset 					1169
+#define OP_glNormalPointerOffset 					1170
+#define OP_glPointSizePointerOffset 					1171
+#define OP_glTexCoordPointerOffset 					1172
+#define OP_glWeightPointerOffset 					1173
+#define OP_glMatrixIndexPointerOffset 					1174
+#define OP_glVertexPointerData 					1175
+#define OP_glColorPointerData 					1176
+#define OP_glNormalPointerData 					1177
+#define OP_glTexCoordPointerData 					1178
+#define OP_glPointSizePointerData 					1179
+#define OP_glWeightPointerData 					1180
+#define OP_glMatrixIndexPointerData 					1181
+#define OP_glDrawElementsOffset 					1182
+#define OP_glDrawElementsData 					1183
+#define OP_glGetCompressedTextureFormats 					1184
+#define OP_glFinishRoundTrip 					1185
+#define OP_glBlendEquationSeparateOES 					1186
+#define OP_glBlendFuncSeparateOES 					1187
+#define OP_glBlendEquationOES 					1188
+#define OP_glDrawTexsOES 					1189
+#define OP_glDrawTexiOES 					1190
+#define OP_glDrawTexxOES 					1191
+#define OP_glDrawTexsvOES 					1192
+#define OP_glDrawTexivOES 					1193
+#define OP_glDrawTexxvOES 					1194
+#define OP_glDrawTexfOES 					1195
+#define OP_glDrawTexfvOES 					1196
+#define OP_glEGLImageTargetTexture2DOES 					1197
+#define OP_glEGLImageTargetRenderbufferStorageOES 					1198
+#define OP_glAlphaFuncxOES 					1199
+#define OP_glClearColorxOES 					1200
+#define OP_glClearDepthxOES 					1201
+#define OP_glClipPlanexOES 					1202
+#define OP_glClipPlanexIMG 					1203
+#define OP_glColor4xOES 					1204
+#define OP_glDepthRangexOES 					1205
+#define OP_glFogxOES 					1206
+#define OP_glFogxvOES 					1207
+#define OP_glFrustumxOES 					1208
+#define OP_glGetClipPlanexOES 					1209
+#define OP_glGetClipPlanex 					1210
+#define OP_glGetFixedvOES 					1211
+#define OP_glGetLightxvOES 					1212
+#define OP_glGetMaterialxvOES 					1213
+#define OP_glGetTexEnvxvOES 					1214
+#define OP_glGetTexParameterxvOES 					1215
+#define OP_glLightModelxOES 					1216
+#define OP_glLightModelxvOES 					1217
+#define OP_glLightxOES 					1218
+#define OP_glLightxvOES 					1219
+#define OP_glLineWidthxOES 					1220
+#define OP_glLoadMatrixxOES 					1221
+#define OP_glMaterialxOES 					1222
+#define OP_glMaterialxvOES 					1223
+#define OP_glMultMatrixxOES 					1224
+#define OP_glMultiTexCoord4xOES 					1225
+#define OP_glNormal3xOES 					1226
+#define OP_glOrthoxOES 					1227
+#define OP_glPointParameterxOES 					1228
+#define OP_glPointParameterxvOES 					1229
+#define OP_glPointSizexOES 					1230
+#define OP_glPolygonOffsetxOES 					1231
+#define OP_glRotatexOES 					1232
+#define OP_glSampleCoveragexOES 					1233
+#define OP_glScalexOES 					1234
+#define OP_glTexEnvxOES 					1235
+#define OP_glTexEnvxvOES 					1236
+#define OP_glTexParameterxOES 					1237
+#define OP_glTexParameterxvOES 					1238
+#define OP_glTranslatexOES 					1239
+#define OP_glIsRenderbufferOES 					1240
+#define OP_glBindRenderbufferOES 					1241
+#define OP_glDeleteRenderbuffersOES 					1242
+#define OP_glGenRenderbuffersOES 					1243
+#define OP_glRenderbufferStorageOES 					1244
+#define OP_glGetRenderbufferParameterivOES 					1245
+#define OP_glIsFramebufferOES 					1246
+#define OP_glBindFramebufferOES 					1247
+#define OP_glDeleteFramebuffersOES 					1248
+#define OP_glGenFramebuffersOES 					1249
+#define OP_glCheckFramebufferStatusOES 					1250
+#define OP_glFramebufferRenderbufferOES 					1251
+#define OP_glFramebufferTexture2DOES 					1252
+#define OP_glGetFramebufferAttachmentParameterivOES 					1253
+#define OP_glGenerateMipmapOES 					1254
+#define OP_glMapBufferOES 					1255
+#define OP_glUnmapBufferOES 					1256
+#define OP_glGetBufferPointervOES 					1257
+#define OP_glCurrentPaletteMatrixOES 					1258
+#define OP_glLoadPaletteFromModelViewMatrixOES 					1259
+#define OP_glMatrixIndexPointerOES 					1260
+#define OP_glWeightPointerOES 					1261
+#define OP_glQueryMatrixxOES 					1262
+#define OP_glDepthRangefOES 					1263
+#define OP_glFrustumfOES 					1264
+#define OP_glOrthofOES 					1265
+#define OP_glClipPlanefOES 					1266
+#define OP_glClipPlanefIMG 					1267
+#define OP_glGetClipPlanefOES 					1268
+#define OP_glClearDepthfOES 					1269
+#define OP_glTexGenfOES 					1270
+#define OP_glTexGenfvOES 					1271
+#define OP_glTexGeniOES 					1272
+#define OP_glTexGenivOES 					1273
+#define OP_glTexGenxOES 					1274
+#define OP_glTexGenxvOES 					1275
+#define OP_glGetTexGenfvOES 					1276
+#define OP_glGetTexGenivOES 					1277
+#define OP_glGetTexGenxvOES 					1278
+#define OP_glBindVertexArrayOES 					1279
+#define OP_glDeleteVertexArraysOES 					1280
+#define OP_glGenVertexArraysOES 					1281
+#define OP_glIsVertexArrayOES 					1282
+#define OP_glDiscardFramebufferEXT 					1283
+#define OP_glMultiDrawArraysEXT 					1284
+#define OP_glMultiDrawElementsEXT 					1285
+#define OP_glMultiDrawArraysSUN 					1286
+#define OP_glMultiDrawElementsSUN 					1287
+#define OP_glRenderbufferStorageMultisampleIMG 					1288
+#define OP_glFramebufferTexture2DMultisampleIMG 					1289
+#define OP_glDeleteFencesNV 					1290
+#define OP_glGenFencesNV 					1291
+#define OP_glIsFenceNV 					1292
+#define OP_glTestFenceNV 					1293
+#define OP_glGetFenceivNV 					1294
+#define OP_glFinishFenceNV 					1295
+#define OP_glSetFenceNV 					1296
+#define OP_glGetDriverControlsQCOM 					1297
+#define OP_glGetDriverControlStringQCOM 					1298
+#define OP_glEnableDriverControlQCOM 					1299
+#define OP_glDisableDriverControlQCOM 					1300
+#define OP_glExtGetTexturesQCOM 					1301
+#define OP_glExtGetBuffersQCOM 					1302
+#define OP_glExtGetRenderbuffersQCOM 					1303
+#define OP_glExtGetFramebuffersQCOM 					1304
+#define OP_glExtGetTexLevelParameterivQCOM 					1305
+#define OP_glExtTexObjectStateOverrideiQCOM 					1306
+#define OP_glExtGetTexSubImageQCOM 					1307
+#define OP_glExtGetBufferPointervQCOM 					1308
+#define OP_glExtGetShadersQCOM 					1309
+#define OP_glExtGetProgramsQCOM 					1310
+#define OP_glExtIsProgramBinaryQCOM 					1311
+#define OP_glExtGetProgramBinarySourceQCOM 					1312
+#define OP_glStartTilingQCOM 					1313
+#define OP_glEndTilingQCOM 					1314
+#define OP_last 					1315
+
+
+#endif
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..36fabfb
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv1_enc/gl_types.h
@@ -0,0 +1,20 @@
+/*
+* 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 "gl_base_types.h"
+#endif
diff --git a/tools/emulator/opengl/system/GLESv2/Android.mk b/tools/emulator/opengl/system/GLESv2/Android.mk
new file mode 100644
index 0000000..c299522
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+
+### GLESv2 implementation ###########################################
+$(call emugl-begin-shared-library,libGLESv2_emulation)
+$(call emugl-import,libOpenglSystemCommon libGLESv2_enc lib_renderControl_enc)
+
+LOCAL_CFLAGS += -DLOG_TAG=\"GLESv2_emulation\" -DGL_GLEXT_PROTOTYPES
+
+LOCAL_SRC_FILES := gl2.cpp
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
+
+$(call emugl-end-module)
diff --git a/tools/emulator/opengl/system/GLESv2/gl2.cpp b/tools/emulator/opengl/system/GLESv2/gl2.cpp
new file mode 100644
index 0000000..b32dd74
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2/gl2.cpp
@@ -0,0 +1,143 @@
+/*
+* Copyright 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 "EGLClientIface.h"
+#include "HostConnection.h"
+#include "GL2Encoder.h"
+#include "GLES/gl.h"
+#include "GLES/glext.h"
+#include "ErrorLog.h"
+#include "gralloc_cb.h"
+#include "ThreadInfo.h"
+
+//XXX: fix this macro to get the context from fast tls path
+#define GET_CONTEXT GL2Encoder * ctx = getEGLThreadInfo()->hostConn->gl2Encoder();
+
+#include "gl2_entry.cpp"
+
+//The functions table
+#include "gl2_ftable.h"
+
+
+static EGLClient_eglInterface * s_egl = NULL;
+static EGLClient_glesInterface * s_gl = NULL;
+
+#define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \
+    HostConnection *hostCon = HostConnection::get(); \
+    if (!hostCon) { \
+        ALOGE("egl: Failed to get host connection\n"); \
+        return ret; \
+    } \
+    renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
+    if (!rcEnc) { \
+        ALOGE("egl: Failed to get renderControl encoder context\n"); \
+        return ret; \
+    }
+
+//GL extensions
+void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES image)
+{
+    DBG("glEGLImageTargetTexture2DOES v2 target=%#x img=%p\n", target, image);
+    //TODO: check error - we don't have a way to set gl error
+    android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+
+    if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
+        return;
+    }
+
+    if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+        return;
+    }
+
+    GET_CONTEXT;
+    DEFINE_AND_VALIDATE_HOST_CONNECTION();
+
+    ctx->override2DTextureTarget(target);
+    rcEnc->rcBindTexture(rcEnc, ((cb_handle_t *)(native_buffer->handle))->hostHandle);
+    ctx->restore2DTextureTarget();
+
+    return;
+}
+
+void glEGLImageTargetRenderbufferStorageOES(void *self, GLenum target, GLeglImageOES image)
+{
+    DBG("glEGLImageTargetRenderbufferStorageOES v2 image=%p\n", image);
+    //TODO: check error - we don't have a way to set gl error
+    android_native_buffer_t* native_buffer = (android_native_buffer_t*)image;
+
+    if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) {
+        return;
+    }
+
+    if (native_buffer->common.version != sizeof(android_native_buffer_t)) {
+        return;
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION();
+    rcEnc->rcBindRenderbuffer(rcEnc, ((cb_handle_t *)(native_buffer->handle))->hostHandle);
+
+    return;
+}
+
+void * getProcAddress(const char * procname)
+{
+    // search in GL function table
+    for (int i=0; i<gl2_num_funcs; i++) {
+        if (!strcmp(gl2_funcs_by_name[i].name, procname)) {
+            return gl2_funcs_by_name[i].proc;
+        }
+    }
+    return NULL;
+}
+
+void finish()
+{
+    glFinish();
+}
+
+const GLubyte *my_glGetString (void *self, GLenum name)
+{
+    if (s_egl) {
+        return (const GLubyte*)s_egl->getGLString(name);
+    }
+    return NULL;
+}
+
+void init()
+{
+    GET_CONTEXT;
+    ctx->set_glEGLImageTargetTexture2DOES(glEGLImageTargetTexture2DOES);
+    ctx->set_glEGLImageTargetRenderbufferStorageOES(glEGLImageTargetRenderbufferStorageOES);
+    ctx->set_glGetString(my_glGetString);
+}
+
+extern "C" {
+EGLClient_glesInterface * init_emul_gles(EGLClient_eglInterface *eglIface)
+{
+    s_egl = eglIface;
+
+    if (!s_gl) {
+        s_gl = new EGLClient_glesInterface();
+        s_gl->getProcAddress = getProcAddress;
+        s_gl->finish = finish;
+        s_gl->init = init;
+    }
+
+    return s_gl;
+}
+} //extern
+
+
diff --git a/tools/emulator/opengl/system/GLESv2_enc/Android.mk b/tools/emulator/opengl/system/GLESv2_enc/Android.mk
new file mode 100644
index 0000000..e76a175
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/Android.mk
@@ -0,0 +1,20 @@
+LOCAL_PATH := $(call my-dir)
+
+### GLESv2_enc Encoder ###########################################
+$(call emugl-begin-shared-library,libGLESv2_enc)
+
+LOCAL_SRC_FILES := \
+    GL2EncoderUtils.cpp \
+    GL2Encoder.cpp \
+    gl2_client_context.cpp \
+    gl2_enc.cpp \
+    gl2_entry.cpp
+
+LOCAL_CFLAGS += -DLOG_TAG=\"emuglGLESv2_enc\"
+
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+$(call emugl-import,libOpenglCodecCommon)
+
+$(call emugl-end-module)
+
+
diff --git a/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp b/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp
new file mode 100644
index 0000000..d8fedf3
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp
@@ -0,0 +1,1197 @@
+/*
+* 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 "GL2Encoder.h"
+#include <assert.h>
+#include <ctype.h>
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+static GLubyte *gVendorString= (GLubyte *) "Android";
+static GLubyte *gRendererString= (GLubyte *) "Android HW-GLES 2.0";
+static GLubyte *gVersionString= (GLubyte *) "OpenGL ES 2.0";
+static GLubyte *gExtensionsString= (GLubyte *) ""; // no extensions at this point;
+
+#define SET_ERROR_IF(condition,err) if((condition)) {                            \
+        ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+        ctx->setError(err);                                    \
+        return;                                                  \
+    }
+
+
+#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) {                \
+        ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+        ctx->setError(err);                                    \
+        return ret;                                              \
+    }
+
+
+GL2Encoder::GL2Encoder(IOStream *stream) : gl2_encoder_context_t(stream)
+{
+    m_initialized = false;
+    m_state = NULL;
+    m_error = GL_NO_ERROR;
+    m_num_compressedTextureFormats = 0;
+    m_compressedTextureFormats = NULL;
+    //overrides
+    m_glFlush_enc = set_glFlush(s_glFlush);
+    m_glPixelStorei_enc = set_glPixelStorei(s_glPixelStorei);
+    m_glGetString_enc = set_glGetString(s_glGetString);
+    m_glBindBuffer_enc = set_glBindBuffer(s_glBindBuffer);
+    m_glBufferData_enc = set_glBufferData(s_glBufferData);
+    m_glBufferSubData_enc = set_glBufferSubData(s_glBufferSubData);
+    m_glDeleteBuffers_enc = set_glDeleteBuffers(s_glDeleteBuffers);
+    m_glDrawArrays_enc = set_glDrawArrays(s_glDrawArrays);
+    m_glDrawElements_enc = set_glDrawElements(s_glDrawElements);
+    m_glGetIntegerv_enc = set_glGetIntegerv(s_glGetIntegerv);
+    m_glGetFloatv_enc = set_glGetFloatv(s_glGetFloatv);
+    m_glGetBooleanv_enc = set_glGetBooleanv(s_glGetBooleanv);
+    m_glVertexAttribPointer_enc = set_glVertexAttribPointer(s_glVertexAtrribPointer);
+    m_glEnableVertexAttribArray_enc = set_glEnableVertexAttribArray(s_glEnableVertexAttribArray);
+    m_glDisableVertexAttribArray_enc = set_glDisableVertexAttribArray(s_glDisableVertexAttribArray);
+    m_glGetVertexAttribiv_enc = set_glGetVertexAttribiv(s_glGetVertexAttribiv);
+    m_glGetVertexAttribfv_enc = set_glGetVertexAttribfv(s_glGetVertexAttribfv);
+    m_glGetVertexAttribPointerv = set_glGetVertexAttribPointerv(s_glGetVertexAttribPointerv);
+    set_glShaderSource(s_glShaderSource);
+    set_glFinish(s_glFinish);
+    m_glGetError_enc = set_glGetError(s_glGetError);
+    m_glLinkProgram_enc = set_glLinkProgram(s_glLinkProgram);
+    m_glDeleteProgram_enc = set_glDeleteProgram(s_glDeleteProgram);
+    m_glGetUniformiv_enc = set_glGetUniformiv(s_glGetUniformiv);
+    m_glGetUniformfv_enc = set_glGetUniformfv(s_glGetUniformfv);
+    m_glCreateProgram_enc = set_glCreateProgram(s_glCreateProgram);
+    m_glCreateShader_enc = set_glCreateShader(s_glCreateShader);
+    m_glDeleteShader_enc = set_glDeleteShader(s_glDeleteShader);
+    m_glAttachShader_enc = set_glAttachShader(s_glAttachShader);
+    m_glDetachShader_enc = set_glDetachShader(s_glDetachShader);
+    m_glGetUniformLocation_enc = set_glGetUniformLocation(s_glGetUniformLocation);
+    m_glUseProgram_enc = set_glUseProgram(s_glUseProgram);
+
+    m_glUniform1f_enc = set_glUniform1f(s_glUniform1f);
+    m_glUniform1fv_enc = set_glUniform1fv(s_glUniform1fv);
+    m_glUniform1i_enc = set_glUniform1i(s_glUniform1i);
+    m_glUniform1iv_enc = set_glUniform1iv(s_glUniform1iv);
+    m_glUniform2f_enc = set_glUniform2f(s_glUniform2f);
+    m_glUniform2fv_enc = set_glUniform2fv(s_glUniform2fv);
+    m_glUniform2i_enc = set_glUniform2i(s_glUniform2i);
+    m_glUniform2iv_enc = set_glUniform2iv(s_glUniform2iv);
+    m_glUniform3f_enc = set_glUniform3f(s_glUniform3f);
+    m_glUniform3fv_enc = set_glUniform3fv(s_glUniform3fv);
+    m_glUniform3i_enc = set_glUniform3i(s_glUniform3i);
+    m_glUniform3iv_enc = set_glUniform3iv(s_glUniform3iv);
+    m_glUniform4f_enc = set_glUniform4f(s_glUniform4f);
+    m_glUniform4fv_enc = set_glUniform4fv(s_glUniform4fv);
+    m_glUniform4i_enc = set_glUniform4i(s_glUniform4i);
+    m_glUniform4iv_enc = set_glUniform4iv(s_glUniform4iv);
+    m_glUniformMatrix2fv_enc = set_glUniformMatrix2fv(s_glUniformMatrix2fv);
+    m_glUniformMatrix3fv_enc = set_glUniformMatrix3fv(s_glUniformMatrix3fv);
+    m_glUniformMatrix4fv_enc = set_glUniformMatrix4fv(s_glUniformMatrix4fv);
+
+    m_glActiveTexture_enc = set_glActiveTexture(s_glActiveTexture);
+    m_glBindTexture_enc = set_glBindTexture(s_glBindTexture);
+    m_glDeleteTextures_enc = set_glDeleteTextures(s_glDeleteTextures);
+    m_glGetTexParameterfv_enc = set_glGetTexParameterfv(s_glGetTexParameterfv);
+    m_glGetTexParameteriv_enc = set_glGetTexParameteriv(s_glGetTexParameteriv);
+    m_glTexParameterf_enc = set_glTexParameterf(s_glTexParameterf);
+    m_glTexParameterfv_enc = set_glTexParameterfv(s_glTexParameterfv);
+    m_glTexParameteri_enc = set_glTexParameteri(s_glTexParameteri);
+    m_glTexParameteriv_enc = set_glTexParameteriv(s_glTexParameteriv);
+}
+
+GL2Encoder::~GL2Encoder()
+{
+    delete m_compressedTextureFormats;
+}
+
+GLenum GL2Encoder::s_glGetError(void * self)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    GLenum err = ctx->getError();
+    if(err != GL_NO_ERROR) {
+        ctx->setError(GL_NO_ERROR);
+        return err;
+    }
+
+    return ctx->m_glGetError_enc(self);
+
+}
+
+void GL2Encoder::s_glFlush(void *self)
+{
+    GL2Encoder *ctx = (GL2Encoder *) self;
+    ctx->m_glFlush_enc(self);
+    ctx->m_stream->flush();
+}
+
+const GLubyte *GL2Encoder::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 GL2Encoder::s_glPixelStorei(void *self, GLenum param, GLint value)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    ctx->m_glPixelStorei_enc(ctx, param, value);
+    assert(ctx->m_state != NULL);
+    ctx->m_state->setPixelStore(param, value);
+}
+
+
+void GL2Encoder::s_glBindBuffer(void *self, GLenum target, GLuint id)
+{
+    GL2Encoder *ctx = (GL2Encoder *) self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->bindBuffer(target, id);
+    // TODO set error state if needed;
+    ctx->m_glBindBuffer_enc(self, target, id);
+}
+
+void GL2Encoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage)
+{
+    GL2Encoder *ctx = (GL2Encoder *) self;
+    GLuint bufferId = ctx->m_state->getBuffer(target);
+    SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION);
+    SET_ERROR_IF(size<0, GL_INVALID_VALUE);
+
+    ctx->m_shared->updateBufferData(bufferId, size, (void*)data);
+    ctx->m_glBufferData_enc(self, target, size, data, usage);
+}
+
+void GL2Encoder::s_glBufferSubData(void * self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data)
+{
+    GL2Encoder *ctx = (GL2Encoder *) self;
+    GLuint bufferId = ctx->m_state->getBuffer(target);
+    SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION);
+
+    GLenum res = ctx->m_shared->subUpdateBufferData(bufferId, offset, size, (void*)data);
+    SET_ERROR_IF(res, res);
+
+    ctx->m_glBufferSubData_enc(self, target, offset, size, data);
+}
+
+void GL2Encoder::s_glDeleteBuffers(void * self, GLsizei n, const GLuint * buffers)
+{
+    GL2Encoder *ctx = (GL2Encoder *) self;
+    SET_ERROR_IF(n<0, GL_INVALID_VALUE);
+    for (int i=0; i<n; i++) {
+        ctx->m_shared->deleteBufferData(buffers[i]);
+        ctx->m_glDeleteBuffers_enc(self,1,&buffers[i]);
+    }
+}
+
+void GL2Encoder::s_glVertexAtrribPointer(void *self, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * ptr)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert(ctx->m_state != NULL);
+    ctx->m_state->setState(indx, size, type, normalized, stride, ptr);
+}
+
+void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
+{
+    GL2Encoder *ctx = (GL2Encoder *) self;
+    assert(ctx->m_state != NULL);
+    GLClientState* state = ctx->m_state;
+
+    switch (param) {
+    case GL_NUM_SHADER_BINARY_FORMATS:
+        *ptr = 0;
+        break;
+    case GL_SHADER_BINARY_FORMATS:
+        // do nothing
+        break;
+
+    case 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));
+        }
+        break;
+    }
+
+    case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
+    case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
+    case GL_MAX_TEXTURE_IMAGE_UNITS:
+        ctx->m_glGetIntegerv_enc(self, param, ptr);
+        *ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS);
+        break;
+
+    case GL_TEXTURE_BINDING_2D:
+        *ptr = state->getBoundTexture(GL_TEXTURE_2D);
+        break;
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
+        *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES);
+        break;
+
+    default:
+        if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) {
+            ctx->m_glGetIntegerv_enc(self, param, ptr);
+        }
+        break;
+    }
+}
+
+
+void GL2Encoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert(ctx->m_state != NULL);
+    GLClientState* state = ctx->m_state;
+
+    switch (param) {
+    case GL_NUM_SHADER_BINARY_FORMATS:
+        *ptr = 0;
+        break;
+    case GL_SHADER_BINARY_FORMATS:
+        // do nothing
+        break;
+
+    case 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];
+            }
+        }
+        break;
+    }
+
+    case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
+    case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
+    case GL_MAX_TEXTURE_IMAGE_UNITS:
+        ctx->m_glGetFloatv_enc(self, param, ptr);
+        *ptr = MIN(*ptr, (GLfloat)GLClientState::MAX_TEXTURE_UNITS);
+        break;
+
+    case GL_TEXTURE_BINDING_2D:
+        *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_2D);
+        break;
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
+        *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES);
+        break;
+
+    default:
+        if (!ctx->m_state->getClientStateParameter<GLfloat>(param, ptr)) {
+            ctx->m_glGetFloatv_enc(self, param, ptr);
+        }
+        break;
+    }
+}
+
+
+void GL2Encoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert(ctx->m_state != NULL);
+    GLClientState* state = ctx->m_state;
+
+    switch (param) {
+    case GL_NUM_SHADER_BINARY_FORMATS:
+        *ptr = GL_FALSE;
+        break;
+    case GL_SHADER_BINARY_FORMATS:
+        // do nothing
+        break;
+
+    case 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] != 0 ? GL_TRUE : GL_FALSE;
+            }
+        }
+        break;
+    }
+
+    case GL_TEXTURE_BINDING_2D:
+        *ptr = state->getBoundTexture(GL_TEXTURE_2D) != 0 ? GL_TRUE : GL_FALSE;
+        break;
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
+        *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES) != 0
+                ? GL_TRUE : GL_FALSE;
+        break;
+
+    default:
+        if (!ctx->m_state->getClientStateParameter<GLboolean>(param, ptr)) {
+            ctx->m_glGetBooleanv_enc(self, param, ptr);
+        }
+        break;
+    }
+}
+
+
+void GL2Encoder::s_glEnableVertexAttribArray(void *self, GLuint index)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert(ctx->m_state);
+    ctx->m_state->enable(index, 1);
+}
+
+void GL2Encoder::s_glDisableVertexAttribArray(void *self, GLuint index)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert(ctx->m_state);
+    ctx->m_state->enable(index, 0);
+}
+
+
+void GL2Encoder::s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert(ctx->m_state);
+
+    if (!ctx->m_state->getVertexAttribParameter<GLint>(index, pname, params)) {
+        ctx->m_glGetVertexAttribiv_enc(self, index, pname, params);
+    }
+}
+
+void GL2Encoder::s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert(ctx->m_state);
+
+    if (!ctx->m_state->getVertexAttribParameter<GLfloat>(index, pname, params)) {
+        ctx->m_glGetVertexAttribfv_enc(self, index, pname, params);
+    }
+}
+
+void GL2Encoder::s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    if (ctx->m_state == NULL) return;
+
+    const GLClientState::VertexAttribState *va_state = ctx->m_state->getState(index);
+    if (va_state != NULL) {
+        *pointer = va_state->data;
+    }
+}
+
+
+void GL2Encoder::sendVertexAttributes(GLint first, GLsizei count)
+{
+    assert(m_state);
+
+    for (int i = 0; i < m_state->nLocations(); i++) {
+        bool enableDirty;
+        const GLClientState::VertexAttribState *state = m_state->getStateAndEnableDirty(i, &enableDirty);
+
+        if (!state) {
+            continue;
+        }
+
+        if (!enableDirty && !state->enabled) {
+            continue;
+        }
+
+
+        if (state->enabled) {
+            m_glEnableVertexAttribArray_enc(this, i);
+
+            unsigned int datalen = state->elementSize * count;
+            int stride = state->stride == 0 ? state->elementSize : state->stride;
+            int firstIndex = stride * first;
+
+            if (state->bufferObject == 0) {
+                this->glVertexAttribPointerData(this, i, state->size, state->type, state->normalized, state->stride,
+                                                (unsigned char *)state->data + firstIndex, datalen);
+            } else {
+                this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, state->bufferObject);
+                this->glVertexAttribPointerOffset(this, i, state->size, state->type, state->normalized, state->stride,
+                                                  (GLuint) state->data + firstIndex);
+                this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo());
+            }
+        } else {
+            this->m_glDisableVertexAttribArray_enc(this, i);
+        }
+    }
+}
+
+void GL2Encoder::s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    ctx->sendVertexAttributes(first, count);
+    ctx->m_glDrawArrays_enc(ctx, mode, 0, count);
+}
+
+
+void GL2Encoder::s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices)
+{
+
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert(ctx->m_state != NULL);
+    SET_ERROR_IF(count<0, GL_INVALID_VALUE);
+
+    bool has_immediate_arrays = false;
+    bool has_indirect_arrays = false;
+    int nLocations = ctx->m_state->nLocations();
+
+    for (int i = 0; i < nLocations; 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) {
+        ALOGE("glDrawElements: no data bound to the command - ignoring\n");
+        return;
+    }
+
+    bool adjustIndices = true;
+    if (ctx->m_state->currentIndexVbo() != 0) {
+        if (!has_immediate_arrays) {
+            ctx->sendVertexAttributes(0, count);
+            ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, ctx->m_state->currentIndexVbo());
+            ctx->glDrawElementsOffset(ctx, mode, count, type, (GLuint)indices);
+            adjustIndices = false;
+        } else {
+            BufferData * buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
+            ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, 0);
+            indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+        }
+    } 
+    if (adjustIndices) {
+        void *adjustedIndices = (void*)indices;
+        int minIndex = 0, maxIndex = 0;
+
+        switch(type) {
+        case GL_BYTE:
+        case GL_UNSIGNED_BYTE:
+            GLUtils::minmax<unsigned char>((unsigned char *)indices, count, &minIndex, &maxIndex);
+            if (minIndex != 0) {
+                adjustedIndices =  ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                GLUtils::shiftIndices<unsigned char>((unsigned char *)indices,
+                                                 (unsigned char *)adjustedIndices,
+                                                 count, -minIndex);
+            }
+            break;
+        case GL_SHORT:
+        case GL_UNSIGNED_SHORT:
+            GLUtils::minmax<unsigned short>((unsigned short *)indices, count, &minIndex, &maxIndex);
+            if (minIndex != 0) {
+                adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                GLUtils::shiftIndices<unsigned short>((unsigned short *)indices,
+                                                  (unsigned short *)adjustedIndices,
+                                                  count, -minIndex);
+            }
+            break;
+        default:
+            ALOGE("unsupported index buffer type %d\n", type);
+        }
+        if (has_indirect_arrays || 1) {
+            ctx->sendVertexAttributes(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) {
+                //ALOGD("unoptimized drawelements !!!\n");
+            }
+        } else {
+            // we are all direct arrays and immidate mode index array -
+            // rebuild the arrays and the index array;
+            ALOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n");
+        }
+    }
+}
+
+
+GLint * GL2Encoder::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;
+}
+
+// Replace uses of samplerExternalOES with sampler2D, recording the names of
+// modified shaders in data. Also remove
+//   #extension GL_OES_EGL_image_external : require
+// statements.
+//
+// This implementation assumes the input has already been pre-processed. If not,
+// a few cases will be mishandled:
+//
+// 1. "mySampler" will be incorrectly recorded as being a samplerExternalOES in
+//    the following code:
+//      #if 1
+//      uniform sampler2D mySampler;
+//      #else
+//      uniform samplerExternalOES mySampler;
+//      #endif
+//
+// 2. Comments that look like sampler declarations will be incorrectly modified
+//    and recorded:
+//      // samplerExternalOES hahaFooledYou
+//
+// 3. However, GLSL ES does not have a concatentation operator, so things like
+//    this (valid in C) are invalid and not a problem:
+//      #define SAMPLER(TYPE, NAME) uniform sampler#TYPE NAME
+//      SAMPLER(ExternalOES, mySampler);
+//
+static bool replaceSamplerExternalWith2D(char* const str, ShaderData* const data)
+{
+    static const char STR_HASH_EXTENSION[] = "#extension";
+    static const char STR_GL_OES_EGL_IMAGE_EXTERNAL[] = "GL_OES_EGL_image_external";
+    static const char STR_SAMPLER_EXTERNAL_OES[] = "samplerExternalOES";
+    static const char STR_SAMPLER2D_SPACE[]      = "sampler2D         ";
+
+    // -- overwrite all "#extension GL_OES_EGL_image_external : xxx" statements
+    char* c = str;
+    while ((c = strstr(c, STR_HASH_EXTENSION))) {
+        char* start = c;
+        c += sizeof(STR_HASH_EXTENSION)-1;
+        while (isspace(*c) && *c != '\0') {
+            c++;
+        }
+        if (strncmp(c, STR_GL_OES_EGL_IMAGE_EXTERNAL,
+                sizeof(STR_GL_OES_EGL_IMAGE_EXTERNAL)-1) == 0)
+        {
+            // #extension statements are terminated by end of line
+            c = start;
+            while (*c != '\0' && *c != '\r' && *c != '\n') {
+                *c++ = ' ';
+            }
+        }
+    }
+
+    // -- replace "samplerExternalOES" with "sampler2D" and record name
+    c = str;
+    while ((c = strstr(c, STR_SAMPLER_EXTERNAL_OES))) {
+        // Make sure "samplerExternalOES" isn't a substring of a larger token
+        if (c == str || !isspace(*(c-1))) {
+            c++;
+            continue;
+        }
+        char* sampler_start = c;
+        c += sizeof(STR_SAMPLER_EXTERNAL_OES)-1;
+        if (!isspace(*c) && *c != '\0') {
+            continue;
+        }
+
+        // capture sampler name
+        while (isspace(*c) && *c != '\0') {
+            c++;
+        }
+        if (!isalpha(*c) && *c != '_') {
+            // not an identifier
+            return false;
+        }
+        char* name_start = c;
+        do {
+            c++;
+        } while (isalnum(*c) || *c == '_');
+        data->samplerExternalNames.push_back(
+                android::String8(name_start, c - name_start));
+
+        // memcpy instead of strcpy since we don't want the NUL terminator
+        memcpy(sampler_start, STR_SAMPLER2D_SPACE, sizeof(STR_SAMPLER2D_SPACE)-1);
+    }
+
+    return true;
+}
+
+void GL2Encoder::s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar **string, const GLint *length)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    ShaderData* shaderData = ctx->m_shared->getShaderData(shader);
+    SET_ERROR_IF(!shaderData, GL_INVALID_VALUE);
+
+    int len = glUtilsCalcShaderSourceLen((char**)string, (GLint*)length, count);
+    char *str = new char[len + 1];
+    glUtilsPackStrings(str, (char**)string, (GLint*)length, count);
+
+    // TODO: pre-process str before calling replaceSamplerExternalWith2D().
+    // Perhaps we can borrow Mesa's pre-processor?
+
+    if (!replaceSamplerExternalWith2D(str, shaderData)) {
+        delete str;
+        ctx->setError(GL_OUT_OF_MEMORY);
+        return;
+    }
+
+    ctx->glShaderString(ctx, shader, str, len + 1);
+    delete str;
+}
+
+void GL2Encoder::s_glFinish(void *self)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    ctx->glFinishRoundTrip(self);
+}
+
+void GL2Encoder::s_glLinkProgram(void * self, GLuint program)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    ctx->m_glLinkProgram_enc(self, program);
+
+    GLint linkStatus = 0;
+    ctx->glGetProgramiv(self,program,GL_LINK_STATUS,&linkStatus);
+    if (!linkStatus)
+        return;
+
+    //get number of active uniforms in the program
+    GLint numUniforms=0;
+    ctx->glGetProgramiv(self, program, GL_ACTIVE_UNIFORMS, &numUniforms);
+    ctx->m_shared->initProgramData(program,numUniforms);
+
+    //get the length of the longest uniform name
+    GLint maxLength=0;
+    ctx->glGetProgramiv(self, program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength);
+
+    GLint size;
+    GLenum type;
+    GLchar *name = new GLchar[maxLength+1];
+    GLint location;
+    //for each active uniform, get its size and starting location.
+    for (GLint i=0 ; i<numUniforms ; ++i) 
+    {
+        ctx->glGetActiveUniform(self, program, i, maxLength, NULL, &size, &type, name);
+        location = ctx->m_glGetUniformLocation_enc(self, program, name);
+        ctx->m_shared->setProgramIndexInfo(program, i, location, size, type, name);
+    }
+    ctx->m_shared->setupLocationShiftWAR(program);
+
+    delete[] name;
+}
+
+void GL2Encoder::s_glDeleteProgram(void *self, GLuint program)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    ctx->m_glDeleteProgram_enc(self, program);
+
+    ctx->m_shared->deleteProgramData(program);
+}
+
+void GL2Encoder::s_glGetUniformiv(void *self, GLuint program, GLint location, GLint* params)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    SET_ERROR_IF(!ctx->m_shared->isProgram(program), GL_INVALID_VALUE);
+    SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION);
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(program, location);
+    SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,hostLoc)==0, GL_INVALID_OPERATION);
+    ctx->m_glGetUniformiv_enc(self, program, hostLoc, params);
+}
+void GL2Encoder::s_glGetUniformfv(void *self, GLuint program, GLint location, GLfloat* params)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    SET_ERROR_IF(!ctx->m_shared->isProgram(program), GL_INVALID_VALUE);
+    SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION);
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(program,location);
+    SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,hostLoc)==0, GL_INVALID_OPERATION);
+    ctx->m_glGetUniformfv_enc(self, program, hostLoc, params);
+}
+
+GLuint GL2Encoder::s_glCreateProgram(void * self)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLuint program = ctx->m_glCreateProgram_enc(self);
+    if (program!=0)
+        ctx->m_shared->addProgramData(program);
+    return program;
+}
+
+GLuint GL2Encoder::s_glCreateShader(void *self, GLenum shaderType)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLuint shader = ctx->m_glCreateShader_enc(self, shaderType);
+    if (shader != 0) {
+        if (!ctx->m_shared->addShaderData(shader)) {
+            ctx->m_glDeleteShader_enc(self, shader);
+            return 0;
+        }
+    }
+    return shader;
+}
+
+void GL2Encoder::s_glDeleteShader(void *self, GLenum shader)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    ctx->m_glDeleteShader_enc(self,shader);
+    ctx->m_shared->unrefShaderData(shader);
+}
+
+void GL2Encoder::s_glAttachShader(void *self, GLuint program, GLuint shader)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    ctx->m_glAttachShader_enc(self, program, shader);
+    ctx->m_shared->attachShader(program, shader);
+}
+
+void GL2Encoder::s_glDetachShader(void *self, GLuint program, GLuint shader)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    ctx->m_glDetachShader_enc(self, program, shader);
+    ctx->m_shared->detachShader(program, shader);
+}
+
+int GL2Encoder::s_glGetUniformLocation(void *self, GLuint program, const GLchar *name)
+{
+    if (!name) return -1;
+
+    GL2Encoder *ctx = (GL2Encoder*)self;
+
+    // if we need the uniform location WAR
+    // parse array index from the end of the name string
+    int arrIndex = 0;
+    bool needLocationWAR = ctx->m_shared->needUniformLocationWAR(program);
+    if (needLocationWAR) {
+        int namelen = strlen(name);
+        if (name[namelen-1] == ']') {
+            char *brace = strrchr(name,'[');
+            if (!brace || sscanf(brace+1,"%d",&arrIndex) != 1) {
+                return -1;
+            }
+        
+        }
+    }
+
+    int hostLoc = ctx->m_glGetUniformLocation_enc(self, program, name);
+    if (hostLoc >= 0 && needLocationWAR) {
+        return ctx->m_shared->locationWARHostToApp(program, hostLoc, arrIndex);
+    }
+    return hostLoc;
+}
+
+bool GL2Encoder::updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget)
+{
+    if (newTarget != GL_TEXTURE_2D && newTarget != GL_TEXTURE_EXTERNAL_OES)
+        return false;
+
+    m_state->setActiveTextureUnit(texUnit);
+
+    GLenum oldTarget = m_state->getPriorityEnabledTarget(GL_TEXTURE_2D);
+    if (newTarget != oldTarget) {
+        if (newTarget == GL_TEXTURE_EXTERNAL_OES) {
+            m_state->disableTextureTarget(GL_TEXTURE_2D);
+            m_state->enableTextureTarget(GL_TEXTURE_EXTERNAL_OES);
+        } else {
+            m_state->disableTextureTarget(GL_TEXTURE_EXTERNAL_OES);
+            m_state->enableTextureTarget(GL_TEXTURE_2D);
+        }
+        m_glActiveTexture_enc(this, texUnit);
+        m_glBindTexture_enc(this, GL_TEXTURE_2D,
+                m_state->getBoundTexture(newTarget));
+        return true;
+    }
+
+    return false;
+}
+
+void GL2Encoder::s_glUseProgram(void *self, GLuint program)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLClientState* state = ctx->m_state;
+    GLSharedGroupPtr shared = ctx->m_shared;
+
+    ctx->m_glUseProgram_enc(self, program);
+    ctx->m_state->setCurrentProgram(program);
+
+    GLenum origActiveTexture = state->getActiveTextureUnit();
+    GLenum hostActiveTexture = origActiveTexture;
+    GLint samplerIdx = -1;
+    GLint samplerVal;
+    GLenum samplerTarget;
+    while ((samplerIdx = shared->getNextSamplerUniform(program, samplerIdx, &samplerVal, &samplerTarget)) != -1) {
+        if (samplerVal < 0 || samplerVal >= GLClientState::MAX_TEXTURE_UNITS)
+            continue;
+        if (ctx->updateHostTexture2DBinding(GL_TEXTURE0 + samplerVal,
+                samplerTarget))
+        {
+            hostActiveTexture = GL_TEXTURE0 + samplerVal;
+        }
+    }
+    state->setActiveTextureUnit(origActiveTexture);
+    if (hostActiveTexture != origActiveTexture) {
+        ctx->m_glActiveTexture_enc(self, origActiveTexture);
+    }
+}
+
+void GL2Encoder::s_glUniform1f(void *self , GLint location, GLfloat x)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform1f_enc(self, hostLoc, x);
+}
+
+void GL2Encoder::s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform1fv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform1i(void *self , GLint location, GLint x)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLClientState* state = ctx->m_state;
+    GLSharedGroupPtr shared = ctx->m_shared;
+
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform1i_enc(self, hostLoc, x);
+
+    GLenum target;
+    if (shared->setSamplerUniform(state->currentProgram(), location, x, &target)) {
+        GLenum origActiveTexture = state->getActiveTextureUnit();
+        if (ctx->updateHostTexture2DBinding(GL_TEXTURE0 + x, target)) {
+            ctx->m_glActiveTexture_enc(self, origActiveTexture);
+        }
+        state->setActiveTextureUnit(origActiveTexture);
+    }
+}
+
+void GL2Encoder::s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform1iv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform2f_enc(self, hostLoc, x, y);
+}
+
+void GL2Encoder::s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform2fv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform2i(void *self , GLint location, GLint x, GLint y)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform2i_enc(self, hostLoc, x, y);
+}
+
+void GL2Encoder::s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform2iv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform3f_enc(self, hostLoc, x, y, z);
+}
+
+void GL2Encoder::s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform3fv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform3i_enc(self, hostLoc, x, y, z);
+}
+
+void GL2Encoder::s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform3iv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform4f_enc(self, hostLoc, x, y, z, w);
+}
+
+void GL2Encoder::s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform4fv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform4i_enc(self, hostLoc, x, y, z, w);
+}
+
+void GL2Encoder::s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniform4iv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniformMatrix2fv_enc(self, hostLoc, count, transpose, value);
+}
+
+void GL2Encoder::s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniformMatrix3fv_enc(self, hostLoc, count, transpose, value);
+}
+
+void GL2Encoder::s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+    ctx->m_glUniformMatrix4fv_enc(self, hostLoc, count, transpose, value);
+}
+
+void GL2Encoder::s_glActiveTexture(void* self, GLenum texture)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    GLClientState* state = ctx->m_state;
+    GLenum err;
+
+    SET_ERROR_IF((err = state->setActiveTextureUnit(texture)) != GL_NO_ERROR, err);
+
+    ctx->m_glActiveTexture_enc(ctx, texture);
+}
+
+void GL2Encoder::s_glBindTexture(void* self, GLenum target, GLuint texture)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    GLClientState* state = ctx->m_state;
+    GLenum err;
+    GLboolean firstUse;
+
+    SET_ERROR_IF((err = state->bindTexture(target, texture, &firstUse)) != GL_NO_ERROR, err);
+
+    if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
+        ctx->m_glBindTexture_enc(ctx, target, texture);
+        return;
+    }
+
+    GLenum priorityTarget = state->getPriorityEnabledTarget(GL_TEXTURE_2D);
+
+    if (target == GL_TEXTURE_EXTERNAL_OES && firstUse) {
+        ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture);
+        ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+                GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+                GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+                GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+        if (target != priorityTarget) {
+            ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D,
+                    state->getBoundTexture(GL_TEXTURE_2D));
+        }
+    }
+
+    if (target == priorityTarget) {
+        ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture);
+    }
+}
+
+void GL2Encoder::s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    GLClientState* state = ctx->m_state;
+
+    state->deleteTextures(n, textures);
+    ctx->m_glDeleteTextures_enc(ctx, n, textures);
+}
+
+void GL2Encoder::s_glGetTexParameterfv(void* self,
+        GLenum target, GLenum pname, GLfloat* params)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glGetTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glGetTexParameterfv_enc(ctx, target, pname, params);
+    }
+}
+
+void GL2Encoder::s_glGetTexParameteriv(void* self,
+        GLenum target, GLenum pname, GLint* params)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    switch (pname) {
+    case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
+        *params = 1;
+        break;
+
+    default:
+        if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+            ctx->override2DTextureTarget(target);
+            ctx->m_glGetTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params);
+            ctx->restore2DTextureTarget();
+        } else {
+            ctx->m_glGetTexParameteriv_enc(ctx, target, pname, params);
+        }
+        break;
+    }
+}
+
+static bool isValidTextureExternalParam(GLenum pname, GLenum param)
+{
+    switch (pname) {
+    case GL_TEXTURE_MIN_FILTER:
+    case GL_TEXTURE_MAG_FILTER:
+        return param == GL_NEAREST || param == GL_LINEAR;
+
+    case GL_TEXTURE_WRAP_S:
+    case GL_TEXTURE_WRAP_T:
+        return param == GL_CLAMP_TO_EDGE;
+
+    default:
+        return true;
+    }
+}
+
+void GL2Encoder::s_glTexParameterf(void* self,
+        GLenum target, GLenum pname, GLfloat param)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)param)),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameterf_enc(ctx, GL_TEXTURE_2D, pname, param);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameterf_enc(ctx, target, pname, param);
+    }
+}
+
+void GL2Encoder::s_glTexParameterfv(void* self,
+        GLenum target, GLenum pname, const GLfloat* params)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)params[0])),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameterfv_enc(ctx, target, pname, params);
+    }
+}
+
+void GL2Encoder::s_glTexParameteri(void* self,
+        GLenum target, GLenum pname, GLint param)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)param)),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, pname, param);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameteri_enc(ctx, target, pname, param);
+    }
+}
+
+void GL2Encoder::s_glTexParameteriv(void* self,
+        GLenum target, GLenum pname, const GLint* params)
+{
+    GL2Encoder* ctx = (GL2Encoder*)self;
+    const GLClientState* state = ctx->m_state;
+
+    SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+            !isValidTextureExternalParam(pname, (GLenum)params[0])),
+            GL_INVALID_ENUM);
+
+    if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+        ctx->override2DTextureTarget(target);
+        ctx->m_glTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params);
+        ctx->restore2DTextureTarget();
+    } else {
+        ctx->m_glTexParameteriv_enc(ctx, target, pname, params);
+    }
+}
+
+void GL2Encoder::override2DTextureTarget(GLenum target)
+{
+    if ((target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) &&
+        target != m_state->getPriorityEnabledTarget(GL_TEXTURE_2D)) {
+            m_glBindTexture_enc(this, GL_TEXTURE_2D,
+                    m_state->getBoundTexture(target));
+    }
+}
+
+void GL2Encoder::restore2DTextureTarget()
+{
+    GLenum priorityTarget = m_state->getPriorityEnabledTarget(GL_TEXTURE_2D);
+    m_glBindTexture_enc(this, GL_TEXTURE_2D,
+            m_state->getBoundTexture(priorityTarget));
+}
diff --git a/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.h b/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.h
new file mode 100644
index 0000000..f9235d7
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/GL2Encoder.h
@@ -0,0 +1,216 @@
+/*
+* 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 _GL2_ENCODER_H_
+#define _GL2_ENCODER_H_
+
+#include "gl2_enc.h"
+#include "GLClientState.h"
+#include "GLSharedGroup.h"
+#include "FixedBuffer.h"
+
+
+class GL2Encoder : public gl2_encoder_context_t {
+public:
+    GL2Encoder(IOStream *stream);
+    virtual ~GL2Encoder();
+    void setClientState(GLClientState *state) {
+        m_state = state;
+    }
+    void setSharedGroup(GLSharedGroupPtr shared){ m_shared = shared; }
+    const GLClientState *state() { return m_state; }
+    const GLSharedGroupPtr shared() { return m_shared; }
+    void flush() { m_stream->flush(); }
+
+    void setInitialized(){ m_initialized = true; };
+    bool isInitialized(){ return m_initialized; };
+
+    virtual void setError(GLenum error){ m_error = error; };
+    virtual GLenum getError() { return m_error; };
+
+    void override2DTextureTarget(GLenum target);
+    void restore2DTextureTarget();
+
+private:
+
+    bool    m_initialized;
+    GLClientState *m_state;
+    GLSharedGroupPtr m_shared;
+    GLenum  m_error;
+
+    GLint *m_compressedTextureFormats;
+    GLint m_num_compressedTextureFormats;
+    GLint *getCompressedTextureFormats();
+
+    FixedBuffer m_fixedBuffer;
+
+    void sendVertexAttributes(GLint first, GLsizei count);
+    bool updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget);
+
+    glGetError_client_proc_t    m_glGetError_enc;
+    static GLenum s_glGetError(void * self);
+
+    glFlush_client_proc_t m_glFlush_enc;
+    static void s_glFlush(void * self);
+
+    glPixelStorei_client_proc_t m_glPixelStorei_enc;
+    static void s_glPixelStorei(void *self, GLenum param, GLint value);
+
+    glGetString_client_proc_t m_glGetString_enc;
+    static const GLubyte * s_glGetString(void *self, GLenum name);
+
+    glBindBuffer_client_proc_t m_glBindBuffer_enc;
+    static void s_glBindBuffer(void *self, GLenum target, GLuint id);
+
+    
+    glBufferData_client_proc_t m_glBufferData_enc;
+    static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+    glBufferSubData_client_proc_t m_glBufferSubData_enc;
+    static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
+    glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
+    static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
+
+    glDrawArrays_client_proc_t m_glDrawArrays_enc;
+    static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
+
+    glDrawElements_client_proc_t m_glDrawElements_enc;
+    static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
+
+
+    glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
+    static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
+
+    glGetFloatv_client_proc_t m_glGetFloatv_enc;
+    static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
+
+    glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
+    static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
+
+    glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc;
+    static void s_glVertexAtrribPointer(void *self, GLuint indx, GLint size, GLenum type,
+                                        GLboolean normalized, GLsizei stride, const GLvoid * ptr);
+
+    glEnableVertexAttribArray_client_proc_t m_glEnableVertexAttribArray_enc;
+    static void s_glEnableVertexAttribArray(void *self, GLuint index);
+
+    glDisableVertexAttribArray_client_proc_t m_glDisableVertexAttribArray_enc;
+    static void s_glDisableVertexAttribArray(void *self, GLuint index);
+
+    glGetVertexAttribiv_client_proc_t m_glGetVertexAttribiv_enc;
+    static void s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params);
+
+    glGetVertexAttribfv_client_proc_t m_glGetVertexAttribfv_enc;
+    static void s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params);
+
+    glGetVertexAttribPointerv_client_proc_t m_glGetVertexAttribPointerv;
+    static void s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer);
+
+    static void s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
+
+    static void s_glFinish(void *self);
+
+    glLinkProgram_client_proc_t m_glLinkProgram_enc;
+    static void s_glLinkProgram(void *self, GLuint program);
+
+    glDeleteProgram_client_proc_t m_glDeleteProgram_enc;
+    static void s_glDeleteProgram(void * self, GLuint program);
+
+    glGetUniformiv_client_proc_t m_glGetUniformiv_enc;
+    static void s_glGetUniformiv(void *self, GLuint program, GLint location , GLint *params);
+
+    glGetUniformfv_client_proc_t m_glGetUniformfv_enc;
+    static void s_glGetUniformfv(void *self, GLuint program, GLint location , GLfloat *params);
+
+    glCreateProgram_client_proc_t m_glCreateProgram_enc;
+    static GLuint s_glCreateProgram(void *self);
+
+    glCreateShader_client_proc_t m_glCreateShader_enc;
+    static GLuint s_glCreateShader(void *self, GLenum shaderType);
+
+    glDeleteShader_client_proc_t m_glDeleteShader_enc;
+    static void s_glDeleteShader(void *self, GLuint shader);
+
+    glAttachShader_client_proc_t m_glAttachShader_enc;
+    static void s_glAttachShader(void *self, GLuint program, GLuint shader);
+
+    glDetachShader_client_proc_t m_glDetachShader_enc;
+    static void s_glDetachShader(void *self, GLuint program, GLuint shader);
+
+    glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc;
+    static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name);
+    glUseProgram_client_proc_t m_glUseProgram_enc;
+
+    glUniform1f_client_proc_t m_glUniform1f_enc;
+    glUniform1fv_client_proc_t m_glUniform1fv_enc;
+    glUniform1i_client_proc_t m_glUniform1i_enc;
+    glUniform1iv_client_proc_t m_glUniform1iv_enc;
+    glUniform2f_client_proc_t m_glUniform2f_enc;
+    glUniform2fv_client_proc_t m_glUniform2fv_enc;
+    glUniform2i_client_proc_t m_glUniform2i_enc;
+    glUniform2iv_client_proc_t m_glUniform2iv_enc;
+    glUniform3f_client_proc_t m_glUniform3f_enc;
+    glUniform3fv_client_proc_t m_glUniform3fv_enc;
+    glUniform3i_client_proc_t m_glUniform3i_enc;
+    glUniform3iv_client_proc_t m_glUniform3iv_enc;
+    glUniform4f_client_proc_t m_glUniform4f_enc;
+    glUniform4fv_client_proc_t m_glUniform4fv_enc;
+    glUniform4i_client_proc_t m_glUniform4i_enc;
+    glUniform4iv_client_proc_t m_glUniform4iv_enc;
+    glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc;
+    glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc;
+    glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc;
+
+    static void s_glUseProgram(void *self, GLuint program);
+	static void s_glUniform1f(void *self , GLint location, GLfloat x);
+	static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v);
+	static void s_glUniform1i(void *self , GLint location, GLint x);
+	static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v);
+	static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y);
+	static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v);
+	static void s_glUniform2i(void *self , GLint location, GLint x, GLint y);
+	static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v);
+	static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z);
+	static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v);
+	static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z);
+	static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v);
+	static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+	static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v);
+	static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w);
+	static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v);
+	static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+	static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+	static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+
+    glActiveTexture_client_proc_t m_glActiveTexture_enc;
+    glBindTexture_client_proc_t m_glBindTexture_enc;
+    glDeleteTextures_client_proc_t m_glDeleteTextures_enc;
+    glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc;
+    glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc;
+    glTexParameterf_client_proc_t m_glTexParameterf_enc;
+    glTexParameterfv_client_proc_t m_glTexParameterfv_enc;
+    glTexParameteri_client_proc_t m_glTexParameteri_enc;
+    glTexParameteriv_client_proc_t m_glTexParameteriv_enc;
+
+    static void s_glActiveTexture(void* self, GLenum texture);
+    static void s_glBindTexture(void* self, GLenum target, GLuint texture);
+    static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures);
+    static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params);
+    static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
+    static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param);
+    static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params);
+    static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param);
+    static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params);
+};
+#endif
diff --git a/tools/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp b/tools/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp
new file mode 100644
index 0000000..57d65c0
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.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 <stdio.h>
+#include <stdlib.h>
+#include "GL2Encoder.h"
+#include <assert.h>
+
+size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack)
+{
+    GL2Encoder *ctx = (GL2Encoder *)self;
+    assert (ctx->state() != NULL);
+    return ctx->state()->pixelDataSize(width, height, format, type, pack);
+}
+
+size_t pixelDataSize3D(void *self, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack)
+{
+    size_t layerSize = pixelDataSize(self, width, height, format, type, pack);
+    return layerSize * depth;
+}
+
+GLenum uniformType(void * self, GLuint program, GLint location)
+{
+    GL2Encoder * ctx = (GL2Encoder *) self;
+    assert (ctx->shared() != NULL);
+    return ctx->shared()->getProgramUniformType(program, location);
+}
diff --git a/tools/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.h b/tools/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.h
new file mode 100644
index 0000000..8e91aeb
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.h
@@ -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.
+*/
+#ifndef GL2_ENCODER_UTILS_H
+#define GL2_ENCLODER_UTILS_H
+
+extern "C" {
+    size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack);
+    size_t pixelDataSize3D(void *self, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack);
+    GLenum uniformType(void * self, GLuint program, GLint location);
+};
+#endif
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_client_context.cpp b/tools/emulator/opengl/system/GLESv2_enc/gl2_client_context.cpp
new file mode 100644
index 0000000..e4e08b2
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_client_context.cpp
@@ -0,0 +1,225 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "gl2_client_context.h"
+
+
+#include <stdio.h>
+
+int gl2_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+	void *ptr;
+
+	ptr = getProc("glActiveTexture", userData); set_glActiveTexture((glActiveTexture_client_proc_t)ptr);
+	ptr = getProc("glAttachShader", userData); set_glAttachShader((glAttachShader_client_proc_t)ptr);
+	ptr = getProc("glBindAttribLocation", userData); set_glBindAttribLocation((glBindAttribLocation_client_proc_t)ptr);
+	ptr = getProc("glBindBuffer", userData); set_glBindBuffer((glBindBuffer_client_proc_t)ptr);
+	ptr = getProc("glBindFramebuffer", userData); set_glBindFramebuffer((glBindFramebuffer_client_proc_t)ptr);
+	ptr = getProc("glBindRenderbuffer", userData); set_glBindRenderbuffer((glBindRenderbuffer_client_proc_t)ptr);
+	ptr = getProc("glBindTexture", userData); set_glBindTexture((glBindTexture_client_proc_t)ptr);
+	ptr = getProc("glBlendColor", userData); set_glBlendColor((glBlendColor_client_proc_t)ptr);
+	ptr = getProc("glBlendEquation", userData); set_glBlendEquation((glBlendEquation_client_proc_t)ptr);
+	ptr = getProc("glBlendEquationSeparate", userData); set_glBlendEquationSeparate((glBlendEquationSeparate_client_proc_t)ptr);
+	ptr = getProc("glBlendFunc", userData); set_glBlendFunc((glBlendFunc_client_proc_t)ptr);
+	ptr = getProc("glBlendFuncSeparate", userData); set_glBlendFuncSeparate((glBlendFuncSeparate_client_proc_t)ptr);
+	ptr = getProc("glBufferData", userData); set_glBufferData((glBufferData_client_proc_t)ptr);
+	ptr = getProc("glBufferSubData", userData); set_glBufferSubData((glBufferSubData_client_proc_t)ptr);
+	ptr = getProc("glCheckFramebufferStatus", userData); set_glCheckFramebufferStatus((glCheckFramebufferStatus_client_proc_t)ptr);
+	ptr = getProc("glClear", userData); set_glClear((glClear_client_proc_t)ptr);
+	ptr = getProc("glClearColor", userData); set_glClearColor((glClearColor_client_proc_t)ptr);
+	ptr = getProc("glClearDepthf", userData); set_glClearDepthf((glClearDepthf_client_proc_t)ptr);
+	ptr = getProc("glClearStencil", userData); set_glClearStencil((glClearStencil_client_proc_t)ptr);
+	ptr = getProc("glColorMask", userData); set_glColorMask((glColorMask_client_proc_t)ptr);
+	ptr = getProc("glCompileShader", userData); set_glCompileShader((glCompileShader_client_proc_t)ptr);
+	ptr = getProc("glCompressedTexImage2D", userData); set_glCompressedTexImage2D((glCompressedTexImage2D_client_proc_t)ptr);
+	ptr = getProc("glCompressedTexSubImage2D", userData); set_glCompressedTexSubImage2D((glCompressedTexSubImage2D_client_proc_t)ptr);
+	ptr = getProc("glCopyTexImage2D", userData); set_glCopyTexImage2D((glCopyTexImage2D_client_proc_t)ptr);
+	ptr = getProc("glCopyTexSubImage2D", userData); set_glCopyTexSubImage2D((glCopyTexSubImage2D_client_proc_t)ptr);
+	ptr = getProc("glCreateProgram", userData); set_glCreateProgram((glCreateProgram_client_proc_t)ptr);
+	ptr = getProc("glCreateShader", userData); set_glCreateShader((glCreateShader_client_proc_t)ptr);
+	ptr = getProc("glCullFace", userData); set_glCullFace((glCullFace_client_proc_t)ptr);
+	ptr = getProc("glDeleteBuffers", userData); set_glDeleteBuffers((glDeleteBuffers_client_proc_t)ptr);
+	ptr = getProc("glDeleteFramebuffers", userData); set_glDeleteFramebuffers((glDeleteFramebuffers_client_proc_t)ptr);
+	ptr = getProc("glDeleteProgram", userData); set_glDeleteProgram((glDeleteProgram_client_proc_t)ptr);
+	ptr = getProc("glDeleteRenderbuffers", userData); set_glDeleteRenderbuffers((glDeleteRenderbuffers_client_proc_t)ptr);
+	ptr = getProc("glDeleteShader", userData); set_glDeleteShader((glDeleteShader_client_proc_t)ptr);
+	ptr = getProc("glDeleteTextures", userData); set_glDeleteTextures((glDeleteTextures_client_proc_t)ptr);
+	ptr = getProc("glDepthFunc", userData); set_glDepthFunc((glDepthFunc_client_proc_t)ptr);
+	ptr = getProc("glDepthMask", userData); set_glDepthMask((glDepthMask_client_proc_t)ptr);
+	ptr = getProc("glDepthRangef", userData); set_glDepthRangef((glDepthRangef_client_proc_t)ptr);
+	ptr = getProc("glDetachShader", userData); set_glDetachShader((glDetachShader_client_proc_t)ptr);
+	ptr = getProc("glDisable", userData); set_glDisable((glDisable_client_proc_t)ptr);
+	ptr = getProc("glDisableVertexAttribArray", userData); set_glDisableVertexAttribArray((glDisableVertexAttribArray_client_proc_t)ptr);
+	ptr = getProc("glDrawArrays", userData); set_glDrawArrays((glDrawArrays_client_proc_t)ptr);
+	ptr = getProc("glDrawElements", userData); set_glDrawElements((glDrawElements_client_proc_t)ptr);
+	ptr = getProc("glEnable", userData); set_glEnable((glEnable_client_proc_t)ptr);
+	ptr = getProc("glEnableVertexAttribArray", userData); set_glEnableVertexAttribArray((glEnableVertexAttribArray_client_proc_t)ptr);
+	ptr = getProc("glFinish", userData); set_glFinish((glFinish_client_proc_t)ptr);
+	ptr = getProc("glFlush", userData); set_glFlush((glFlush_client_proc_t)ptr);
+	ptr = getProc("glFramebufferRenderbuffer", userData); set_glFramebufferRenderbuffer((glFramebufferRenderbuffer_client_proc_t)ptr);
+	ptr = getProc("glFramebufferTexture2D", userData); set_glFramebufferTexture2D((glFramebufferTexture2D_client_proc_t)ptr);
+	ptr = getProc("glFrontFace", userData); set_glFrontFace((glFrontFace_client_proc_t)ptr);
+	ptr = getProc("glGenBuffers", userData); set_glGenBuffers((glGenBuffers_client_proc_t)ptr);
+	ptr = getProc("glGenerateMipmap", userData); set_glGenerateMipmap((glGenerateMipmap_client_proc_t)ptr);
+	ptr = getProc("glGenFramebuffers", userData); set_glGenFramebuffers((glGenFramebuffers_client_proc_t)ptr);
+	ptr = getProc("glGenRenderbuffers", userData); set_glGenRenderbuffers((glGenRenderbuffers_client_proc_t)ptr);
+	ptr = getProc("glGenTextures", userData); set_glGenTextures((glGenTextures_client_proc_t)ptr);
+	ptr = getProc("glGetActiveAttrib", userData); set_glGetActiveAttrib((glGetActiveAttrib_client_proc_t)ptr);
+	ptr = getProc("glGetActiveUniform", userData); set_glGetActiveUniform((glGetActiveUniform_client_proc_t)ptr);
+	ptr = getProc("glGetAttachedShaders", userData); set_glGetAttachedShaders((glGetAttachedShaders_client_proc_t)ptr);
+	ptr = getProc("glGetAttribLocation", userData); set_glGetAttribLocation((glGetAttribLocation_client_proc_t)ptr);
+	ptr = getProc("glGetBooleanv", userData); set_glGetBooleanv((glGetBooleanv_client_proc_t)ptr);
+	ptr = getProc("glGetBufferParameteriv", userData); set_glGetBufferParameteriv((glGetBufferParameteriv_client_proc_t)ptr);
+	ptr = getProc("glGetError", userData); set_glGetError((glGetError_client_proc_t)ptr);
+	ptr = getProc("glGetFloatv", userData); set_glGetFloatv((glGetFloatv_client_proc_t)ptr);
+	ptr = getProc("glGetFramebufferAttachmentParameteriv", userData); set_glGetFramebufferAttachmentParameteriv((glGetFramebufferAttachmentParameteriv_client_proc_t)ptr);
+	ptr = getProc("glGetIntegerv", userData); set_glGetIntegerv((glGetIntegerv_client_proc_t)ptr);
+	ptr = getProc("glGetProgramiv", userData); set_glGetProgramiv((glGetProgramiv_client_proc_t)ptr);
+	ptr = getProc("glGetProgramInfoLog", userData); set_glGetProgramInfoLog((glGetProgramInfoLog_client_proc_t)ptr);
+	ptr = getProc("glGetRenderbufferParameteriv", userData); set_glGetRenderbufferParameteriv((glGetRenderbufferParameteriv_client_proc_t)ptr);
+	ptr = getProc("glGetShaderiv", userData); set_glGetShaderiv((glGetShaderiv_client_proc_t)ptr);
+	ptr = getProc("glGetShaderInfoLog", userData); set_glGetShaderInfoLog((glGetShaderInfoLog_client_proc_t)ptr);
+	ptr = getProc("glGetShaderPrecisionFormat", userData); set_glGetShaderPrecisionFormat((glGetShaderPrecisionFormat_client_proc_t)ptr);
+	ptr = getProc("glGetShaderSource", userData); set_glGetShaderSource((glGetShaderSource_client_proc_t)ptr);
+	ptr = getProc("glGetString", userData); set_glGetString((glGetString_client_proc_t)ptr);
+	ptr = getProc("glGetTexParameterfv", userData); set_glGetTexParameterfv((glGetTexParameterfv_client_proc_t)ptr);
+	ptr = getProc("glGetTexParameteriv", userData); set_glGetTexParameteriv((glGetTexParameteriv_client_proc_t)ptr);
+	ptr = getProc("glGetUniformfv", userData); set_glGetUniformfv((glGetUniformfv_client_proc_t)ptr);
+	ptr = getProc("glGetUniformiv", userData); set_glGetUniformiv((glGetUniformiv_client_proc_t)ptr);
+	ptr = getProc("glGetUniformLocation", userData); set_glGetUniformLocation((glGetUniformLocation_client_proc_t)ptr);
+	ptr = getProc("glGetVertexAttribfv", userData); set_glGetVertexAttribfv((glGetVertexAttribfv_client_proc_t)ptr);
+	ptr = getProc("glGetVertexAttribiv", userData); set_glGetVertexAttribiv((glGetVertexAttribiv_client_proc_t)ptr);
+	ptr = getProc("glGetVertexAttribPointerv", userData); set_glGetVertexAttribPointerv((glGetVertexAttribPointerv_client_proc_t)ptr);
+	ptr = getProc("glHint", userData); set_glHint((glHint_client_proc_t)ptr);
+	ptr = getProc("glIsBuffer", userData); set_glIsBuffer((glIsBuffer_client_proc_t)ptr);
+	ptr = getProc("glIsEnabled", userData); set_glIsEnabled((glIsEnabled_client_proc_t)ptr);
+	ptr = getProc("glIsFramebuffer", userData); set_glIsFramebuffer((glIsFramebuffer_client_proc_t)ptr);
+	ptr = getProc("glIsProgram", userData); set_glIsProgram((glIsProgram_client_proc_t)ptr);
+	ptr = getProc("glIsRenderbuffer", userData); set_glIsRenderbuffer((glIsRenderbuffer_client_proc_t)ptr);
+	ptr = getProc("glIsShader", userData); set_glIsShader((glIsShader_client_proc_t)ptr);
+	ptr = getProc("glIsTexture", userData); set_glIsTexture((glIsTexture_client_proc_t)ptr);
+	ptr = getProc("glLineWidth", userData); set_glLineWidth((glLineWidth_client_proc_t)ptr);
+	ptr = getProc("glLinkProgram", userData); set_glLinkProgram((glLinkProgram_client_proc_t)ptr);
+	ptr = getProc("glPixelStorei", userData); set_glPixelStorei((glPixelStorei_client_proc_t)ptr);
+	ptr = getProc("glPolygonOffset", userData); set_glPolygonOffset((glPolygonOffset_client_proc_t)ptr);
+	ptr = getProc("glReadPixels", userData); set_glReadPixels((glReadPixels_client_proc_t)ptr);
+	ptr = getProc("glReleaseShaderCompiler", userData); set_glReleaseShaderCompiler((glReleaseShaderCompiler_client_proc_t)ptr);
+	ptr = getProc("glRenderbufferStorage", userData); set_glRenderbufferStorage((glRenderbufferStorage_client_proc_t)ptr);
+	ptr = getProc("glSampleCoverage", userData); set_glSampleCoverage((glSampleCoverage_client_proc_t)ptr);
+	ptr = getProc("glScissor", userData); set_glScissor((glScissor_client_proc_t)ptr);
+	ptr = getProc("glShaderBinary", userData); set_glShaderBinary((glShaderBinary_client_proc_t)ptr);
+	ptr = getProc("glShaderSource", userData); set_glShaderSource((glShaderSource_client_proc_t)ptr);
+	ptr = getProc("glStencilFunc", userData); set_glStencilFunc((glStencilFunc_client_proc_t)ptr);
+	ptr = getProc("glStencilFuncSeparate", userData); set_glStencilFuncSeparate((glStencilFuncSeparate_client_proc_t)ptr);
+	ptr = getProc("glStencilMask", userData); set_glStencilMask((glStencilMask_client_proc_t)ptr);
+	ptr = getProc("glStencilMaskSeparate", userData); set_glStencilMaskSeparate((glStencilMaskSeparate_client_proc_t)ptr);
+	ptr = getProc("glStencilOp", userData); set_glStencilOp((glStencilOp_client_proc_t)ptr);
+	ptr = getProc("glStencilOpSeparate", userData); set_glStencilOpSeparate((glStencilOpSeparate_client_proc_t)ptr);
+	ptr = getProc("glTexImage2D", userData); set_glTexImage2D((glTexImage2D_client_proc_t)ptr);
+	ptr = getProc("glTexParameterf", userData); set_glTexParameterf((glTexParameterf_client_proc_t)ptr);
+	ptr = getProc("glTexParameterfv", userData); set_glTexParameterfv((glTexParameterfv_client_proc_t)ptr);
+	ptr = getProc("glTexParameteri", userData); set_glTexParameteri((glTexParameteri_client_proc_t)ptr);
+	ptr = getProc("glTexParameteriv", userData); set_glTexParameteriv((glTexParameteriv_client_proc_t)ptr);
+	ptr = getProc("glTexSubImage2D", userData); set_glTexSubImage2D((glTexSubImage2D_client_proc_t)ptr);
+	ptr = getProc("glUniform1f", userData); set_glUniform1f((glUniform1f_client_proc_t)ptr);
+	ptr = getProc("glUniform1fv", userData); set_glUniform1fv((glUniform1fv_client_proc_t)ptr);
+	ptr = getProc("glUniform1i", userData); set_glUniform1i((glUniform1i_client_proc_t)ptr);
+	ptr = getProc("glUniform1iv", userData); set_glUniform1iv((glUniform1iv_client_proc_t)ptr);
+	ptr = getProc("glUniform2f", userData); set_glUniform2f((glUniform2f_client_proc_t)ptr);
+	ptr = getProc("glUniform2fv", userData); set_glUniform2fv((glUniform2fv_client_proc_t)ptr);
+	ptr = getProc("glUniform2i", userData); set_glUniform2i((glUniform2i_client_proc_t)ptr);
+	ptr = getProc("glUniform2iv", userData); set_glUniform2iv((glUniform2iv_client_proc_t)ptr);
+	ptr = getProc("glUniform3f", userData); set_glUniform3f((glUniform3f_client_proc_t)ptr);
+	ptr = getProc("glUniform3fv", userData); set_glUniform3fv((glUniform3fv_client_proc_t)ptr);
+	ptr = getProc("glUniform3i", userData); set_glUniform3i((glUniform3i_client_proc_t)ptr);
+	ptr = getProc("glUniform3iv", userData); set_glUniform3iv((glUniform3iv_client_proc_t)ptr);
+	ptr = getProc("glUniform4f", userData); set_glUniform4f((glUniform4f_client_proc_t)ptr);
+	ptr = getProc("glUniform4fv", userData); set_glUniform4fv((glUniform4fv_client_proc_t)ptr);
+	ptr = getProc("glUniform4i", userData); set_glUniform4i((glUniform4i_client_proc_t)ptr);
+	ptr = getProc("glUniform4iv", userData); set_glUniform4iv((glUniform4iv_client_proc_t)ptr);
+	ptr = getProc("glUniformMatrix2fv", userData); set_glUniformMatrix2fv((glUniformMatrix2fv_client_proc_t)ptr);
+	ptr = getProc("glUniformMatrix3fv", userData); set_glUniformMatrix3fv((glUniformMatrix3fv_client_proc_t)ptr);
+	ptr = getProc("glUniformMatrix4fv", userData); set_glUniformMatrix4fv((glUniformMatrix4fv_client_proc_t)ptr);
+	ptr = getProc("glUseProgram", userData); set_glUseProgram((glUseProgram_client_proc_t)ptr);
+	ptr = getProc("glValidateProgram", userData); set_glValidateProgram((glValidateProgram_client_proc_t)ptr);
+	ptr = getProc("glVertexAttrib1f", userData); set_glVertexAttrib1f((glVertexAttrib1f_client_proc_t)ptr);
+	ptr = getProc("glVertexAttrib1fv", userData); set_glVertexAttrib1fv((glVertexAttrib1fv_client_proc_t)ptr);
+	ptr = getProc("glVertexAttrib2f", userData); set_glVertexAttrib2f((glVertexAttrib2f_client_proc_t)ptr);
+	ptr = getProc("glVertexAttrib2fv", userData); set_glVertexAttrib2fv((glVertexAttrib2fv_client_proc_t)ptr);
+	ptr = getProc("glVertexAttrib3f", userData); set_glVertexAttrib3f((glVertexAttrib3f_client_proc_t)ptr);
+	ptr = getProc("glVertexAttrib3fv", userData); set_glVertexAttrib3fv((glVertexAttrib3fv_client_proc_t)ptr);
+	ptr = getProc("glVertexAttrib4f", userData); set_glVertexAttrib4f((glVertexAttrib4f_client_proc_t)ptr);
+	ptr = getProc("glVertexAttrib4fv", userData); set_glVertexAttrib4fv((glVertexAttrib4fv_client_proc_t)ptr);
+	ptr = getProc("glVertexAttribPointer", userData); set_glVertexAttribPointer((glVertexAttribPointer_client_proc_t)ptr);
+	ptr = getProc("glViewport", userData); set_glViewport((glViewport_client_proc_t)ptr);
+	ptr = getProc("glEGLImageTargetTexture2DOES", userData); set_glEGLImageTargetTexture2DOES((glEGLImageTargetTexture2DOES_client_proc_t)ptr);
+	ptr = getProc("glEGLImageTargetRenderbufferStorageOES", userData); set_glEGLImageTargetRenderbufferStorageOES((glEGLImageTargetRenderbufferStorageOES_client_proc_t)ptr);
+	ptr = getProc("glGetProgramBinaryOES", userData); set_glGetProgramBinaryOES((glGetProgramBinaryOES_client_proc_t)ptr);
+	ptr = getProc("glProgramBinaryOES", userData); set_glProgramBinaryOES((glProgramBinaryOES_client_proc_t)ptr);
+	ptr = getProc("glMapBufferOES", userData); set_glMapBufferOES((glMapBufferOES_client_proc_t)ptr);
+	ptr = getProc("glUnmapBufferOES", userData); set_glUnmapBufferOES((glUnmapBufferOES_client_proc_t)ptr);
+	ptr = getProc("glTexImage3DOES", userData); set_glTexImage3DOES((glTexImage3DOES_client_proc_t)ptr);
+	ptr = getProc("glTexSubImage3DOES", userData); set_glTexSubImage3DOES((glTexSubImage3DOES_client_proc_t)ptr);
+	ptr = getProc("glCopyTexSubImage3DOES", userData); set_glCopyTexSubImage3DOES((glCopyTexSubImage3DOES_client_proc_t)ptr);
+	ptr = getProc("glCompressedTexImage3DOES", userData); set_glCompressedTexImage3DOES((glCompressedTexImage3DOES_client_proc_t)ptr);
+	ptr = getProc("glCompressedTexSubImage3DOES", userData); set_glCompressedTexSubImage3DOES((glCompressedTexSubImage3DOES_client_proc_t)ptr);
+	ptr = getProc("glFramebufferTexture3DOES", userData); set_glFramebufferTexture3DOES((glFramebufferTexture3DOES_client_proc_t)ptr);
+	ptr = getProc("glBindVertexArrayOES", userData); set_glBindVertexArrayOES((glBindVertexArrayOES_client_proc_t)ptr);
+	ptr = getProc("glDeleteVertexArraysOES", userData); set_glDeleteVertexArraysOES((glDeleteVertexArraysOES_client_proc_t)ptr);
+	ptr = getProc("glGenVertexArraysOES", userData); set_glGenVertexArraysOES((glGenVertexArraysOES_client_proc_t)ptr);
+	ptr = getProc("glIsVertexArrayOES", userData); set_glIsVertexArrayOES((glIsVertexArrayOES_client_proc_t)ptr);
+	ptr = getProc("glDiscardFramebufferEXT", userData); set_glDiscardFramebufferEXT((glDiscardFramebufferEXT_client_proc_t)ptr);
+	ptr = getProc("glMultiDrawArraysEXT", userData); set_glMultiDrawArraysEXT((glMultiDrawArraysEXT_client_proc_t)ptr);
+	ptr = getProc("glMultiDrawElementsEXT", userData); set_glMultiDrawElementsEXT((glMultiDrawElementsEXT_client_proc_t)ptr);
+	ptr = getProc("glGetPerfMonitorGroupsAMD", userData); set_glGetPerfMonitorGroupsAMD((glGetPerfMonitorGroupsAMD_client_proc_t)ptr);
+	ptr = getProc("glGetPerfMonitorCountersAMD", userData); set_glGetPerfMonitorCountersAMD((glGetPerfMonitorCountersAMD_client_proc_t)ptr);
+	ptr = getProc("glGetPerfMonitorGroupStringAMD", userData); set_glGetPerfMonitorGroupStringAMD((glGetPerfMonitorGroupStringAMD_client_proc_t)ptr);
+	ptr = getProc("glGetPerfMonitorCounterStringAMD", userData); set_glGetPerfMonitorCounterStringAMD((glGetPerfMonitorCounterStringAMD_client_proc_t)ptr);
+	ptr = getProc("glGetPerfMonitorCounterInfoAMD", userData); set_glGetPerfMonitorCounterInfoAMD((glGetPerfMonitorCounterInfoAMD_client_proc_t)ptr);
+	ptr = getProc("glGenPerfMonitorsAMD", userData); set_glGenPerfMonitorsAMD((glGenPerfMonitorsAMD_client_proc_t)ptr);
+	ptr = getProc("glDeletePerfMonitorsAMD", userData); set_glDeletePerfMonitorsAMD((glDeletePerfMonitorsAMD_client_proc_t)ptr);
+	ptr = getProc("glSelectPerfMonitorCountersAMD", userData); set_glSelectPerfMonitorCountersAMD((glSelectPerfMonitorCountersAMD_client_proc_t)ptr);
+	ptr = getProc("glBeginPerfMonitorAMD", userData); set_glBeginPerfMonitorAMD((glBeginPerfMonitorAMD_client_proc_t)ptr);
+	ptr = getProc("glEndPerfMonitorAMD", userData); set_glEndPerfMonitorAMD((glEndPerfMonitorAMD_client_proc_t)ptr);
+	ptr = getProc("glGetPerfMonitorCounterDataAMD", userData); set_glGetPerfMonitorCounterDataAMD((glGetPerfMonitorCounterDataAMD_client_proc_t)ptr);
+	ptr = getProc("glRenderbufferStorageMultisampleIMG", userData); set_glRenderbufferStorageMultisampleIMG((glRenderbufferStorageMultisampleIMG_client_proc_t)ptr);
+	ptr = getProc("glFramebufferTexture2DMultisampleIMG", userData); set_glFramebufferTexture2DMultisampleIMG((glFramebufferTexture2DMultisampleIMG_client_proc_t)ptr);
+	ptr = getProc("glDeleteFencesNV", userData); set_glDeleteFencesNV((glDeleteFencesNV_client_proc_t)ptr);
+	ptr = getProc("glGenFencesNV", userData); set_glGenFencesNV((glGenFencesNV_client_proc_t)ptr);
+	ptr = getProc("glIsFenceNV", userData); set_glIsFenceNV((glIsFenceNV_client_proc_t)ptr);
+	ptr = getProc("glTestFenceNV", userData); set_glTestFenceNV((glTestFenceNV_client_proc_t)ptr);
+	ptr = getProc("glGetFenceivNV", userData); set_glGetFenceivNV((glGetFenceivNV_client_proc_t)ptr);
+	ptr = getProc("glFinishFenceNV", userData); set_glFinishFenceNV((glFinishFenceNV_client_proc_t)ptr);
+	ptr = getProc("glSetFenceNV", userData); set_glSetFenceNV((glSetFenceNV_client_proc_t)ptr);
+	ptr = getProc("glCoverageMaskNV", userData); set_glCoverageMaskNV((glCoverageMaskNV_client_proc_t)ptr);
+	ptr = getProc("glCoverageOperationNV", userData); set_glCoverageOperationNV((glCoverageOperationNV_client_proc_t)ptr);
+	ptr = getProc("glGetDriverControlsQCOM", userData); set_glGetDriverControlsQCOM((glGetDriverControlsQCOM_client_proc_t)ptr);
+	ptr = getProc("glGetDriverControlStringQCOM", userData); set_glGetDriverControlStringQCOM((glGetDriverControlStringQCOM_client_proc_t)ptr);
+	ptr = getProc("glEnableDriverControlQCOM", userData); set_glEnableDriverControlQCOM((glEnableDriverControlQCOM_client_proc_t)ptr);
+	ptr = getProc("glDisableDriverControlQCOM", userData); set_glDisableDriverControlQCOM((glDisableDriverControlQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetTexturesQCOM", userData); set_glExtGetTexturesQCOM((glExtGetTexturesQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetBuffersQCOM", userData); set_glExtGetBuffersQCOM((glExtGetBuffersQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetRenderbuffersQCOM", userData); set_glExtGetRenderbuffersQCOM((glExtGetRenderbuffersQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetFramebuffersQCOM", userData); set_glExtGetFramebuffersQCOM((glExtGetFramebuffersQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetTexLevelParameterivQCOM", userData); set_glExtGetTexLevelParameterivQCOM((glExtGetTexLevelParameterivQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtTexObjectStateOverrideiQCOM", userData); set_glExtTexObjectStateOverrideiQCOM((glExtTexObjectStateOverrideiQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetTexSubImageQCOM", userData); set_glExtGetTexSubImageQCOM((glExtGetTexSubImageQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetBufferPointervQCOM", userData); set_glExtGetBufferPointervQCOM((glExtGetBufferPointervQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetShadersQCOM", userData); set_glExtGetShadersQCOM((glExtGetShadersQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetProgramsQCOM", userData); set_glExtGetProgramsQCOM((glExtGetProgramsQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtIsProgramBinaryQCOM", userData); set_glExtIsProgramBinaryQCOM((glExtIsProgramBinaryQCOM_client_proc_t)ptr);
+	ptr = getProc("glExtGetProgramBinarySourceQCOM", userData); set_glExtGetProgramBinarySourceQCOM((glExtGetProgramBinarySourceQCOM_client_proc_t)ptr);
+	ptr = getProc("glStartTilingQCOM", userData); set_glStartTilingQCOM((glStartTilingQCOM_client_proc_t)ptr);
+	ptr = getProc("glEndTilingQCOM", userData); set_glEndTilingQCOM((glEndTilingQCOM_client_proc_t)ptr);
+	ptr = getProc("glVertexAttribPointerData", userData); set_glVertexAttribPointerData((glVertexAttribPointerData_client_proc_t)ptr);
+	ptr = getProc("glVertexAttribPointerOffset", userData); set_glVertexAttribPointerOffset((glVertexAttribPointerOffset_client_proc_t)ptr);
+	ptr = getProc("glDrawElementsOffset", userData); set_glDrawElementsOffset((glDrawElementsOffset_client_proc_t)ptr);
+	ptr = getProc("glDrawElementsData", userData); set_glDrawElementsData((glDrawElementsData_client_proc_t)ptr);
+	ptr = getProc("glGetCompressedTextureFormats", userData); set_glGetCompressedTextureFormats((glGetCompressedTextureFormats_client_proc_t)ptr);
+	ptr = getProc("glShaderString", userData); set_glShaderString((glShaderString_client_proc_t)ptr);
+	ptr = getProc("glFinishRoundTrip", userData); set_glFinishRoundTrip((glFinishRoundTrip_client_proc_t)ptr);
+	return 0;
+}
+
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_client_context.h b/tools/emulator/opengl/system/GLESv2_enc/gl2_client_context.h
new file mode 100644
index 0000000..7f0abcd
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_client_context.h
@@ -0,0 +1,437 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __gl2_client_context_t_h
+#define __gl2_client_context_t_h
+
+#include "gl2_client_proc.h"
+
+
+struct gl2_client_context_t {
+
+	glActiveTexture_client_proc_t glActiveTexture;
+	glAttachShader_client_proc_t glAttachShader;
+	glBindAttribLocation_client_proc_t glBindAttribLocation;
+	glBindBuffer_client_proc_t glBindBuffer;
+	glBindFramebuffer_client_proc_t glBindFramebuffer;
+	glBindRenderbuffer_client_proc_t glBindRenderbuffer;
+	glBindTexture_client_proc_t glBindTexture;
+	glBlendColor_client_proc_t glBlendColor;
+	glBlendEquation_client_proc_t glBlendEquation;
+	glBlendEquationSeparate_client_proc_t glBlendEquationSeparate;
+	glBlendFunc_client_proc_t glBlendFunc;
+	glBlendFuncSeparate_client_proc_t glBlendFuncSeparate;
+	glBufferData_client_proc_t glBufferData;
+	glBufferSubData_client_proc_t glBufferSubData;
+	glCheckFramebufferStatus_client_proc_t glCheckFramebufferStatus;
+	glClear_client_proc_t glClear;
+	glClearColor_client_proc_t glClearColor;
+	glClearDepthf_client_proc_t glClearDepthf;
+	glClearStencil_client_proc_t glClearStencil;
+	glColorMask_client_proc_t glColorMask;
+	glCompileShader_client_proc_t glCompileShader;
+	glCompressedTexImage2D_client_proc_t glCompressedTexImage2D;
+	glCompressedTexSubImage2D_client_proc_t glCompressedTexSubImage2D;
+	glCopyTexImage2D_client_proc_t glCopyTexImage2D;
+	glCopyTexSubImage2D_client_proc_t glCopyTexSubImage2D;
+	glCreateProgram_client_proc_t glCreateProgram;
+	glCreateShader_client_proc_t glCreateShader;
+	glCullFace_client_proc_t glCullFace;
+	glDeleteBuffers_client_proc_t glDeleteBuffers;
+	glDeleteFramebuffers_client_proc_t glDeleteFramebuffers;
+	glDeleteProgram_client_proc_t glDeleteProgram;
+	glDeleteRenderbuffers_client_proc_t glDeleteRenderbuffers;
+	glDeleteShader_client_proc_t glDeleteShader;
+	glDeleteTextures_client_proc_t glDeleteTextures;
+	glDepthFunc_client_proc_t glDepthFunc;
+	glDepthMask_client_proc_t glDepthMask;
+	glDepthRangef_client_proc_t glDepthRangef;
+	glDetachShader_client_proc_t glDetachShader;
+	glDisable_client_proc_t glDisable;
+	glDisableVertexAttribArray_client_proc_t glDisableVertexAttribArray;
+	glDrawArrays_client_proc_t glDrawArrays;
+	glDrawElements_client_proc_t glDrawElements;
+	glEnable_client_proc_t glEnable;
+	glEnableVertexAttribArray_client_proc_t glEnableVertexAttribArray;
+	glFinish_client_proc_t glFinish;
+	glFlush_client_proc_t glFlush;
+	glFramebufferRenderbuffer_client_proc_t glFramebufferRenderbuffer;
+	glFramebufferTexture2D_client_proc_t glFramebufferTexture2D;
+	glFrontFace_client_proc_t glFrontFace;
+	glGenBuffers_client_proc_t glGenBuffers;
+	glGenerateMipmap_client_proc_t glGenerateMipmap;
+	glGenFramebuffers_client_proc_t glGenFramebuffers;
+	glGenRenderbuffers_client_proc_t glGenRenderbuffers;
+	glGenTextures_client_proc_t glGenTextures;
+	glGetActiveAttrib_client_proc_t glGetActiveAttrib;
+	glGetActiveUniform_client_proc_t glGetActiveUniform;
+	glGetAttachedShaders_client_proc_t glGetAttachedShaders;
+	glGetAttribLocation_client_proc_t glGetAttribLocation;
+	glGetBooleanv_client_proc_t glGetBooleanv;
+	glGetBufferParameteriv_client_proc_t glGetBufferParameteriv;
+	glGetError_client_proc_t glGetError;
+	glGetFloatv_client_proc_t glGetFloatv;
+	glGetFramebufferAttachmentParameteriv_client_proc_t glGetFramebufferAttachmentParameteriv;
+	glGetIntegerv_client_proc_t glGetIntegerv;
+	glGetProgramiv_client_proc_t glGetProgramiv;
+	glGetProgramInfoLog_client_proc_t glGetProgramInfoLog;
+	glGetRenderbufferParameteriv_client_proc_t glGetRenderbufferParameteriv;
+	glGetShaderiv_client_proc_t glGetShaderiv;
+	glGetShaderInfoLog_client_proc_t glGetShaderInfoLog;
+	glGetShaderPrecisionFormat_client_proc_t glGetShaderPrecisionFormat;
+	glGetShaderSource_client_proc_t glGetShaderSource;
+	glGetString_client_proc_t glGetString;
+	glGetTexParameterfv_client_proc_t glGetTexParameterfv;
+	glGetTexParameteriv_client_proc_t glGetTexParameteriv;
+	glGetUniformfv_client_proc_t glGetUniformfv;
+	glGetUniformiv_client_proc_t glGetUniformiv;
+	glGetUniformLocation_client_proc_t glGetUniformLocation;
+	glGetVertexAttribfv_client_proc_t glGetVertexAttribfv;
+	glGetVertexAttribiv_client_proc_t glGetVertexAttribiv;
+	glGetVertexAttribPointerv_client_proc_t glGetVertexAttribPointerv;
+	glHint_client_proc_t glHint;
+	glIsBuffer_client_proc_t glIsBuffer;
+	glIsEnabled_client_proc_t glIsEnabled;
+	glIsFramebuffer_client_proc_t glIsFramebuffer;
+	glIsProgram_client_proc_t glIsProgram;
+	glIsRenderbuffer_client_proc_t glIsRenderbuffer;
+	glIsShader_client_proc_t glIsShader;
+	glIsTexture_client_proc_t glIsTexture;
+	glLineWidth_client_proc_t glLineWidth;
+	glLinkProgram_client_proc_t glLinkProgram;
+	glPixelStorei_client_proc_t glPixelStorei;
+	glPolygonOffset_client_proc_t glPolygonOffset;
+	glReadPixels_client_proc_t glReadPixels;
+	glReleaseShaderCompiler_client_proc_t glReleaseShaderCompiler;
+	glRenderbufferStorage_client_proc_t glRenderbufferStorage;
+	glSampleCoverage_client_proc_t glSampleCoverage;
+	glScissor_client_proc_t glScissor;
+	glShaderBinary_client_proc_t glShaderBinary;
+	glShaderSource_client_proc_t glShaderSource;
+	glStencilFunc_client_proc_t glStencilFunc;
+	glStencilFuncSeparate_client_proc_t glStencilFuncSeparate;
+	glStencilMask_client_proc_t glStencilMask;
+	glStencilMaskSeparate_client_proc_t glStencilMaskSeparate;
+	glStencilOp_client_proc_t glStencilOp;
+	glStencilOpSeparate_client_proc_t glStencilOpSeparate;
+	glTexImage2D_client_proc_t glTexImage2D;
+	glTexParameterf_client_proc_t glTexParameterf;
+	glTexParameterfv_client_proc_t glTexParameterfv;
+	glTexParameteri_client_proc_t glTexParameteri;
+	glTexParameteriv_client_proc_t glTexParameteriv;
+	glTexSubImage2D_client_proc_t glTexSubImage2D;
+	glUniform1f_client_proc_t glUniform1f;
+	glUniform1fv_client_proc_t glUniform1fv;
+	glUniform1i_client_proc_t glUniform1i;
+	glUniform1iv_client_proc_t glUniform1iv;
+	glUniform2f_client_proc_t glUniform2f;
+	glUniform2fv_client_proc_t glUniform2fv;
+	glUniform2i_client_proc_t glUniform2i;
+	glUniform2iv_client_proc_t glUniform2iv;
+	glUniform3f_client_proc_t glUniform3f;
+	glUniform3fv_client_proc_t glUniform3fv;
+	glUniform3i_client_proc_t glUniform3i;
+	glUniform3iv_client_proc_t glUniform3iv;
+	glUniform4f_client_proc_t glUniform4f;
+	glUniform4fv_client_proc_t glUniform4fv;
+	glUniform4i_client_proc_t glUniform4i;
+	glUniform4iv_client_proc_t glUniform4iv;
+	glUniformMatrix2fv_client_proc_t glUniformMatrix2fv;
+	glUniformMatrix3fv_client_proc_t glUniformMatrix3fv;
+	glUniformMatrix4fv_client_proc_t glUniformMatrix4fv;
+	glUseProgram_client_proc_t glUseProgram;
+	glValidateProgram_client_proc_t glValidateProgram;
+	glVertexAttrib1f_client_proc_t glVertexAttrib1f;
+	glVertexAttrib1fv_client_proc_t glVertexAttrib1fv;
+	glVertexAttrib2f_client_proc_t glVertexAttrib2f;
+	glVertexAttrib2fv_client_proc_t glVertexAttrib2fv;
+	glVertexAttrib3f_client_proc_t glVertexAttrib3f;
+	glVertexAttrib3fv_client_proc_t glVertexAttrib3fv;
+	glVertexAttrib4f_client_proc_t glVertexAttrib4f;
+	glVertexAttrib4fv_client_proc_t glVertexAttrib4fv;
+	glVertexAttribPointer_client_proc_t glVertexAttribPointer;
+	glViewport_client_proc_t glViewport;
+	glEGLImageTargetTexture2DOES_client_proc_t glEGLImageTargetTexture2DOES;
+	glEGLImageTargetRenderbufferStorageOES_client_proc_t glEGLImageTargetRenderbufferStorageOES;
+	glGetProgramBinaryOES_client_proc_t glGetProgramBinaryOES;
+	glProgramBinaryOES_client_proc_t glProgramBinaryOES;
+	glMapBufferOES_client_proc_t glMapBufferOES;
+	glUnmapBufferOES_client_proc_t glUnmapBufferOES;
+	glTexImage3DOES_client_proc_t glTexImage3DOES;
+	glTexSubImage3DOES_client_proc_t glTexSubImage3DOES;
+	glCopyTexSubImage3DOES_client_proc_t glCopyTexSubImage3DOES;
+	glCompressedTexImage3DOES_client_proc_t glCompressedTexImage3DOES;
+	glCompressedTexSubImage3DOES_client_proc_t glCompressedTexSubImage3DOES;
+	glFramebufferTexture3DOES_client_proc_t glFramebufferTexture3DOES;
+	glBindVertexArrayOES_client_proc_t glBindVertexArrayOES;
+	glDeleteVertexArraysOES_client_proc_t glDeleteVertexArraysOES;
+	glGenVertexArraysOES_client_proc_t glGenVertexArraysOES;
+	glIsVertexArrayOES_client_proc_t glIsVertexArrayOES;
+	glDiscardFramebufferEXT_client_proc_t glDiscardFramebufferEXT;
+	glMultiDrawArraysEXT_client_proc_t glMultiDrawArraysEXT;
+	glMultiDrawElementsEXT_client_proc_t glMultiDrawElementsEXT;
+	glGetPerfMonitorGroupsAMD_client_proc_t glGetPerfMonitorGroupsAMD;
+	glGetPerfMonitorCountersAMD_client_proc_t glGetPerfMonitorCountersAMD;
+	glGetPerfMonitorGroupStringAMD_client_proc_t glGetPerfMonitorGroupStringAMD;
+	glGetPerfMonitorCounterStringAMD_client_proc_t glGetPerfMonitorCounterStringAMD;
+	glGetPerfMonitorCounterInfoAMD_client_proc_t glGetPerfMonitorCounterInfoAMD;
+	glGenPerfMonitorsAMD_client_proc_t glGenPerfMonitorsAMD;
+	glDeletePerfMonitorsAMD_client_proc_t glDeletePerfMonitorsAMD;
+	glSelectPerfMonitorCountersAMD_client_proc_t glSelectPerfMonitorCountersAMD;
+	glBeginPerfMonitorAMD_client_proc_t glBeginPerfMonitorAMD;
+	glEndPerfMonitorAMD_client_proc_t glEndPerfMonitorAMD;
+	glGetPerfMonitorCounterDataAMD_client_proc_t glGetPerfMonitorCounterDataAMD;
+	glRenderbufferStorageMultisampleIMG_client_proc_t glRenderbufferStorageMultisampleIMG;
+	glFramebufferTexture2DMultisampleIMG_client_proc_t glFramebufferTexture2DMultisampleIMG;
+	glDeleteFencesNV_client_proc_t glDeleteFencesNV;
+	glGenFencesNV_client_proc_t glGenFencesNV;
+	glIsFenceNV_client_proc_t glIsFenceNV;
+	glTestFenceNV_client_proc_t glTestFenceNV;
+	glGetFenceivNV_client_proc_t glGetFenceivNV;
+	glFinishFenceNV_client_proc_t glFinishFenceNV;
+	glSetFenceNV_client_proc_t glSetFenceNV;
+	glCoverageMaskNV_client_proc_t glCoverageMaskNV;
+	glCoverageOperationNV_client_proc_t glCoverageOperationNV;
+	glGetDriverControlsQCOM_client_proc_t glGetDriverControlsQCOM;
+	glGetDriverControlStringQCOM_client_proc_t glGetDriverControlStringQCOM;
+	glEnableDriverControlQCOM_client_proc_t glEnableDriverControlQCOM;
+	glDisableDriverControlQCOM_client_proc_t glDisableDriverControlQCOM;
+	glExtGetTexturesQCOM_client_proc_t glExtGetTexturesQCOM;
+	glExtGetBuffersQCOM_client_proc_t glExtGetBuffersQCOM;
+	glExtGetRenderbuffersQCOM_client_proc_t glExtGetRenderbuffersQCOM;
+	glExtGetFramebuffersQCOM_client_proc_t glExtGetFramebuffersQCOM;
+	glExtGetTexLevelParameterivQCOM_client_proc_t glExtGetTexLevelParameterivQCOM;
+	glExtTexObjectStateOverrideiQCOM_client_proc_t glExtTexObjectStateOverrideiQCOM;
+	glExtGetTexSubImageQCOM_client_proc_t glExtGetTexSubImageQCOM;
+	glExtGetBufferPointervQCOM_client_proc_t glExtGetBufferPointervQCOM;
+	glExtGetShadersQCOM_client_proc_t glExtGetShadersQCOM;
+	glExtGetProgramsQCOM_client_proc_t glExtGetProgramsQCOM;
+	glExtIsProgramBinaryQCOM_client_proc_t glExtIsProgramBinaryQCOM;
+	glExtGetProgramBinarySourceQCOM_client_proc_t glExtGetProgramBinarySourceQCOM;
+	glStartTilingQCOM_client_proc_t glStartTilingQCOM;
+	glEndTilingQCOM_client_proc_t glEndTilingQCOM;
+	glVertexAttribPointerData_client_proc_t glVertexAttribPointerData;
+	glVertexAttribPointerOffset_client_proc_t glVertexAttribPointerOffset;
+	glDrawElementsOffset_client_proc_t glDrawElementsOffset;
+	glDrawElementsData_client_proc_t glDrawElementsData;
+	glGetCompressedTextureFormats_client_proc_t glGetCompressedTextureFormats;
+	glShaderString_client_proc_t glShaderString;
+	glFinishRoundTrip_client_proc_t glFinishRoundTrip;
+	//Accessors 
+	virtual glActiveTexture_client_proc_t set_glActiveTexture(glActiveTexture_client_proc_t f) { glActiveTexture_client_proc_t retval = glActiveTexture; glActiveTexture = f; return retval;}
+	virtual glAttachShader_client_proc_t set_glAttachShader(glAttachShader_client_proc_t f) { glAttachShader_client_proc_t retval = glAttachShader; glAttachShader = f; return retval;}
+	virtual glBindAttribLocation_client_proc_t set_glBindAttribLocation(glBindAttribLocation_client_proc_t f) { glBindAttribLocation_client_proc_t retval = glBindAttribLocation; glBindAttribLocation = f; return retval;}
+	virtual glBindBuffer_client_proc_t set_glBindBuffer(glBindBuffer_client_proc_t f) { glBindBuffer_client_proc_t retval = glBindBuffer; glBindBuffer = f; return retval;}
+	virtual glBindFramebuffer_client_proc_t set_glBindFramebuffer(glBindFramebuffer_client_proc_t f) { glBindFramebuffer_client_proc_t retval = glBindFramebuffer; glBindFramebuffer = f; return retval;}
+	virtual glBindRenderbuffer_client_proc_t set_glBindRenderbuffer(glBindRenderbuffer_client_proc_t f) { glBindRenderbuffer_client_proc_t retval = glBindRenderbuffer; glBindRenderbuffer = f; return retval;}
+	virtual glBindTexture_client_proc_t set_glBindTexture(glBindTexture_client_proc_t f) { glBindTexture_client_proc_t retval = glBindTexture; glBindTexture = f; return retval;}
+	virtual glBlendColor_client_proc_t set_glBlendColor(glBlendColor_client_proc_t f) { glBlendColor_client_proc_t retval = glBlendColor; glBlendColor = f; return retval;}
+	virtual glBlendEquation_client_proc_t set_glBlendEquation(glBlendEquation_client_proc_t f) { glBlendEquation_client_proc_t retval = glBlendEquation; glBlendEquation = f; return retval;}
+	virtual glBlendEquationSeparate_client_proc_t set_glBlendEquationSeparate(glBlendEquationSeparate_client_proc_t f) { glBlendEquationSeparate_client_proc_t retval = glBlendEquationSeparate; glBlendEquationSeparate = f; return retval;}
+	virtual glBlendFunc_client_proc_t set_glBlendFunc(glBlendFunc_client_proc_t f) { glBlendFunc_client_proc_t retval = glBlendFunc; glBlendFunc = f; return retval;}
+	virtual glBlendFuncSeparate_client_proc_t set_glBlendFuncSeparate(glBlendFuncSeparate_client_proc_t f) { glBlendFuncSeparate_client_proc_t retval = glBlendFuncSeparate; glBlendFuncSeparate = f; return retval;}
+	virtual glBufferData_client_proc_t set_glBufferData(glBufferData_client_proc_t f) { glBufferData_client_proc_t retval = glBufferData; glBufferData = f; return retval;}
+	virtual glBufferSubData_client_proc_t set_glBufferSubData(glBufferSubData_client_proc_t f) { glBufferSubData_client_proc_t retval = glBufferSubData; glBufferSubData = f; return retval;}
+	virtual glCheckFramebufferStatus_client_proc_t set_glCheckFramebufferStatus(glCheckFramebufferStatus_client_proc_t f) { glCheckFramebufferStatus_client_proc_t retval = glCheckFramebufferStatus; glCheckFramebufferStatus = f; return retval;}
+	virtual glClear_client_proc_t set_glClear(glClear_client_proc_t f) { glClear_client_proc_t retval = glClear; glClear = f; return retval;}
+	virtual glClearColor_client_proc_t set_glClearColor(glClearColor_client_proc_t f) { glClearColor_client_proc_t retval = glClearColor; glClearColor = f; return retval;}
+	virtual glClearDepthf_client_proc_t set_glClearDepthf(glClearDepthf_client_proc_t f) { glClearDepthf_client_proc_t retval = glClearDepthf; glClearDepthf = f; return retval;}
+	virtual glClearStencil_client_proc_t set_glClearStencil(glClearStencil_client_proc_t f) { glClearStencil_client_proc_t retval = glClearStencil; glClearStencil = f; return retval;}
+	virtual glColorMask_client_proc_t set_glColorMask(glColorMask_client_proc_t f) { glColorMask_client_proc_t retval = glColorMask; glColorMask = f; return retval;}
+	virtual glCompileShader_client_proc_t set_glCompileShader(glCompileShader_client_proc_t f) { glCompileShader_client_proc_t retval = glCompileShader; glCompileShader = f; return retval;}
+	virtual glCompressedTexImage2D_client_proc_t set_glCompressedTexImage2D(glCompressedTexImage2D_client_proc_t f) { glCompressedTexImage2D_client_proc_t retval = glCompressedTexImage2D; glCompressedTexImage2D = f; return retval;}
+	virtual glCompressedTexSubImage2D_client_proc_t set_glCompressedTexSubImage2D(glCompressedTexSubImage2D_client_proc_t f) { glCompressedTexSubImage2D_client_proc_t retval = glCompressedTexSubImage2D; glCompressedTexSubImage2D = f; return retval;}
+	virtual glCopyTexImage2D_client_proc_t set_glCopyTexImage2D(glCopyTexImage2D_client_proc_t f) { glCopyTexImage2D_client_proc_t retval = glCopyTexImage2D; glCopyTexImage2D = f; return retval;}
+	virtual glCopyTexSubImage2D_client_proc_t set_glCopyTexSubImage2D(glCopyTexSubImage2D_client_proc_t f) { glCopyTexSubImage2D_client_proc_t retval = glCopyTexSubImage2D; glCopyTexSubImage2D = f; return retval;}
+	virtual glCreateProgram_client_proc_t set_glCreateProgram(glCreateProgram_client_proc_t f) { glCreateProgram_client_proc_t retval = glCreateProgram; glCreateProgram = f; return retval;}
+	virtual glCreateShader_client_proc_t set_glCreateShader(glCreateShader_client_proc_t f) { glCreateShader_client_proc_t retval = glCreateShader; glCreateShader = f; return retval;}
+	virtual glCullFace_client_proc_t set_glCullFace(glCullFace_client_proc_t f) { glCullFace_client_proc_t retval = glCullFace; glCullFace = f; return retval;}
+	virtual glDeleteBuffers_client_proc_t set_glDeleteBuffers(glDeleteBuffers_client_proc_t f) { glDeleteBuffers_client_proc_t retval = glDeleteBuffers; glDeleteBuffers = f; return retval;}
+	virtual glDeleteFramebuffers_client_proc_t set_glDeleteFramebuffers(glDeleteFramebuffers_client_proc_t f) { glDeleteFramebuffers_client_proc_t retval = glDeleteFramebuffers; glDeleteFramebuffers = f; return retval;}
+	virtual glDeleteProgram_client_proc_t set_glDeleteProgram(glDeleteProgram_client_proc_t f) { glDeleteProgram_client_proc_t retval = glDeleteProgram; glDeleteProgram = f; return retval;}
+	virtual glDeleteRenderbuffers_client_proc_t set_glDeleteRenderbuffers(glDeleteRenderbuffers_client_proc_t f) { glDeleteRenderbuffers_client_proc_t retval = glDeleteRenderbuffers; glDeleteRenderbuffers = f; return retval;}
+	virtual glDeleteShader_client_proc_t set_glDeleteShader(glDeleteShader_client_proc_t f) { glDeleteShader_client_proc_t retval = glDeleteShader; glDeleteShader = f; return retval;}
+	virtual glDeleteTextures_client_proc_t set_glDeleteTextures(glDeleteTextures_client_proc_t f) { glDeleteTextures_client_proc_t retval = glDeleteTextures; glDeleteTextures = f; return retval;}
+	virtual glDepthFunc_client_proc_t set_glDepthFunc(glDepthFunc_client_proc_t f) { glDepthFunc_client_proc_t retval = glDepthFunc; glDepthFunc = f; return retval;}
+	virtual glDepthMask_client_proc_t set_glDepthMask(glDepthMask_client_proc_t f) { glDepthMask_client_proc_t retval = glDepthMask; glDepthMask = f; return retval;}
+	virtual glDepthRangef_client_proc_t set_glDepthRangef(glDepthRangef_client_proc_t f) { glDepthRangef_client_proc_t retval = glDepthRangef; glDepthRangef = f; return retval;}
+	virtual glDetachShader_client_proc_t set_glDetachShader(glDetachShader_client_proc_t f) { glDetachShader_client_proc_t retval = glDetachShader; glDetachShader = f; return retval;}
+	virtual glDisable_client_proc_t set_glDisable(glDisable_client_proc_t f) { glDisable_client_proc_t retval = glDisable; glDisable = f; return retval;}
+	virtual glDisableVertexAttribArray_client_proc_t set_glDisableVertexAttribArray(glDisableVertexAttribArray_client_proc_t f) { glDisableVertexAttribArray_client_proc_t retval = glDisableVertexAttribArray; glDisableVertexAttribArray = f; return retval;}
+	virtual glDrawArrays_client_proc_t set_glDrawArrays(glDrawArrays_client_proc_t f) { glDrawArrays_client_proc_t retval = glDrawArrays; glDrawArrays = f; return retval;}
+	virtual glDrawElements_client_proc_t set_glDrawElements(glDrawElements_client_proc_t f) { glDrawElements_client_proc_t retval = glDrawElements; glDrawElements = f; return retval;}
+	virtual glEnable_client_proc_t set_glEnable(glEnable_client_proc_t f) { glEnable_client_proc_t retval = glEnable; glEnable = f; return retval;}
+	virtual glEnableVertexAttribArray_client_proc_t set_glEnableVertexAttribArray(glEnableVertexAttribArray_client_proc_t f) { glEnableVertexAttribArray_client_proc_t retval = glEnableVertexAttribArray; glEnableVertexAttribArray = f; return retval;}
+	virtual glFinish_client_proc_t set_glFinish(glFinish_client_proc_t f) { glFinish_client_proc_t retval = glFinish; glFinish = f; return retval;}
+	virtual glFlush_client_proc_t set_glFlush(glFlush_client_proc_t f) { glFlush_client_proc_t retval = glFlush; glFlush = f; return retval;}
+	virtual glFramebufferRenderbuffer_client_proc_t set_glFramebufferRenderbuffer(glFramebufferRenderbuffer_client_proc_t f) { glFramebufferRenderbuffer_client_proc_t retval = glFramebufferRenderbuffer; glFramebufferRenderbuffer = f; return retval;}
+	virtual glFramebufferTexture2D_client_proc_t set_glFramebufferTexture2D(glFramebufferTexture2D_client_proc_t f) { glFramebufferTexture2D_client_proc_t retval = glFramebufferTexture2D; glFramebufferTexture2D = f; return retval;}
+	virtual glFrontFace_client_proc_t set_glFrontFace(glFrontFace_client_proc_t f) { glFrontFace_client_proc_t retval = glFrontFace; glFrontFace = f; return retval;}
+	virtual glGenBuffers_client_proc_t set_glGenBuffers(glGenBuffers_client_proc_t f) { glGenBuffers_client_proc_t retval = glGenBuffers; glGenBuffers = f; return retval;}
+	virtual glGenerateMipmap_client_proc_t set_glGenerateMipmap(glGenerateMipmap_client_proc_t f) { glGenerateMipmap_client_proc_t retval = glGenerateMipmap; glGenerateMipmap = f; return retval;}
+	virtual glGenFramebuffers_client_proc_t set_glGenFramebuffers(glGenFramebuffers_client_proc_t f) { glGenFramebuffers_client_proc_t retval = glGenFramebuffers; glGenFramebuffers = f; return retval;}
+	virtual glGenRenderbuffers_client_proc_t set_glGenRenderbuffers(glGenRenderbuffers_client_proc_t f) { glGenRenderbuffers_client_proc_t retval = glGenRenderbuffers; glGenRenderbuffers = f; return retval;}
+	virtual glGenTextures_client_proc_t set_glGenTextures(glGenTextures_client_proc_t f) { glGenTextures_client_proc_t retval = glGenTextures; glGenTextures = f; return retval;}
+	virtual glGetActiveAttrib_client_proc_t set_glGetActiveAttrib(glGetActiveAttrib_client_proc_t f) { glGetActiveAttrib_client_proc_t retval = glGetActiveAttrib; glGetActiveAttrib = f; return retval;}
+	virtual glGetActiveUniform_client_proc_t set_glGetActiveUniform(glGetActiveUniform_client_proc_t f) { glGetActiveUniform_client_proc_t retval = glGetActiveUniform; glGetActiveUniform = f; return retval;}
+	virtual glGetAttachedShaders_client_proc_t set_glGetAttachedShaders(glGetAttachedShaders_client_proc_t f) { glGetAttachedShaders_client_proc_t retval = glGetAttachedShaders; glGetAttachedShaders = f; return retval;}
+	virtual glGetAttribLocation_client_proc_t set_glGetAttribLocation(glGetAttribLocation_client_proc_t f) { glGetAttribLocation_client_proc_t retval = glGetAttribLocation; glGetAttribLocation = f; return retval;}
+	virtual glGetBooleanv_client_proc_t set_glGetBooleanv(glGetBooleanv_client_proc_t f) { glGetBooleanv_client_proc_t retval = glGetBooleanv; glGetBooleanv = f; return retval;}
+	virtual glGetBufferParameteriv_client_proc_t set_glGetBufferParameteriv(glGetBufferParameteriv_client_proc_t f) { glGetBufferParameteriv_client_proc_t retval = glGetBufferParameteriv; glGetBufferParameteriv = f; return retval;}
+	virtual glGetError_client_proc_t set_glGetError(glGetError_client_proc_t f) { glGetError_client_proc_t retval = glGetError; glGetError = f; return retval;}
+	virtual glGetFloatv_client_proc_t set_glGetFloatv(glGetFloatv_client_proc_t f) { glGetFloatv_client_proc_t retval = glGetFloatv; glGetFloatv = f; return retval;}
+	virtual glGetFramebufferAttachmentParameteriv_client_proc_t set_glGetFramebufferAttachmentParameteriv(glGetFramebufferAttachmentParameteriv_client_proc_t f) { glGetFramebufferAttachmentParameteriv_client_proc_t retval = glGetFramebufferAttachmentParameteriv; glGetFramebufferAttachmentParameteriv = f; return retval;}
+	virtual glGetIntegerv_client_proc_t set_glGetIntegerv(glGetIntegerv_client_proc_t f) { glGetIntegerv_client_proc_t retval = glGetIntegerv; glGetIntegerv = f; return retval;}
+	virtual glGetProgramiv_client_proc_t set_glGetProgramiv(glGetProgramiv_client_proc_t f) { glGetProgramiv_client_proc_t retval = glGetProgramiv; glGetProgramiv = f; return retval;}
+	virtual glGetProgramInfoLog_client_proc_t set_glGetProgramInfoLog(glGetProgramInfoLog_client_proc_t f) { glGetProgramInfoLog_client_proc_t retval = glGetProgramInfoLog; glGetProgramInfoLog = f; return retval;}
+	virtual glGetRenderbufferParameteriv_client_proc_t set_glGetRenderbufferParameteriv(glGetRenderbufferParameteriv_client_proc_t f) { glGetRenderbufferParameteriv_client_proc_t retval = glGetRenderbufferParameteriv; glGetRenderbufferParameteriv = f; return retval;}
+	virtual glGetShaderiv_client_proc_t set_glGetShaderiv(glGetShaderiv_client_proc_t f) { glGetShaderiv_client_proc_t retval = glGetShaderiv; glGetShaderiv = f; return retval;}
+	virtual glGetShaderInfoLog_client_proc_t set_glGetShaderInfoLog(glGetShaderInfoLog_client_proc_t f) { glGetShaderInfoLog_client_proc_t retval = glGetShaderInfoLog; glGetShaderInfoLog = f; return retval;}
+	virtual glGetShaderPrecisionFormat_client_proc_t set_glGetShaderPrecisionFormat(glGetShaderPrecisionFormat_client_proc_t f) { glGetShaderPrecisionFormat_client_proc_t retval = glGetShaderPrecisionFormat; glGetShaderPrecisionFormat = f; return retval;}
+	virtual glGetShaderSource_client_proc_t set_glGetShaderSource(glGetShaderSource_client_proc_t f) { glGetShaderSource_client_proc_t retval = glGetShaderSource; glGetShaderSource = f; return retval;}
+	virtual glGetString_client_proc_t set_glGetString(glGetString_client_proc_t f) { glGetString_client_proc_t retval = glGetString; glGetString = f; return retval;}
+	virtual glGetTexParameterfv_client_proc_t set_glGetTexParameterfv(glGetTexParameterfv_client_proc_t f) { glGetTexParameterfv_client_proc_t retval = glGetTexParameterfv; glGetTexParameterfv = f; return retval;}
+	virtual glGetTexParameteriv_client_proc_t set_glGetTexParameteriv(glGetTexParameteriv_client_proc_t f) { glGetTexParameteriv_client_proc_t retval = glGetTexParameteriv; glGetTexParameteriv = f; return retval;}
+	virtual glGetUniformfv_client_proc_t set_glGetUniformfv(glGetUniformfv_client_proc_t f) { glGetUniformfv_client_proc_t retval = glGetUniformfv; glGetUniformfv = f; return retval;}
+	virtual glGetUniformiv_client_proc_t set_glGetUniformiv(glGetUniformiv_client_proc_t f) { glGetUniformiv_client_proc_t retval = glGetUniformiv; glGetUniformiv = f; return retval;}
+	virtual glGetUniformLocation_client_proc_t set_glGetUniformLocation(glGetUniformLocation_client_proc_t f) { glGetUniformLocation_client_proc_t retval = glGetUniformLocation; glGetUniformLocation = f; return retval;}
+	virtual glGetVertexAttribfv_client_proc_t set_glGetVertexAttribfv(glGetVertexAttribfv_client_proc_t f) { glGetVertexAttribfv_client_proc_t retval = glGetVertexAttribfv; glGetVertexAttribfv = f; return retval;}
+	virtual glGetVertexAttribiv_client_proc_t set_glGetVertexAttribiv(glGetVertexAttribiv_client_proc_t f) { glGetVertexAttribiv_client_proc_t retval = glGetVertexAttribiv; glGetVertexAttribiv = f; return retval;}
+	virtual glGetVertexAttribPointerv_client_proc_t set_glGetVertexAttribPointerv(glGetVertexAttribPointerv_client_proc_t f) { glGetVertexAttribPointerv_client_proc_t retval = glGetVertexAttribPointerv; glGetVertexAttribPointerv = f; return retval;}
+	virtual glHint_client_proc_t set_glHint(glHint_client_proc_t f) { glHint_client_proc_t retval = glHint; glHint = f; return retval;}
+	virtual glIsBuffer_client_proc_t set_glIsBuffer(glIsBuffer_client_proc_t f) { glIsBuffer_client_proc_t retval = glIsBuffer; glIsBuffer = f; return retval;}
+	virtual glIsEnabled_client_proc_t set_glIsEnabled(glIsEnabled_client_proc_t f) { glIsEnabled_client_proc_t retval = glIsEnabled; glIsEnabled = f; return retval;}
+	virtual glIsFramebuffer_client_proc_t set_glIsFramebuffer(glIsFramebuffer_client_proc_t f) { glIsFramebuffer_client_proc_t retval = glIsFramebuffer; glIsFramebuffer = f; return retval;}
+	virtual glIsProgram_client_proc_t set_glIsProgram(glIsProgram_client_proc_t f) { glIsProgram_client_proc_t retval = glIsProgram; glIsProgram = f; return retval;}
+	virtual glIsRenderbuffer_client_proc_t set_glIsRenderbuffer(glIsRenderbuffer_client_proc_t f) { glIsRenderbuffer_client_proc_t retval = glIsRenderbuffer; glIsRenderbuffer = f; return retval;}
+	virtual glIsShader_client_proc_t set_glIsShader(glIsShader_client_proc_t f) { glIsShader_client_proc_t retval = glIsShader; glIsShader = f; return retval;}
+	virtual glIsTexture_client_proc_t set_glIsTexture(glIsTexture_client_proc_t f) { glIsTexture_client_proc_t retval = glIsTexture; glIsTexture = f; return retval;}
+	virtual glLineWidth_client_proc_t set_glLineWidth(glLineWidth_client_proc_t f) { glLineWidth_client_proc_t retval = glLineWidth; glLineWidth = f; return retval;}
+	virtual glLinkProgram_client_proc_t set_glLinkProgram(glLinkProgram_client_proc_t f) { glLinkProgram_client_proc_t retval = glLinkProgram; glLinkProgram = f; return retval;}
+	virtual glPixelStorei_client_proc_t set_glPixelStorei(glPixelStorei_client_proc_t f) { glPixelStorei_client_proc_t retval = glPixelStorei; glPixelStorei = f; return retval;}
+	virtual glPolygonOffset_client_proc_t set_glPolygonOffset(glPolygonOffset_client_proc_t f) { glPolygonOffset_client_proc_t retval = glPolygonOffset; glPolygonOffset = f; return retval;}
+	virtual glReadPixels_client_proc_t set_glReadPixels(glReadPixels_client_proc_t f) { glReadPixels_client_proc_t retval = glReadPixels; glReadPixels = f; return retval;}
+	virtual glReleaseShaderCompiler_client_proc_t set_glReleaseShaderCompiler(glReleaseShaderCompiler_client_proc_t f) { glReleaseShaderCompiler_client_proc_t retval = glReleaseShaderCompiler; glReleaseShaderCompiler = f; return retval;}
+	virtual glRenderbufferStorage_client_proc_t set_glRenderbufferStorage(glRenderbufferStorage_client_proc_t f) { glRenderbufferStorage_client_proc_t retval = glRenderbufferStorage; glRenderbufferStorage = f; return retval;}
+	virtual glSampleCoverage_client_proc_t set_glSampleCoverage(glSampleCoverage_client_proc_t f) { glSampleCoverage_client_proc_t retval = glSampleCoverage; glSampleCoverage = f; return retval;}
+	virtual glScissor_client_proc_t set_glScissor(glScissor_client_proc_t f) { glScissor_client_proc_t retval = glScissor; glScissor = f; return retval;}
+	virtual glShaderBinary_client_proc_t set_glShaderBinary(glShaderBinary_client_proc_t f) { glShaderBinary_client_proc_t retval = glShaderBinary; glShaderBinary = f; return retval;}
+	virtual glShaderSource_client_proc_t set_glShaderSource(glShaderSource_client_proc_t f) { glShaderSource_client_proc_t retval = glShaderSource; glShaderSource = f; return retval;}
+	virtual glStencilFunc_client_proc_t set_glStencilFunc(glStencilFunc_client_proc_t f) { glStencilFunc_client_proc_t retval = glStencilFunc; glStencilFunc = f; return retval;}
+	virtual glStencilFuncSeparate_client_proc_t set_glStencilFuncSeparate(glStencilFuncSeparate_client_proc_t f) { glStencilFuncSeparate_client_proc_t retval = glStencilFuncSeparate; glStencilFuncSeparate = f; return retval;}
+	virtual glStencilMask_client_proc_t set_glStencilMask(glStencilMask_client_proc_t f) { glStencilMask_client_proc_t retval = glStencilMask; glStencilMask = f; return retval;}
+	virtual glStencilMaskSeparate_client_proc_t set_glStencilMaskSeparate(glStencilMaskSeparate_client_proc_t f) { glStencilMaskSeparate_client_proc_t retval = glStencilMaskSeparate; glStencilMaskSeparate = f; return retval;}
+	virtual glStencilOp_client_proc_t set_glStencilOp(glStencilOp_client_proc_t f) { glStencilOp_client_proc_t retval = glStencilOp; glStencilOp = f; return retval;}
+	virtual glStencilOpSeparate_client_proc_t set_glStencilOpSeparate(glStencilOpSeparate_client_proc_t f) { glStencilOpSeparate_client_proc_t retval = glStencilOpSeparate; glStencilOpSeparate = f; return retval;}
+	virtual glTexImage2D_client_proc_t set_glTexImage2D(glTexImage2D_client_proc_t f) { glTexImage2D_client_proc_t retval = glTexImage2D; glTexImage2D = f; return retval;}
+	virtual glTexParameterf_client_proc_t set_glTexParameterf(glTexParameterf_client_proc_t f) { glTexParameterf_client_proc_t retval = glTexParameterf; glTexParameterf = f; return retval;}
+	virtual glTexParameterfv_client_proc_t set_glTexParameterfv(glTexParameterfv_client_proc_t f) { glTexParameterfv_client_proc_t retval = glTexParameterfv; glTexParameterfv = f; return retval;}
+	virtual glTexParameteri_client_proc_t set_glTexParameteri(glTexParameteri_client_proc_t f) { glTexParameteri_client_proc_t retval = glTexParameteri; glTexParameteri = f; return retval;}
+	virtual glTexParameteriv_client_proc_t set_glTexParameteriv(glTexParameteriv_client_proc_t f) { glTexParameteriv_client_proc_t retval = glTexParameteriv; glTexParameteriv = f; return retval;}
+	virtual glTexSubImage2D_client_proc_t set_glTexSubImage2D(glTexSubImage2D_client_proc_t f) { glTexSubImage2D_client_proc_t retval = glTexSubImage2D; glTexSubImage2D = f; return retval;}
+	virtual glUniform1f_client_proc_t set_glUniform1f(glUniform1f_client_proc_t f) { glUniform1f_client_proc_t retval = glUniform1f; glUniform1f = f; return retval;}
+	virtual glUniform1fv_client_proc_t set_glUniform1fv(glUniform1fv_client_proc_t f) { glUniform1fv_client_proc_t retval = glUniform1fv; glUniform1fv = f; return retval;}
+	virtual glUniform1i_client_proc_t set_glUniform1i(glUniform1i_client_proc_t f) { glUniform1i_client_proc_t retval = glUniform1i; glUniform1i = f; return retval;}
+	virtual glUniform1iv_client_proc_t set_glUniform1iv(glUniform1iv_client_proc_t f) { glUniform1iv_client_proc_t retval = glUniform1iv; glUniform1iv = f; return retval;}
+	virtual glUniform2f_client_proc_t set_glUniform2f(glUniform2f_client_proc_t f) { glUniform2f_client_proc_t retval = glUniform2f; glUniform2f = f; return retval;}
+	virtual glUniform2fv_client_proc_t set_glUniform2fv(glUniform2fv_client_proc_t f) { glUniform2fv_client_proc_t retval = glUniform2fv; glUniform2fv = f; return retval;}
+	virtual glUniform2i_client_proc_t set_glUniform2i(glUniform2i_client_proc_t f) { glUniform2i_client_proc_t retval = glUniform2i; glUniform2i = f; return retval;}
+	virtual glUniform2iv_client_proc_t set_glUniform2iv(glUniform2iv_client_proc_t f) { glUniform2iv_client_proc_t retval = glUniform2iv; glUniform2iv = f; return retval;}
+	virtual glUniform3f_client_proc_t set_glUniform3f(glUniform3f_client_proc_t f) { glUniform3f_client_proc_t retval = glUniform3f; glUniform3f = f; return retval;}
+	virtual glUniform3fv_client_proc_t set_glUniform3fv(glUniform3fv_client_proc_t f) { glUniform3fv_client_proc_t retval = glUniform3fv; glUniform3fv = f; return retval;}
+	virtual glUniform3i_client_proc_t set_glUniform3i(glUniform3i_client_proc_t f) { glUniform3i_client_proc_t retval = glUniform3i; glUniform3i = f; return retval;}
+	virtual glUniform3iv_client_proc_t set_glUniform3iv(glUniform3iv_client_proc_t f) { glUniform3iv_client_proc_t retval = glUniform3iv; glUniform3iv = f; return retval;}
+	virtual glUniform4f_client_proc_t set_glUniform4f(glUniform4f_client_proc_t f) { glUniform4f_client_proc_t retval = glUniform4f; glUniform4f = f; return retval;}
+	virtual glUniform4fv_client_proc_t set_glUniform4fv(glUniform4fv_client_proc_t f) { glUniform4fv_client_proc_t retval = glUniform4fv; glUniform4fv = f; return retval;}
+	virtual glUniform4i_client_proc_t set_glUniform4i(glUniform4i_client_proc_t f) { glUniform4i_client_proc_t retval = glUniform4i; glUniform4i = f; return retval;}
+	virtual glUniform4iv_client_proc_t set_glUniform4iv(glUniform4iv_client_proc_t f) { glUniform4iv_client_proc_t retval = glUniform4iv; glUniform4iv = f; return retval;}
+	virtual glUniformMatrix2fv_client_proc_t set_glUniformMatrix2fv(glUniformMatrix2fv_client_proc_t f) { glUniformMatrix2fv_client_proc_t retval = glUniformMatrix2fv; glUniformMatrix2fv = f; return retval;}
+	virtual glUniformMatrix3fv_client_proc_t set_glUniformMatrix3fv(glUniformMatrix3fv_client_proc_t f) { glUniformMatrix3fv_client_proc_t retval = glUniformMatrix3fv; glUniformMatrix3fv = f; return retval;}
+	virtual glUniformMatrix4fv_client_proc_t set_glUniformMatrix4fv(glUniformMatrix4fv_client_proc_t f) { glUniformMatrix4fv_client_proc_t retval = glUniformMatrix4fv; glUniformMatrix4fv = f; return retval;}
+	virtual glUseProgram_client_proc_t set_glUseProgram(glUseProgram_client_proc_t f) { glUseProgram_client_proc_t retval = glUseProgram; glUseProgram = f; return retval;}
+	virtual glValidateProgram_client_proc_t set_glValidateProgram(glValidateProgram_client_proc_t f) { glValidateProgram_client_proc_t retval = glValidateProgram; glValidateProgram = f; return retval;}
+	virtual glVertexAttrib1f_client_proc_t set_glVertexAttrib1f(glVertexAttrib1f_client_proc_t f) { glVertexAttrib1f_client_proc_t retval = glVertexAttrib1f; glVertexAttrib1f = f; return retval;}
+	virtual glVertexAttrib1fv_client_proc_t set_glVertexAttrib1fv(glVertexAttrib1fv_client_proc_t f) { glVertexAttrib1fv_client_proc_t retval = glVertexAttrib1fv; glVertexAttrib1fv = f; return retval;}
+	virtual glVertexAttrib2f_client_proc_t set_glVertexAttrib2f(glVertexAttrib2f_client_proc_t f) { glVertexAttrib2f_client_proc_t retval = glVertexAttrib2f; glVertexAttrib2f = f; return retval;}
+	virtual glVertexAttrib2fv_client_proc_t set_glVertexAttrib2fv(glVertexAttrib2fv_client_proc_t f) { glVertexAttrib2fv_client_proc_t retval = glVertexAttrib2fv; glVertexAttrib2fv = f; return retval;}
+	virtual glVertexAttrib3f_client_proc_t set_glVertexAttrib3f(glVertexAttrib3f_client_proc_t f) { glVertexAttrib3f_client_proc_t retval = glVertexAttrib3f; glVertexAttrib3f = f; return retval;}
+	virtual glVertexAttrib3fv_client_proc_t set_glVertexAttrib3fv(glVertexAttrib3fv_client_proc_t f) { glVertexAttrib3fv_client_proc_t retval = glVertexAttrib3fv; glVertexAttrib3fv = f; return retval;}
+	virtual glVertexAttrib4f_client_proc_t set_glVertexAttrib4f(glVertexAttrib4f_client_proc_t f) { glVertexAttrib4f_client_proc_t retval = glVertexAttrib4f; glVertexAttrib4f = f; return retval;}
+	virtual glVertexAttrib4fv_client_proc_t set_glVertexAttrib4fv(glVertexAttrib4fv_client_proc_t f) { glVertexAttrib4fv_client_proc_t retval = glVertexAttrib4fv; glVertexAttrib4fv = f; return retval;}
+	virtual glVertexAttribPointer_client_proc_t set_glVertexAttribPointer(glVertexAttribPointer_client_proc_t f) { glVertexAttribPointer_client_proc_t retval = glVertexAttribPointer; glVertexAttribPointer = f; return retval;}
+	virtual glViewport_client_proc_t set_glViewport(glViewport_client_proc_t f) { glViewport_client_proc_t retval = glViewport; glViewport = f; return retval;}
+	virtual glEGLImageTargetTexture2DOES_client_proc_t set_glEGLImageTargetTexture2DOES(glEGLImageTargetTexture2DOES_client_proc_t f) { glEGLImageTargetTexture2DOES_client_proc_t retval = glEGLImageTargetTexture2DOES; glEGLImageTargetTexture2DOES = f; return retval;}
+	virtual glEGLImageTargetRenderbufferStorageOES_client_proc_t set_glEGLImageTargetRenderbufferStorageOES(glEGLImageTargetRenderbufferStorageOES_client_proc_t f) { glEGLImageTargetRenderbufferStorageOES_client_proc_t retval = glEGLImageTargetRenderbufferStorageOES; glEGLImageTargetRenderbufferStorageOES = f; return retval;}
+	virtual glGetProgramBinaryOES_client_proc_t set_glGetProgramBinaryOES(glGetProgramBinaryOES_client_proc_t f) { glGetProgramBinaryOES_client_proc_t retval = glGetProgramBinaryOES; glGetProgramBinaryOES = f; return retval;}
+	virtual glProgramBinaryOES_client_proc_t set_glProgramBinaryOES(glProgramBinaryOES_client_proc_t f) { glProgramBinaryOES_client_proc_t retval = glProgramBinaryOES; glProgramBinaryOES = f; return retval;}
+	virtual glMapBufferOES_client_proc_t set_glMapBufferOES(glMapBufferOES_client_proc_t f) { glMapBufferOES_client_proc_t retval = glMapBufferOES; glMapBufferOES = f; return retval;}
+	virtual glUnmapBufferOES_client_proc_t set_glUnmapBufferOES(glUnmapBufferOES_client_proc_t f) { glUnmapBufferOES_client_proc_t retval = glUnmapBufferOES; glUnmapBufferOES = f; return retval;}
+	virtual glTexImage3DOES_client_proc_t set_glTexImage3DOES(glTexImage3DOES_client_proc_t f) { glTexImage3DOES_client_proc_t retval = glTexImage3DOES; glTexImage3DOES = f; return retval;}
+	virtual glTexSubImage3DOES_client_proc_t set_glTexSubImage3DOES(glTexSubImage3DOES_client_proc_t f) { glTexSubImage3DOES_client_proc_t retval = glTexSubImage3DOES; glTexSubImage3DOES = f; return retval;}
+	virtual glCopyTexSubImage3DOES_client_proc_t set_glCopyTexSubImage3DOES(glCopyTexSubImage3DOES_client_proc_t f) { glCopyTexSubImage3DOES_client_proc_t retval = glCopyTexSubImage3DOES; glCopyTexSubImage3DOES = f; return retval;}
+	virtual glCompressedTexImage3DOES_client_proc_t set_glCompressedTexImage3DOES(glCompressedTexImage3DOES_client_proc_t f) { glCompressedTexImage3DOES_client_proc_t retval = glCompressedTexImage3DOES; glCompressedTexImage3DOES = f; return retval;}
+	virtual glCompressedTexSubImage3DOES_client_proc_t set_glCompressedTexSubImage3DOES(glCompressedTexSubImage3DOES_client_proc_t f) { glCompressedTexSubImage3DOES_client_proc_t retval = glCompressedTexSubImage3DOES; glCompressedTexSubImage3DOES = f; return retval;}
+	virtual glFramebufferTexture3DOES_client_proc_t set_glFramebufferTexture3DOES(glFramebufferTexture3DOES_client_proc_t f) { glFramebufferTexture3DOES_client_proc_t retval = glFramebufferTexture3DOES; glFramebufferTexture3DOES = f; return retval;}
+	virtual glBindVertexArrayOES_client_proc_t set_glBindVertexArrayOES(glBindVertexArrayOES_client_proc_t f) { glBindVertexArrayOES_client_proc_t retval = glBindVertexArrayOES; glBindVertexArrayOES = f; return retval;}
+	virtual glDeleteVertexArraysOES_client_proc_t set_glDeleteVertexArraysOES(glDeleteVertexArraysOES_client_proc_t f) { glDeleteVertexArraysOES_client_proc_t retval = glDeleteVertexArraysOES; glDeleteVertexArraysOES = f; return retval;}
+	virtual glGenVertexArraysOES_client_proc_t set_glGenVertexArraysOES(glGenVertexArraysOES_client_proc_t f) { glGenVertexArraysOES_client_proc_t retval = glGenVertexArraysOES; glGenVertexArraysOES = f; return retval;}
+	virtual glIsVertexArrayOES_client_proc_t set_glIsVertexArrayOES(glIsVertexArrayOES_client_proc_t f) { glIsVertexArrayOES_client_proc_t retval = glIsVertexArrayOES; glIsVertexArrayOES = f; return retval;}
+	virtual glDiscardFramebufferEXT_client_proc_t set_glDiscardFramebufferEXT(glDiscardFramebufferEXT_client_proc_t f) { glDiscardFramebufferEXT_client_proc_t retval = glDiscardFramebufferEXT; glDiscardFramebufferEXT = f; return retval;}
+	virtual glMultiDrawArraysEXT_client_proc_t set_glMultiDrawArraysEXT(glMultiDrawArraysEXT_client_proc_t f) { glMultiDrawArraysEXT_client_proc_t retval = glMultiDrawArraysEXT; glMultiDrawArraysEXT = f; return retval;}
+	virtual glMultiDrawElementsEXT_client_proc_t set_glMultiDrawElementsEXT(glMultiDrawElementsEXT_client_proc_t f) { glMultiDrawElementsEXT_client_proc_t retval = glMultiDrawElementsEXT; glMultiDrawElementsEXT = f; return retval;}
+	virtual glGetPerfMonitorGroupsAMD_client_proc_t set_glGetPerfMonitorGroupsAMD(glGetPerfMonitorGroupsAMD_client_proc_t f) { glGetPerfMonitorGroupsAMD_client_proc_t retval = glGetPerfMonitorGroupsAMD; glGetPerfMonitorGroupsAMD = f; return retval;}
+	virtual glGetPerfMonitorCountersAMD_client_proc_t set_glGetPerfMonitorCountersAMD(glGetPerfMonitorCountersAMD_client_proc_t f) { glGetPerfMonitorCountersAMD_client_proc_t retval = glGetPerfMonitorCountersAMD; glGetPerfMonitorCountersAMD = f; return retval;}
+	virtual glGetPerfMonitorGroupStringAMD_client_proc_t set_glGetPerfMonitorGroupStringAMD(glGetPerfMonitorGroupStringAMD_client_proc_t f) { glGetPerfMonitorGroupStringAMD_client_proc_t retval = glGetPerfMonitorGroupStringAMD; glGetPerfMonitorGroupStringAMD = f; return retval;}
+	virtual glGetPerfMonitorCounterStringAMD_client_proc_t set_glGetPerfMonitorCounterStringAMD(glGetPerfMonitorCounterStringAMD_client_proc_t f) { glGetPerfMonitorCounterStringAMD_client_proc_t retval = glGetPerfMonitorCounterStringAMD; glGetPerfMonitorCounterStringAMD = f; return retval;}
+	virtual glGetPerfMonitorCounterInfoAMD_client_proc_t set_glGetPerfMonitorCounterInfoAMD(glGetPerfMonitorCounterInfoAMD_client_proc_t f) { glGetPerfMonitorCounterInfoAMD_client_proc_t retval = glGetPerfMonitorCounterInfoAMD; glGetPerfMonitorCounterInfoAMD = f; return retval;}
+	virtual glGenPerfMonitorsAMD_client_proc_t set_glGenPerfMonitorsAMD(glGenPerfMonitorsAMD_client_proc_t f) { glGenPerfMonitorsAMD_client_proc_t retval = glGenPerfMonitorsAMD; glGenPerfMonitorsAMD = f; return retval;}
+	virtual glDeletePerfMonitorsAMD_client_proc_t set_glDeletePerfMonitorsAMD(glDeletePerfMonitorsAMD_client_proc_t f) { glDeletePerfMonitorsAMD_client_proc_t retval = glDeletePerfMonitorsAMD; glDeletePerfMonitorsAMD = f; return retval;}
+	virtual glSelectPerfMonitorCountersAMD_client_proc_t set_glSelectPerfMonitorCountersAMD(glSelectPerfMonitorCountersAMD_client_proc_t f) { glSelectPerfMonitorCountersAMD_client_proc_t retval = glSelectPerfMonitorCountersAMD; glSelectPerfMonitorCountersAMD = f; return retval;}
+	virtual glBeginPerfMonitorAMD_client_proc_t set_glBeginPerfMonitorAMD(glBeginPerfMonitorAMD_client_proc_t f) { glBeginPerfMonitorAMD_client_proc_t retval = glBeginPerfMonitorAMD; glBeginPerfMonitorAMD = f; return retval;}
+	virtual glEndPerfMonitorAMD_client_proc_t set_glEndPerfMonitorAMD(glEndPerfMonitorAMD_client_proc_t f) { glEndPerfMonitorAMD_client_proc_t retval = glEndPerfMonitorAMD; glEndPerfMonitorAMD = f; return retval;}
+	virtual glGetPerfMonitorCounterDataAMD_client_proc_t set_glGetPerfMonitorCounterDataAMD(glGetPerfMonitorCounterDataAMD_client_proc_t f) { glGetPerfMonitorCounterDataAMD_client_proc_t retval = glGetPerfMonitorCounterDataAMD; glGetPerfMonitorCounterDataAMD = f; return retval;}
+	virtual glRenderbufferStorageMultisampleIMG_client_proc_t set_glRenderbufferStorageMultisampleIMG(glRenderbufferStorageMultisampleIMG_client_proc_t f) { glRenderbufferStorageMultisampleIMG_client_proc_t retval = glRenderbufferStorageMultisampleIMG; glRenderbufferStorageMultisampleIMG = f; return retval;}
+	virtual glFramebufferTexture2DMultisampleIMG_client_proc_t set_glFramebufferTexture2DMultisampleIMG(glFramebufferTexture2DMultisampleIMG_client_proc_t f) { glFramebufferTexture2DMultisampleIMG_client_proc_t retval = glFramebufferTexture2DMultisampleIMG; glFramebufferTexture2DMultisampleIMG = f; return retval;}
+	virtual glDeleteFencesNV_client_proc_t set_glDeleteFencesNV(glDeleteFencesNV_client_proc_t f) { glDeleteFencesNV_client_proc_t retval = glDeleteFencesNV; glDeleteFencesNV = f; return retval;}
+	virtual glGenFencesNV_client_proc_t set_glGenFencesNV(glGenFencesNV_client_proc_t f) { glGenFencesNV_client_proc_t retval = glGenFencesNV; glGenFencesNV = f; return retval;}
+	virtual glIsFenceNV_client_proc_t set_glIsFenceNV(glIsFenceNV_client_proc_t f) { glIsFenceNV_client_proc_t retval = glIsFenceNV; glIsFenceNV = f; return retval;}
+	virtual glTestFenceNV_client_proc_t set_glTestFenceNV(glTestFenceNV_client_proc_t f) { glTestFenceNV_client_proc_t retval = glTestFenceNV; glTestFenceNV = f; return retval;}
+	virtual glGetFenceivNV_client_proc_t set_glGetFenceivNV(glGetFenceivNV_client_proc_t f) { glGetFenceivNV_client_proc_t retval = glGetFenceivNV; glGetFenceivNV = f; return retval;}
+	virtual glFinishFenceNV_client_proc_t set_glFinishFenceNV(glFinishFenceNV_client_proc_t f) { glFinishFenceNV_client_proc_t retval = glFinishFenceNV; glFinishFenceNV = f; return retval;}
+	virtual glSetFenceNV_client_proc_t set_glSetFenceNV(glSetFenceNV_client_proc_t f) { glSetFenceNV_client_proc_t retval = glSetFenceNV; glSetFenceNV = f; return retval;}
+	virtual glCoverageMaskNV_client_proc_t set_glCoverageMaskNV(glCoverageMaskNV_client_proc_t f) { glCoverageMaskNV_client_proc_t retval = glCoverageMaskNV; glCoverageMaskNV = f; return retval;}
+	virtual glCoverageOperationNV_client_proc_t set_glCoverageOperationNV(glCoverageOperationNV_client_proc_t f) { glCoverageOperationNV_client_proc_t retval = glCoverageOperationNV; glCoverageOperationNV = f; return retval;}
+	virtual glGetDriverControlsQCOM_client_proc_t set_glGetDriverControlsQCOM(glGetDriverControlsQCOM_client_proc_t f) { glGetDriverControlsQCOM_client_proc_t retval = glGetDriverControlsQCOM; glGetDriverControlsQCOM = f; return retval;}
+	virtual glGetDriverControlStringQCOM_client_proc_t set_glGetDriverControlStringQCOM(glGetDriverControlStringQCOM_client_proc_t f) { glGetDriverControlStringQCOM_client_proc_t retval = glGetDriverControlStringQCOM; glGetDriverControlStringQCOM = f; return retval;}
+	virtual glEnableDriverControlQCOM_client_proc_t set_glEnableDriverControlQCOM(glEnableDriverControlQCOM_client_proc_t f) { glEnableDriverControlQCOM_client_proc_t retval = glEnableDriverControlQCOM; glEnableDriverControlQCOM = f; return retval;}
+	virtual glDisableDriverControlQCOM_client_proc_t set_glDisableDriverControlQCOM(glDisableDriverControlQCOM_client_proc_t f) { glDisableDriverControlQCOM_client_proc_t retval = glDisableDriverControlQCOM; glDisableDriverControlQCOM = f; return retval;}
+	virtual glExtGetTexturesQCOM_client_proc_t set_glExtGetTexturesQCOM(glExtGetTexturesQCOM_client_proc_t f) { glExtGetTexturesQCOM_client_proc_t retval = glExtGetTexturesQCOM; glExtGetTexturesQCOM = f; return retval;}
+	virtual glExtGetBuffersQCOM_client_proc_t set_glExtGetBuffersQCOM(glExtGetBuffersQCOM_client_proc_t f) { glExtGetBuffersQCOM_client_proc_t retval = glExtGetBuffersQCOM; glExtGetBuffersQCOM = f; return retval;}
+	virtual glExtGetRenderbuffersQCOM_client_proc_t set_glExtGetRenderbuffersQCOM(glExtGetRenderbuffersQCOM_client_proc_t f) { glExtGetRenderbuffersQCOM_client_proc_t retval = glExtGetRenderbuffersQCOM; glExtGetRenderbuffersQCOM = f; return retval;}
+	virtual glExtGetFramebuffersQCOM_client_proc_t set_glExtGetFramebuffersQCOM(glExtGetFramebuffersQCOM_client_proc_t f) { glExtGetFramebuffersQCOM_client_proc_t retval = glExtGetFramebuffersQCOM; glExtGetFramebuffersQCOM = f; return retval;}
+	virtual glExtGetTexLevelParameterivQCOM_client_proc_t set_glExtGetTexLevelParameterivQCOM(glExtGetTexLevelParameterivQCOM_client_proc_t f) { glExtGetTexLevelParameterivQCOM_client_proc_t retval = glExtGetTexLevelParameterivQCOM; glExtGetTexLevelParameterivQCOM = f; return retval;}
+	virtual glExtTexObjectStateOverrideiQCOM_client_proc_t set_glExtTexObjectStateOverrideiQCOM(glExtTexObjectStateOverrideiQCOM_client_proc_t f) { glExtTexObjectStateOverrideiQCOM_client_proc_t retval = glExtTexObjectStateOverrideiQCOM; glExtTexObjectStateOverrideiQCOM = f; return retval;}
+	virtual glExtGetTexSubImageQCOM_client_proc_t set_glExtGetTexSubImageQCOM(glExtGetTexSubImageQCOM_client_proc_t f) { glExtGetTexSubImageQCOM_client_proc_t retval = glExtGetTexSubImageQCOM; glExtGetTexSubImageQCOM = f; return retval;}
+	virtual glExtGetBufferPointervQCOM_client_proc_t set_glExtGetBufferPointervQCOM(glExtGetBufferPointervQCOM_client_proc_t f) { glExtGetBufferPointervQCOM_client_proc_t retval = glExtGetBufferPointervQCOM; glExtGetBufferPointervQCOM = f; return retval;}
+	virtual glExtGetShadersQCOM_client_proc_t set_glExtGetShadersQCOM(glExtGetShadersQCOM_client_proc_t f) { glExtGetShadersQCOM_client_proc_t retval = glExtGetShadersQCOM; glExtGetShadersQCOM = f; return retval;}
+	virtual glExtGetProgramsQCOM_client_proc_t set_glExtGetProgramsQCOM(glExtGetProgramsQCOM_client_proc_t f) { glExtGetProgramsQCOM_client_proc_t retval = glExtGetProgramsQCOM; glExtGetProgramsQCOM = f; return retval;}
+	virtual glExtIsProgramBinaryQCOM_client_proc_t set_glExtIsProgramBinaryQCOM(glExtIsProgramBinaryQCOM_client_proc_t f) { glExtIsProgramBinaryQCOM_client_proc_t retval = glExtIsProgramBinaryQCOM; glExtIsProgramBinaryQCOM = f; return retval;}
+	virtual glExtGetProgramBinarySourceQCOM_client_proc_t set_glExtGetProgramBinarySourceQCOM(glExtGetProgramBinarySourceQCOM_client_proc_t f) { glExtGetProgramBinarySourceQCOM_client_proc_t retval = glExtGetProgramBinarySourceQCOM; glExtGetProgramBinarySourceQCOM = f; return retval;}
+	virtual glStartTilingQCOM_client_proc_t set_glStartTilingQCOM(glStartTilingQCOM_client_proc_t f) { glStartTilingQCOM_client_proc_t retval = glStartTilingQCOM; glStartTilingQCOM = f; return retval;}
+	virtual glEndTilingQCOM_client_proc_t set_glEndTilingQCOM(glEndTilingQCOM_client_proc_t f) { glEndTilingQCOM_client_proc_t retval = glEndTilingQCOM; glEndTilingQCOM = f; return retval;}
+	virtual glVertexAttribPointerData_client_proc_t set_glVertexAttribPointerData(glVertexAttribPointerData_client_proc_t f) { glVertexAttribPointerData_client_proc_t retval = glVertexAttribPointerData; glVertexAttribPointerData = f; return retval;}
+	virtual glVertexAttribPointerOffset_client_proc_t set_glVertexAttribPointerOffset(glVertexAttribPointerOffset_client_proc_t f) { glVertexAttribPointerOffset_client_proc_t retval = glVertexAttribPointerOffset; glVertexAttribPointerOffset = f; return retval;}
+	virtual glDrawElementsOffset_client_proc_t set_glDrawElementsOffset(glDrawElementsOffset_client_proc_t f) { glDrawElementsOffset_client_proc_t retval = glDrawElementsOffset; glDrawElementsOffset = f; return retval;}
+	virtual glDrawElementsData_client_proc_t set_glDrawElementsData(glDrawElementsData_client_proc_t f) { glDrawElementsData_client_proc_t retval = glDrawElementsData; glDrawElementsData = f; return retval;}
+	virtual glGetCompressedTextureFormats_client_proc_t set_glGetCompressedTextureFormats(glGetCompressedTextureFormats_client_proc_t f) { glGetCompressedTextureFormats_client_proc_t retval = glGetCompressedTextureFormats; glGetCompressedTextureFormats = f; return retval;}
+	virtual glShaderString_client_proc_t set_glShaderString(glShaderString_client_proc_t f) { glShaderString_client_proc_t retval = glShaderString; glShaderString = f; return retval;}
+	virtual glFinishRoundTrip_client_proc_t set_glFinishRoundTrip(glFinishRoundTrip_client_proc_t f) { glFinishRoundTrip_client_proc_t retval = glFinishRoundTrip; glFinishRoundTrip = f; return retval;}
+	 virtual ~gl2_client_context_t() {}
+
+	typedef gl2_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
+	static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
+	int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+	virtual void setError(unsigned int  error){};
+	virtual unsigned int getError(){ return 0; };
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_client_proc.h b/tools/emulator/opengl/system/GLESv2_enc/gl2_client_proc.h
new file mode 100644
index 0000000..b8ff005
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_client_proc.h
@@ -0,0 +1,222 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __gl2_client_proc_t_h
+#define __gl2_client_proc_t_h
+
+
+
+#include "gl2_types.h"
+#ifndef gl2_APIENTRY
+#define gl2_APIENTRY 
+#endif
+typedef void (gl2_APIENTRY *glActiveTexture_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glAttachShader_client_proc_t) (void * ctx, GLuint, GLuint);
+typedef void (gl2_APIENTRY *glBindAttribLocation_client_proc_t) (void * ctx, GLuint, GLuint, const GLchar*);
+typedef void (gl2_APIENTRY *glBindBuffer_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl2_APIENTRY *glBindFramebuffer_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl2_APIENTRY *glBindRenderbuffer_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl2_APIENTRY *glBindTexture_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl2_APIENTRY *glBlendColor_client_proc_t) (void * ctx, GLclampf, GLclampf, GLclampf, GLclampf);
+typedef void (gl2_APIENTRY *glBlendEquation_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glBlendEquationSeparate_client_proc_t) (void * ctx, GLenum, GLenum);
+typedef void (gl2_APIENTRY *glBlendFunc_client_proc_t) (void * ctx, GLenum, GLenum);
+typedef void (gl2_APIENTRY *glBlendFuncSeparate_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLenum);
+typedef void (gl2_APIENTRY *glBufferData_client_proc_t) (void * ctx, GLenum, GLsizeiptr, const GLvoid*, GLenum);
+typedef void (gl2_APIENTRY *glBufferSubData_client_proc_t) (void * ctx, GLenum, GLintptr, GLsizeiptr, const GLvoid*);
+typedef GLenum (gl2_APIENTRY *glCheckFramebufferStatus_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glClear_client_proc_t) (void * ctx, GLbitfield);
+typedef void (gl2_APIENTRY *glClearColor_client_proc_t) (void * ctx, GLclampf, GLclampf, GLclampf, GLclampf);
+typedef void (gl2_APIENTRY *glClearDepthf_client_proc_t) (void * ctx, GLclampf);
+typedef void (gl2_APIENTRY *glClearStencil_client_proc_t) (void * ctx, GLint);
+typedef void (gl2_APIENTRY *glColorMask_client_proc_t) (void * ctx, GLboolean, GLboolean, GLboolean, GLboolean);
+typedef void (gl2_APIENTRY *glCompileShader_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glCompressedTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*);
+typedef void (gl2_APIENTRY *glCompressedTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*);
+typedef void (gl2_APIENTRY *glCopyTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+typedef void (gl2_APIENTRY *glCopyTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+typedef GLuint (gl2_APIENTRY *glCreateProgram_client_proc_t) (void * ctx);
+typedef GLuint (gl2_APIENTRY *glCreateShader_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glCullFace_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glDeleteBuffers_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl2_APIENTRY *glDeleteFramebuffers_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl2_APIENTRY *glDeleteProgram_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glDeleteRenderbuffers_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl2_APIENTRY *glDeleteShader_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glDeleteTextures_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl2_APIENTRY *glDepthFunc_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glDepthMask_client_proc_t) (void * ctx, GLboolean);
+typedef void (gl2_APIENTRY *glDepthRangef_client_proc_t) (void * ctx, GLclampf, GLclampf);
+typedef void (gl2_APIENTRY *glDetachShader_client_proc_t) (void * ctx, GLuint, GLuint);
+typedef void (gl2_APIENTRY *glDisable_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glDisableVertexAttribArray_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glDrawArrays_client_proc_t) (void * ctx, GLenum, GLint, GLsizei);
+typedef void (gl2_APIENTRY *glDrawElements_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, const GLvoid*);
+typedef void (gl2_APIENTRY *glEnable_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glEnableVertexAttribArray_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glFinish_client_proc_t) (void * ctx);
+typedef void (gl2_APIENTRY *glFlush_client_proc_t) (void * ctx);
+typedef void (gl2_APIENTRY *glFramebufferRenderbuffer_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint);
+typedef void (gl2_APIENTRY *glFramebufferTexture2D_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint);
+typedef void (gl2_APIENTRY *glFrontFace_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glGenBuffers_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glGenerateMipmap_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glGenFramebuffers_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glGenRenderbuffers_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glGenTextures_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glGetActiveAttrib_client_proc_t) (void * ctx, GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);
+typedef void (gl2_APIENTRY *glGetActiveUniform_client_proc_t) (void * ctx, GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);
+typedef void (gl2_APIENTRY *glGetAttachedShaders_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLuint*);
+typedef int (gl2_APIENTRY *glGetAttribLocation_client_proc_t) (void * ctx, GLuint, const GLchar*);
+typedef void (gl2_APIENTRY *glGetBooleanv_client_proc_t) (void * ctx, GLenum, GLboolean*);
+typedef void (gl2_APIENTRY *glGetBufferParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*);
+typedef GLenum (gl2_APIENTRY *glGetError_client_proc_t) (void * ctx);
+typedef void (gl2_APIENTRY *glGetFloatv_client_proc_t) (void * ctx, GLenum, GLfloat*);
+typedef void (gl2_APIENTRY *glGetFramebufferAttachmentParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glGetIntegerv_client_proc_t) (void * ctx, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glGetProgramiv_client_proc_t) (void * ctx, GLuint, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glGetProgramInfoLog_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*);
+typedef void (gl2_APIENTRY *glGetRenderbufferParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glGetShaderiv_client_proc_t) (void * ctx, GLuint, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glGetShaderInfoLog_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*);
+typedef void (gl2_APIENTRY *glGetShaderPrecisionFormat_client_proc_t) (void * ctx, GLenum, GLenum, GLint*, GLint*);
+typedef void (gl2_APIENTRY *glGetShaderSource_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*);
+typedef const GLubyte* (gl2_APIENTRY *glGetString_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glGetTexParameterfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*);
+typedef void (gl2_APIENTRY *glGetTexParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glGetUniformfv_client_proc_t) (void * ctx, GLuint, GLint, GLfloat*);
+typedef void (gl2_APIENTRY *glGetUniformiv_client_proc_t) (void * ctx, GLuint, GLint, GLint*);
+typedef int (gl2_APIENTRY *glGetUniformLocation_client_proc_t) (void * ctx, GLuint, const GLchar*);
+typedef void (gl2_APIENTRY *glGetVertexAttribfv_client_proc_t) (void * ctx, GLuint, GLenum, GLfloat*);
+typedef void (gl2_APIENTRY *glGetVertexAttribiv_client_proc_t) (void * ctx, GLuint, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glGetVertexAttribPointerv_client_proc_t) (void * ctx, GLuint, GLenum, GLvoid**);
+typedef void (gl2_APIENTRY *glHint_client_proc_t) (void * ctx, GLenum, GLenum);
+typedef GLboolean (gl2_APIENTRY *glIsBuffer_client_proc_t) (void * ctx, GLuint);
+typedef GLboolean (gl2_APIENTRY *glIsEnabled_client_proc_t) (void * ctx, GLenum);
+typedef GLboolean (gl2_APIENTRY *glIsFramebuffer_client_proc_t) (void * ctx, GLuint);
+typedef GLboolean (gl2_APIENTRY *glIsProgram_client_proc_t) (void * ctx, GLuint);
+typedef GLboolean (gl2_APIENTRY *glIsRenderbuffer_client_proc_t) (void * ctx, GLuint);
+typedef GLboolean (gl2_APIENTRY *glIsShader_client_proc_t) (void * ctx, GLuint);
+typedef GLboolean (gl2_APIENTRY *glIsTexture_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glLineWidth_client_proc_t) (void * ctx, GLfloat);
+typedef void (gl2_APIENTRY *glLinkProgram_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glPixelStorei_client_proc_t) (void * ctx, GLenum, GLint);
+typedef void (gl2_APIENTRY *glPolygonOffset_client_proc_t) (void * ctx, GLfloat, GLfloat);
+typedef void (gl2_APIENTRY *glReadPixels_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*);
+typedef void (gl2_APIENTRY *glReleaseShaderCompiler_client_proc_t) (void * ctx);
+typedef void (gl2_APIENTRY *glRenderbufferStorage_client_proc_t) (void * ctx, GLenum, GLenum, GLsizei, GLsizei);
+typedef void (gl2_APIENTRY *glSampleCoverage_client_proc_t) (void * ctx, GLclampf, GLboolean);
+typedef void (gl2_APIENTRY *glScissor_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei);
+typedef void (gl2_APIENTRY *glShaderBinary_client_proc_t) (void * ctx, GLsizei, const GLuint*, GLenum, const GLvoid*, GLsizei);
+typedef void (gl2_APIENTRY *glShaderSource_client_proc_t) (void * ctx, GLuint, GLsizei, const GLchar**, const GLint*);
+typedef void (gl2_APIENTRY *glStencilFunc_client_proc_t) (void * ctx, GLenum, GLint, GLuint);
+typedef void (gl2_APIENTRY *glStencilFuncSeparate_client_proc_t) (void * ctx, GLenum, GLenum, GLint, GLuint);
+typedef void (gl2_APIENTRY *glStencilMask_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glStencilMaskSeparate_client_proc_t) (void * ctx, GLenum, GLuint);
+typedef void (gl2_APIENTRY *glStencilOp_client_proc_t) (void * ctx, GLenum, GLenum, GLenum);
+typedef void (gl2_APIENTRY *glStencilOpSeparate_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLenum);
+typedef void (gl2_APIENTRY *glTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*);
+typedef void (gl2_APIENTRY *glTexParameterf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat);
+typedef void (gl2_APIENTRY *glTexParameterfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*);
+typedef void (gl2_APIENTRY *glTexParameteri_client_proc_t) (void * ctx, GLenum, GLenum, GLint);
+typedef void (gl2_APIENTRY *glTexParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, const GLint*);
+typedef void (gl2_APIENTRY *glTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*);
+typedef void (gl2_APIENTRY *glUniform1f_client_proc_t) (void * ctx, GLint, GLfloat);
+typedef void (gl2_APIENTRY *glUniform1fv_client_proc_t) (void * ctx, GLint, GLsizei, const GLfloat*);
+typedef void (gl2_APIENTRY *glUniform1i_client_proc_t) (void * ctx, GLint, GLint);
+typedef void (gl2_APIENTRY *glUniform1iv_client_proc_t) (void * ctx, GLint, GLsizei, const GLint*);
+typedef void (gl2_APIENTRY *glUniform2f_client_proc_t) (void * ctx, GLint, GLfloat, GLfloat);
+typedef void (gl2_APIENTRY *glUniform2fv_client_proc_t) (void * ctx, GLint, GLsizei, const GLfloat*);
+typedef void (gl2_APIENTRY *glUniform2i_client_proc_t) (void * ctx, GLint, GLint, GLint);
+typedef void (gl2_APIENTRY *glUniform2iv_client_proc_t) (void * ctx, GLint, GLsizei, const GLint*);
+typedef void (gl2_APIENTRY *glUniform3f_client_proc_t) (void * ctx, GLint, GLfloat, GLfloat, GLfloat);
+typedef void (gl2_APIENTRY *glUniform3fv_client_proc_t) (void * ctx, GLint, GLsizei, const GLfloat*);
+typedef void (gl2_APIENTRY *glUniform3i_client_proc_t) (void * ctx, GLint, GLint, GLint, GLint);
+typedef void (gl2_APIENTRY *glUniform3iv_client_proc_t) (void * ctx, GLint, GLsizei, const GLint*);
+typedef void (gl2_APIENTRY *glUniform4f_client_proc_t) (void * ctx, GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl2_APIENTRY *glUniform4fv_client_proc_t) (void * ctx, GLint, GLsizei, const GLfloat*);
+typedef void (gl2_APIENTRY *glUniform4i_client_proc_t) (void * ctx, GLint, GLint, GLint, GLint, GLint);
+typedef void (gl2_APIENTRY *glUniform4iv_client_proc_t) (void * ctx, GLint, GLsizei, const GLint*);
+typedef void (gl2_APIENTRY *glUniformMatrix2fv_client_proc_t) (void * ctx, GLint, GLsizei, GLboolean, const GLfloat*);
+typedef void (gl2_APIENTRY *glUniformMatrix3fv_client_proc_t) (void * ctx, GLint, GLsizei, GLboolean, const GLfloat*);
+typedef void (gl2_APIENTRY *glUniformMatrix4fv_client_proc_t) (void * ctx, GLint, GLsizei, GLboolean, const GLfloat*);
+typedef void (gl2_APIENTRY *glUseProgram_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glValidateProgram_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glVertexAttrib1f_client_proc_t) (void * ctx, GLuint, GLfloat);
+typedef void (gl2_APIENTRY *glVertexAttrib1fv_client_proc_t) (void * ctx, GLuint, const GLfloat*);
+typedef void (gl2_APIENTRY *glVertexAttrib2f_client_proc_t) (void * ctx, GLuint, GLfloat, GLfloat);
+typedef void (gl2_APIENTRY *glVertexAttrib2fv_client_proc_t) (void * ctx, GLuint, const GLfloat*);
+typedef void (gl2_APIENTRY *glVertexAttrib3f_client_proc_t) (void * ctx, GLuint, GLfloat, GLfloat, GLfloat);
+typedef void (gl2_APIENTRY *glVertexAttrib3fv_client_proc_t) (void * ctx, GLuint, const GLfloat*);
+typedef void (gl2_APIENTRY *glVertexAttrib4f_client_proc_t) (void * ctx, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (gl2_APIENTRY *glVertexAttrib4fv_client_proc_t) (void * ctx, GLuint, const GLfloat*);
+typedef void (gl2_APIENTRY *glVertexAttribPointer_client_proc_t) (void * ctx, GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*);
+typedef void (gl2_APIENTRY *glViewport_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei);
+typedef void (gl2_APIENTRY *glEGLImageTargetTexture2DOES_client_proc_t) (void * ctx, GLenum, GLeglImageOES);
+typedef void (gl2_APIENTRY *glEGLImageTargetRenderbufferStorageOES_client_proc_t) (void * ctx, GLenum, GLeglImageOES);
+typedef void (gl2_APIENTRY *glGetProgramBinaryOES_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLenum*, GLvoid*);
+typedef void (gl2_APIENTRY *glProgramBinaryOES_client_proc_t) (void * ctx, GLuint, GLenum, const GLvoid*, GLint);
+typedef void* (gl2_APIENTRY *glMapBufferOES_client_proc_t) (void * ctx, GLenum, GLenum);
+typedef GLboolean (gl2_APIENTRY *glUnmapBufferOES_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glTexImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*);
+typedef void (gl2_APIENTRY *glTexSubImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*);
+typedef void (gl2_APIENTRY *glCopyTexSubImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+typedef void (gl2_APIENTRY *glCompressedTexImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*);
+typedef void (gl2_APIENTRY *glCompressedTexSubImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*);
+typedef void (gl2_APIENTRY *glFramebufferTexture3DOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint, GLint);
+typedef void (gl2_APIENTRY *glBindVertexArrayOES_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glDeleteVertexArraysOES_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl2_APIENTRY *glGenVertexArraysOES_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef GLboolean (gl2_APIENTRY *glIsVertexArrayOES_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glDiscardFramebufferEXT_client_proc_t) (void * ctx, GLenum, GLsizei, const GLenum*);
+typedef void (gl2_APIENTRY *glMultiDrawArraysEXT_client_proc_t) (void * ctx, GLenum, GLint*, GLsizei*, GLsizei);
+typedef void (gl2_APIENTRY *glMultiDrawElementsEXT_client_proc_t) (void * ctx, GLenum, const GLsizei*, GLenum, const GLvoid**, GLsizei);
+typedef void (gl2_APIENTRY *glGetPerfMonitorGroupsAMD_client_proc_t) (void * ctx, GLint*, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glGetPerfMonitorCountersAMD_client_proc_t) (void * ctx, GLuint, GLint*, GLint*, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glGetPerfMonitorGroupStringAMD_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*);
+typedef void (gl2_APIENTRY *glGetPerfMonitorCounterStringAMD_client_proc_t) (void * ctx, GLuint, GLuint, GLsizei, GLsizei*, GLchar*);
+typedef void (gl2_APIENTRY *glGetPerfMonitorCounterInfoAMD_client_proc_t) (void * ctx, GLuint, GLuint, GLenum, GLvoid*);
+typedef void (gl2_APIENTRY *glGenPerfMonitorsAMD_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glDeletePerfMonitorsAMD_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glSelectPerfMonitorCountersAMD_client_proc_t) (void * ctx, GLuint, GLboolean, GLuint, GLint, GLuint*);
+typedef void (gl2_APIENTRY *glBeginPerfMonitorAMD_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glEndPerfMonitorAMD_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glGetPerfMonitorCounterDataAMD_client_proc_t) (void * ctx, GLuint, GLenum, GLsizei, GLuint*, GLint*);
+typedef void (gl2_APIENTRY *glRenderbufferStorageMultisampleIMG_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+typedef void (gl2_APIENTRY *glFramebufferTexture2DMultisampleIMG_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+typedef void (gl2_APIENTRY *glDeleteFencesNV_client_proc_t) (void * ctx, GLsizei, const GLuint*);
+typedef void (gl2_APIENTRY *glGenFencesNV_client_proc_t) (void * ctx, GLsizei, GLuint*);
+typedef GLboolean (gl2_APIENTRY *glIsFenceNV_client_proc_t) (void * ctx, GLuint);
+typedef GLboolean (gl2_APIENTRY *glTestFenceNV_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glGetFenceivNV_client_proc_t) (void * ctx, GLuint, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glFinishFenceNV_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glSetFenceNV_client_proc_t) (void * ctx, GLuint, GLenum);
+typedef void (gl2_APIENTRY *glCoverageMaskNV_client_proc_t) (void * ctx, GLboolean);
+typedef void (gl2_APIENTRY *glCoverageOperationNV_client_proc_t) (void * ctx, GLenum);
+typedef void (gl2_APIENTRY *glGetDriverControlsQCOM_client_proc_t) (void * ctx, GLint*, GLsizei, GLuint*);
+typedef void (gl2_APIENTRY *glGetDriverControlStringQCOM_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*);
+typedef void (gl2_APIENTRY *glEnableDriverControlQCOM_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glDisableDriverControlQCOM_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glExtGetTexturesQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl2_APIENTRY *glExtGetBuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl2_APIENTRY *glExtGetRenderbuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl2_APIENTRY *glExtGetFramebuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl2_APIENTRY *glExtGetTexLevelParameterivQCOM_client_proc_t) (void * ctx, GLuint, GLenum, GLint, GLenum, GLint*);
+typedef void (gl2_APIENTRY *glExtTexObjectStateOverrideiQCOM_client_proc_t) (void * ctx, GLenum, GLenum, GLint);
+typedef void (gl2_APIENTRY *glExtGetTexSubImageQCOM_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoid*);
+typedef void (gl2_APIENTRY *glExtGetBufferPointervQCOM_client_proc_t) (void * ctx, GLenum, GLvoidptr*);
+typedef void (gl2_APIENTRY *glExtGetShadersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef void (gl2_APIENTRY *glExtGetProgramsQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*);
+typedef GLboolean (gl2_APIENTRY *glExtIsProgramBinaryQCOM_client_proc_t) (void * ctx, GLuint);
+typedef void (gl2_APIENTRY *glExtGetProgramBinarySourceQCOM_client_proc_t) (void * ctx, GLuint, GLenum, GLchar*, GLint*);
+typedef void (gl2_APIENTRY *glStartTilingQCOM_client_proc_t) (void * ctx, GLuint, GLuint, GLuint, GLuint, GLbitfield);
+typedef void (gl2_APIENTRY *glEndTilingQCOM_client_proc_t) (void * ctx, GLbitfield);
+typedef void (gl2_APIENTRY *glVertexAttribPointerData_client_proc_t) (void * ctx, GLuint, GLint, GLenum, GLboolean, GLsizei, void*, GLuint);
+typedef void (gl2_APIENTRY *glVertexAttribPointerOffset_client_proc_t) (void * ctx, GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint);
+typedef void (gl2_APIENTRY *glDrawElementsOffset_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, GLuint);
+typedef void (gl2_APIENTRY *glDrawElementsData_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, void*, GLuint);
+typedef void (gl2_APIENTRY *glGetCompressedTextureFormats_client_proc_t) (void * ctx, int, GLint*);
+typedef void (gl2_APIENTRY *glShaderString_client_proc_t) (void * ctx, GLuint, const GLchar*, GLsizei);
+typedef int (gl2_APIENTRY *glFinishRoundTrip_client_proc_t) (void * ctx);
+
+
+#endif
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_enc.cpp b/tools/emulator/opengl/system/GLESv2_enc/gl2_enc.cpp
new file mode 100644
index 0000000..46684e9
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_enc.cpp
@@ -0,0 +1,3130 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "gl2_opcodes.h"
+
+#include "gl2_enc.h"
+
+
+#include <stdio.h>
+static void enc_unsupported()
+{
+	ALOGE("Function is unsupported\n");
+}
+
+void glActiveTexture_enc(void *self , GLenum texture)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glActiveTexture;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &texture, 4); ptr += 4;
+}
+
+void glAttachShader_enc(void *self , GLuint program, GLuint shader)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glAttachShader;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &shader, 4); ptr += 4;
+}
+
+void glBindAttribLocation_enc(void *self , GLuint program, GLuint index, const GLchar* name)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_name =  (strlen(name) + 1);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_name + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindAttribLocation;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &index, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_name; ptr += 4;
+	memcpy(ptr, name, __size_name);ptr += __size_name;
+}
+
+void glBindBuffer_enc(void *self , GLenum target, GLuint buffer)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &buffer, 4); ptr += 4;
+}
+
+void glBindFramebuffer_enc(void *self , GLenum target, GLuint framebuffer)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindFramebuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &framebuffer, 4); ptr += 4;
+}
+
+void glBindRenderbuffer_enc(void *self , GLenum target, GLuint renderbuffer)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &renderbuffer, 4); ptr += 4;
+}
+
+void glBindTexture_enc(void *self , GLenum target, GLuint texture)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindTexture;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &texture, 4); ptr += 4;
+}
+
+void glBlendColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendColor;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 4); ptr += 4;
+		memcpy(ptr, &green, 4); ptr += 4;
+		memcpy(ptr, &blue, 4); ptr += 4;
+		memcpy(ptr, &alpha, 4); ptr += 4;
+}
+
+void glBlendEquation_enc(void *self , GLenum mode)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendEquation;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+void glBlendEquationSeparate_enc(void *self , GLenum modeRGB, GLenum modeAlpha)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendEquationSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &modeRGB, 4); ptr += 4;
+		memcpy(ptr, &modeAlpha, 4); ptr += 4;
+}
+
+void glBlendFunc_enc(void *self , GLenum sfactor, GLenum dfactor)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &sfactor, 4); ptr += 4;
+		memcpy(ptr, &dfactor, 4); ptr += 4;
+}
+
+void glBlendFuncSeparate_enc(void *self , GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBlendFuncSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &srcRGB, 4); ptr += 4;
+		memcpy(ptr, &dstRGB, 4); ptr += 4;
+		memcpy(ptr, &srcAlpha, 4); ptr += 4;
+		memcpy(ptr, &dstAlpha, 4); ptr += 4;
+}
+
+void glBufferData_enc(void *self , GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data = ((data != NULL) ?  size : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(8 + 4 + 4);
+	int tmp = OP_glBufferData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &size, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_data,4);
+	if (data != NULL) stream->writeFully(data, __size_data);
+	ptr = stream->alloc(4);
+		memcpy(ptr, &usage, 4); ptr += 4;
+}
+
+void glBufferSubData_enc(void *self , GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  size;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_data + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4);
+	int tmp = OP_glBufferSubData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+		memcpy(ptr, &size, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_data,4);
+	stream->writeFully(data, __size_data);
+}
+
+GLenum glCheckFramebufferStatus_enc(void *self , GLenum target)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCheckFramebufferStatus;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+
+	GLenum retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glClear_enc(void *self , GLbitfield mask)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClear;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mask, 4); ptr += 4;
+}
+
+void glClearColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearColor;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 4); ptr += 4;
+		memcpy(ptr, &green, 4); ptr += 4;
+		memcpy(ptr, &blue, 4); ptr += 4;
+		memcpy(ptr, &alpha, 4); ptr += 4;
+}
+
+void glClearDepthf_enc(void *self , GLclampf depth)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearDepthf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &depth, 4); ptr += 4;
+}
+
+void glClearStencil_enc(void *self , GLint s)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glClearStencil;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &s, 4); ptr += 4;
+}
+
+void glColorMask_enc(void *self , GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 1 + 1 + 1 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glColorMask;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &red, 1); ptr += 1;
+		memcpy(ptr, &green, 1); ptr += 1;
+		memcpy(ptr, &blue, 1); ptr += 1;
+		memcpy(ptr, &alpha, 1); ptr += 1;
+}
+
+void glCompileShader_enc(void *self , GLuint shader)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCompileShader;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &shader, 4); ptr += 4;
+}
+
+void glCompressedTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data = ((data != NULL) ?  imageSize : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glCompressedTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &border, 4); ptr += 4;
+		memcpy(ptr, &imageSize, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_data,4);
+	if (data != NULL) stream->writeFully(data, __size_data);
+}
+
+void glCompressedTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  imageSize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glCompressedTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &imageSize, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_data,4);
+	stream->writeFully(data, __size_data);
+}
+
+void glCopyTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCopyTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &border, 4); ptr += 4;
+}
+
+void glCopyTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCopyTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+GLuint glCreateProgram_enc(void *self )
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCreateProgram;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+
+	GLuint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+GLuint glCreateShader_enc(void *self , GLenum type)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCreateShader;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &type, 4); ptr += 4;
+
+	GLuint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glCullFace_enc(void *self , GLenum mode)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCullFace;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+void glDeleteBuffers_enc(void *self , GLsizei n, const GLuint* buffers)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_buffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_buffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteBuffers;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_buffers; ptr += 4;
+	memcpy(ptr, buffers, __size_buffers);ptr += __size_buffers;
+}
+
+void glDeleteFramebuffers_enc(void *self , GLsizei n, const GLuint* framebuffers)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_framebuffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_framebuffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteFramebuffers;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_framebuffers; ptr += 4;
+	memcpy(ptr, framebuffers, __size_framebuffers);ptr += __size_framebuffers;
+}
+
+void glDeleteProgram_enc(void *self , GLuint program)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteProgram;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+}
+
+void glDeleteRenderbuffers_enc(void *self , GLsizei n, const GLuint* renderbuffers)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_renderbuffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_renderbuffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteRenderbuffers;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4;
+	memcpy(ptr, renderbuffers, __size_renderbuffers);ptr += __size_renderbuffers;
+}
+
+void glDeleteShader_enc(void *self , GLuint shader)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteShader;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &shader, 4); ptr += 4;
+}
+
+void glDeleteTextures_enc(void *self , GLsizei n, const GLuint* textures)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_textures =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_textures + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteTextures;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_textures; ptr += 4;
+	memcpy(ptr, textures, __size_textures);ptr += __size_textures;
+}
+
+void glDepthFunc_enc(void *self , GLenum func)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &func, 4); ptr += 4;
+}
+
+void glDepthMask_enc(void *self , GLboolean flag)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthMask;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &flag, 1); ptr += 1;
+}
+
+void glDepthRangef_enc(void *self , GLclampf zNear, GLclampf zFar)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDepthRangef;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &zNear, 4); ptr += 4;
+		memcpy(ptr, &zFar, 4); ptr += 4;
+}
+
+void glDetachShader_enc(void *self , GLuint program, GLuint shader)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDetachShader;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &shader, 4); ptr += 4;
+}
+
+void glDisable_enc(void *self , GLenum cap)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDisable;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &cap, 4); ptr += 4;
+}
+
+void glDisableVertexAttribArray_enc(void *self , GLuint index)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDisableVertexAttribArray;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &index, 4); ptr += 4;
+}
+
+void glDrawArrays_enc(void *self , GLenum mode, GLint first, GLsizei count)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawArrays;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+		memcpy(ptr, &first, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+}
+
+void glEnable_enc(void *self , GLenum cap)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEnable;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &cap, 4); ptr += 4;
+}
+
+void glEnableVertexAttribArray_enc(void *self , GLuint index)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEnableVertexAttribArray;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &index, 4); ptr += 4;
+}
+
+void glFinish_enc(void *self )
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFinish;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+void glFlush_enc(void *self )
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFlush;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+void glFramebufferRenderbuffer_enc(void *self , GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFramebufferRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &attachment, 4); ptr += 4;
+		memcpy(ptr, &renderbuffertarget, 4); ptr += 4;
+		memcpy(ptr, &renderbuffer, 4); ptr += 4;
+}
+
+void glFramebufferTexture2D_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFramebufferTexture2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &attachment, 4); ptr += 4;
+		memcpy(ptr, &textarget, 4); ptr += 4;
+		memcpy(ptr, &texture, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+}
+
+void glFrontFace_enc(void *self , GLenum mode)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFrontFace;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+void glGenBuffers_enc(void *self , GLsizei n, GLuint* buffers)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_buffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_buffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenBuffers;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_buffers; ptr += 4;
+	stream->readback(buffers, __size_buffers);
+}
+
+void glGenerateMipmap_enc(void *self , GLenum target)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenerateMipmap;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+}
+
+void glGenFramebuffers_enc(void *self , GLsizei n, GLuint* framebuffers)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_framebuffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_framebuffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenFramebuffers;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_framebuffers; ptr += 4;
+	stream->readback(framebuffers, __size_framebuffers);
+}
+
+void glGenRenderbuffers_enc(void *self , GLsizei n, GLuint* renderbuffers)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_renderbuffers =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_renderbuffers + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenRenderbuffers;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4;
+	stream->readback(renderbuffers, __size_renderbuffers);
+}
+
+void glGenTextures_enc(void *self , GLsizei n, GLuint* textures)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_textures =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_textures + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenTextures;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_textures; ptr += 4;
+	stream->readback(textures, __size_textures);
+}
+
+void glGetActiveAttrib_enc(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_length = ((length != NULL) ?  (sizeof(GLsizei)) : 0);
+	const unsigned int __size_size =  (sizeof(GLint));
+	const unsigned int __size_type =  (sizeof(GLenum));
+	const unsigned int __size_name = ((name != NULL) ?  bufsize : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_length + __size_size + __size_type + __size_name + 4*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetActiveAttrib;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &index, 4); ptr += 4;
+		memcpy(ptr, &bufsize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_length; ptr += 4;
+	*(unsigned int *)(ptr) = __size_size; ptr += 4;
+	*(unsigned int *)(ptr) = __size_type; ptr += 4;
+	*(unsigned int *)(ptr) = __size_name; ptr += 4;
+	if (length != NULL) stream->readback(length, __size_length);
+	stream->readback(size, __size_size);
+	stream->readback(type, __size_type);
+	if (name != NULL) stream->readback(name, __size_name);
+}
+
+void glGetActiveUniform_enc(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_length = ((length != NULL) ?  (sizeof(GLsizei)) : 0);
+	const unsigned int __size_size =  (sizeof(GLint));
+	const unsigned int __size_type =  (sizeof(GLenum));
+	const unsigned int __size_name = ((name != NULL) ?  bufsize : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_length + __size_size + __size_type + __size_name + 4*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetActiveUniform;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &index, 4); ptr += 4;
+		memcpy(ptr, &bufsize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_length; ptr += 4;
+	*(unsigned int *)(ptr) = __size_size; ptr += 4;
+	*(unsigned int *)(ptr) = __size_type; ptr += 4;
+	*(unsigned int *)(ptr) = __size_name; ptr += 4;
+	if (length != NULL) stream->readback(length, __size_length);
+	stream->readback(size, __size_size);
+	stream->readback(type, __size_type);
+	if (name != NULL) stream->readback(name, __size_name);
+}
+
+void glGetAttachedShaders_enc(void *self , GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_count = ((count != NULL) ?  (sizeof(GLsizei)) : 0);
+	const unsigned int __size_shaders =  (maxcount*sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_count + __size_shaders + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetAttachedShaders;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &maxcount, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_count; ptr += 4;
+	*(unsigned int *)(ptr) = __size_shaders; ptr += 4;
+	if (count != NULL) stream->readback(count, __size_count);
+	stream->readback(shaders, __size_shaders);
+}
+
+int glGetAttribLocation_enc(void *self , GLuint program, const GLchar* name)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_name =  (strlen(name) + 1);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_name + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetAttribLocation;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_name; ptr += 4;
+	memcpy(ptr, name, __size_name);ptr += __size_name;
+
+	int retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glGetBooleanv_enc(void *self , GLenum pname, GLboolean* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLboolean));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetBooleanv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetBufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetBufferParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+GLenum glGetError_enc(void *self )
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetError;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+
+	GLenum retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glGetFloatv_enc(void *self , GLenum pname, GLfloat* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetFloatv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetFramebufferAttachmentParameteriv_enc(void *self , GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetFramebufferAttachmentParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &attachment, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetIntegerv_enc(void *self , GLenum pname, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetIntegerv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetProgramiv_enc(void *self , GLuint program, GLenum pname, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  sizeof(GLint);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetProgramiv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetProgramInfoLog_enc(void *self , GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_length =  sizeof(GLsizei);
+	const unsigned int __size_infolog =  bufsize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_length + __size_infolog + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetProgramInfoLog;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &bufsize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_length; ptr += 4;
+	*(unsigned int *)(ptr) = __size_infolog; ptr += 4;
+	stream->readback(length, __size_length);
+	stream->readback(infolog, __size_infolog);
+}
+
+void glGetRenderbufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  sizeof(GLint);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetRenderbufferParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetShaderiv_enc(void *self , GLuint shader, GLenum pname, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  sizeof(GLint);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetShaderiv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &shader, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetShaderInfoLog_enc(void *self , GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_length = ((length != NULL) ?  (sizeof(GLsizei)) : 0);
+	const unsigned int __size_infolog =  bufsize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_length + __size_infolog + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetShaderInfoLog;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &shader, 4); ptr += 4;
+		memcpy(ptr, &bufsize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_length; ptr += 4;
+	*(unsigned int *)(ptr) = __size_infolog; ptr += 4;
+	if (length != NULL) stream->readback(length, __size_length);
+	stream->readback(infolog, __size_infolog);
+}
+
+void glGetShaderPrecisionFormat_enc(void *self , GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_range =  (2 * sizeof(GLint));
+	const unsigned int __size_precision =  (sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_range + __size_precision + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetShaderPrecisionFormat;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &shadertype, 4); ptr += 4;
+		memcpy(ptr, &precisiontype, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_range; ptr += 4;
+	*(unsigned int *)(ptr) = __size_precision; ptr += 4;
+	stream->readback(range, __size_range);
+	stream->readback(precision, __size_precision);
+}
+
+void glGetShaderSource_enc(void *self , GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_length = ((length != NULL) ?  (sizeof(GLsizei)) : 0);
+	const unsigned int __size_source =  bufsize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_length + __size_source + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetShaderSource;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &shader, 4); ptr += 4;
+		memcpy(ptr, &bufsize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_length; ptr += 4;
+	*(unsigned int *)(ptr) = __size_source; ptr += 4;
+	if (length != NULL) stream->readback(length, __size_length);
+	stream->readback(source, __size_source);
+}
+
+void glGetTexParameterfv_enc(void *self , GLenum target, GLenum pname, GLfloat* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetTexParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetUniformfv_enc(void *self , GLuint program, GLint location, GLfloat* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  glSizeof(uniformType(self, program, location));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetUniformfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &location, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetUniformiv_enc(void *self , GLuint program, GLint location, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  glSizeof(uniformType(self, program, location));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetUniformiv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+		memcpy(ptr, &location, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+int glGetUniformLocation_enc(void *self , GLuint program, const GLchar* name)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_name =  (strlen(name) + 1);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_name + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetUniformLocation;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_name; ptr += 4;
+	memcpy(ptr, name, __size_name);ptr += __size_name;
+
+	int retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void glGetVertexAttribfv_enc(void *self , GLuint index, GLenum pname, GLfloat* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetVertexAttribfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &index, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glGetVertexAttribiv_enc(void *self , GLuint index, GLenum pname, GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetVertexAttribiv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &index, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	stream->readback(params, __size_params);
+}
+
+void glHint_enc(void *self , GLenum target, GLenum mode)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glHint;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &mode, 4); ptr += 4;
+}
+
+GLboolean glIsBuffer_enc(void *self , GLuint buffer)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &buffer, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glIsEnabled_enc(void *self , GLenum cap)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsEnabled;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &cap, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glIsFramebuffer_enc(void *self , GLuint framebuffer)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsFramebuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &framebuffer, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glIsProgram_enc(void *self , GLuint program)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsProgram;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glIsRenderbuffer_enc(void *self , GLuint renderbuffer)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &renderbuffer, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glIsShader_enc(void *self , GLuint shader)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsShader;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &shader, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+GLboolean glIsTexture_enc(void *self , GLuint texture)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsTexture;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &texture, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glLineWidth_enc(void *self , GLfloat width)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLineWidth;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &width, 4); ptr += 4;
+}
+
+void glLinkProgram_enc(void *self , GLuint program)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glLinkProgram;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+}
+
+void glPixelStorei_enc(void *self , GLenum pname, GLint param)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPixelStorei;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glPolygonOffset_enc(void *self , GLfloat factor, GLfloat units)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glPolygonOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &factor, 4); ptr += 4;
+		memcpy(ptr, &units, 4); ptr += 4;
+}
+
+void glReadPixels_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels =  pixelDataSize(self, width, height, format, type, 1);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glReadPixels;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_pixels; ptr += 4;
+	stream->readback(pixels, __size_pixels);
+}
+
+void glReleaseShaderCompiler_enc(void *self )
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glReleaseShaderCompiler;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+}
+
+void glRenderbufferStorage_enc(void *self , GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glRenderbufferStorage;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glSampleCoverage_enc(void *self , GLclampf value, GLboolean invert)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 1;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glSampleCoverage;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &value, 4); ptr += 4;
+		memcpy(ptr, &invert, 1); ptr += 1;
+}
+
+void glScissor_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glScissor;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glStencilFunc_enc(void *self , GLenum func, GLint ref, GLuint mask)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &func, 4); ptr += 4;
+		memcpy(ptr, &ref, 4); ptr += 4;
+		memcpy(ptr, &mask, 4); ptr += 4;
+}
+
+void glStencilFuncSeparate_enc(void *self , GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilFuncSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &func, 4); ptr += 4;
+		memcpy(ptr, &ref, 4); ptr += 4;
+		memcpy(ptr, &mask, 4); ptr += 4;
+}
+
+void glStencilMask_enc(void *self , GLuint mask)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilMask;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mask, 4); ptr += 4;
+}
+
+void glStencilMaskSeparate_enc(void *self , GLenum face, GLuint mask)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilMaskSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &mask, 4); ptr += 4;
+}
+
+void glStencilOp_enc(void *self , GLenum fail, GLenum zfail, GLenum zpass)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilOp;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &fail, 4); ptr += 4;
+		memcpy(ptr, &zfail, 4); ptr += 4;
+		memcpy(ptr, &zpass, 4); ptr += 4;
+}
+
+void glStencilOpSeparate_enc(void *self , GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glStencilOpSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &face, 4); ptr += 4;
+		memcpy(ptr, &fail, 4); ptr += 4;
+		memcpy(ptr, &zfail, 4); ptr += 4;
+		memcpy(ptr, &zpass, 4); ptr += 4;
+}
+
+void glTexImage2D_enc(void *self , GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels = ((pixels != NULL) ?  pixelDataSize(self, width, height, format, type, 0) : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &border, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_pixels,4);
+	if (pixels != NULL) stream->writeFully(pixels, __size_pixels);
+}
+
+void glTexParameterf_enc(void *self , GLenum target, GLenum pname, GLfloat param)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameterf;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexParameterfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexParameteri_enc(void *self , GLenum target, GLenum pname, GLint param)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameteri;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+		memcpy(ptr, &param, 4); ptr += 4;
+}
+
+void glTexParameteriv_enc(void *self , GLenum target, GLenum pname, const GLint* params)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_params =  (glUtilsParamSize(pname) * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_params + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &pname, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_params; ptr += 4;
+	memcpy(ptr, params, __size_params);ptr += __size_params;
+}
+
+void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels =  pixelDataSize(self, width, height, format, type, 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_pixels,4);
+	stream->writeFully(pixels, __size_pixels);
+}
+
+void glUniform1f_enc(void *self , GLint location, GLfloat x)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform1f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+}
+
+void glUniform1fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_v =  (count * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_v + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform1fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_v; ptr += 4;
+	memcpy(ptr, v, __size_v);ptr += __size_v;
+}
+
+void glUniform1i_enc(void *self , GLint location, GLint x)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform1i;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+}
+
+void glUniform1iv_enc(void *self , GLint location, GLsizei count, const GLint* v)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_v =  (count * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_v + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform1iv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_v; ptr += 4;
+	memcpy(ptr, v, __size_v);ptr += __size_v;
+}
+
+void glUniform2f_enc(void *self , GLint location, GLfloat x, GLfloat y)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform2f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+}
+
+void glUniform2fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_v =  (count * 2 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_v + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform2fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_v; ptr += 4;
+	memcpy(ptr, v, __size_v);ptr += __size_v;
+}
+
+void glUniform2i_enc(void *self , GLint location, GLint x, GLint y)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform2i;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+}
+
+void glUniform2iv_enc(void *self , GLint location, GLsizei count, const GLint* v)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_v =  (count * 2 * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_v + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform2iv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_v; ptr += 4;
+	memcpy(ptr, v, __size_v);ptr += __size_v;
+}
+
+void glUniform3f_enc(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform3f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glUniform3fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_v =  (count * 3 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_v + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform3fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_v; ptr += 4;
+	memcpy(ptr, v, __size_v);ptr += __size_v;
+}
+
+void glUniform3i_enc(void *self , GLint location, GLint x, GLint y, GLint z)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform3i;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glUniform3iv_enc(void *self , GLint location, GLsizei count, const GLint* v)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_v =  (3 * count * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_v + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform3iv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_v; ptr += 4;
+	memcpy(ptr, v, __size_v);ptr += __size_v;
+}
+
+void glUniform4f_enc(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform4f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+		memcpy(ptr, &w, 4); ptr += 4;
+}
+
+void glUniform4fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_v =  (4 * count * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_v + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform4fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_v; ptr += 4;
+	memcpy(ptr, v, __size_v);ptr += __size_v;
+}
+
+void glUniform4i_enc(void *self , GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform4i;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+		memcpy(ptr, &w, 4); ptr += 4;
+}
+
+void glUniform4iv_enc(void *self , GLint location, GLsizei count, const GLint* v)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_v =  (4 * count * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_v + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniform4iv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_v; ptr += 4;
+	memcpy(ptr, v, __size_v);ptr += __size_v;
+}
+
+void glUniformMatrix2fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_value =  (count * 4 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 1 + __size_value + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniformMatrix2fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+		memcpy(ptr, &transpose, 1); ptr += 1;
+	*(unsigned int *)(ptr) = __size_value; ptr += 4;
+	memcpy(ptr, value, __size_value);ptr += __size_value;
+}
+
+void glUniformMatrix3fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_value =  (count * 9 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 1 + __size_value + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniformMatrix3fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+		memcpy(ptr, &transpose, 1); ptr += 1;
+	*(unsigned int *)(ptr) = __size_value; ptr += 4;
+	memcpy(ptr, value, __size_value);ptr += __size_value;
+}
+
+void glUniformMatrix4fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_value =  (count * 16 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 1 + __size_value + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUniformMatrix4fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &location, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+		memcpy(ptr, &transpose, 1); ptr += 1;
+	*(unsigned int *)(ptr) = __size_value; ptr += 4;
+	memcpy(ptr, value, __size_value);ptr += __size_value;
+}
+
+void glUseProgram_enc(void *self , GLuint program)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUseProgram;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+}
+
+void glValidateProgram_enc(void *self , GLuint program)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glValidateProgram;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &program, 4); ptr += 4;
+}
+
+void glVertexAttrib1f_enc(void *self , GLuint indx, GLfloat x)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttrib1f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+}
+
+void glVertexAttrib1fv_enc(void *self , GLuint indx, const GLfloat* values)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_values =  (sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_values + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttrib1fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_values; ptr += 4;
+	memcpy(ptr, values, __size_values);ptr += __size_values;
+}
+
+void glVertexAttrib2f_enc(void *self , GLuint indx, GLfloat x, GLfloat y)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttrib2f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+}
+
+void glVertexAttrib2fv_enc(void *self , GLuint indx, const GLfloat* values)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_values =  (2 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_values + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttrib2fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_values; ptr += 4;
+	memcpy(ptr, values, __size_values);ptr += __size_values;
+}
+
+void glVertexAttrib3f_enc(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttrib3f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+}
+
+void glVertexAttrib3fv_enc(void *self , GLuint indx, const GLfloat* values)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_values =  (3 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_values + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttrib3fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_values; ptr += 4;
+	memcpy(ptr, values, __size_values);ptr += __size_values;
+}
+
+void glVertexAttrib4f_enc(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttrib4f;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &z, 4); ptr += 4;
+		memcpy(ptr, &w, 4); ptr += 4;
+}
+
+void glVertexAttrib4fv_enc(void *self , GLuint indx, const GLfloat* values)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_values =  (4 * sizeof(GLfloat));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_values + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttrib4fv;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_values; ptr += 4;
+	memcpy(ptr, values, __size_values);ptr += __size_values;
+}
+
+void glViewport_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glViewport;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glEGLImageTargetTexture2DOES_enc(void *self , GLenum target, GLeglImageOES image)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEGLImageTargetTexture2DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &image, 4); ptr += 4;
+}
+
+void glEGLImageTargetRenderbufferStorageOES_enc(void *self , GLenum target, GLeglImageOES image)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glEGLImageTargetRenderbufferStorageOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &image, 4); ptr += 4;
+}
+
+GLboolean glUnmapBufferOES_enc(void *self , GLenum target)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glUnmapBufferOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glTexImage3DOES_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels = ((pixels != NULL) ?  pixelDataSize3D(self, width, height, depth, format, type, 0) : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glTexImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &depth, 4); ptr += 4;
+		memcpy(ptr, &border, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_pixels,4);
+	if (pixels != NULL) stream->writeFully(pixels, __size_pixels);
+}
+
+void glTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels =  pixelDataSize3D(self, width, height, depth, format, type, 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &zoffset, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &depth, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_pixels,4);
+	stream->writeFully(pixels, __size_pixels);
+}
+
+void glCopyTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glCopyTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &zoffset, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+}
+
+void glCompressedTexImage3DOES_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  imageSize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glCompressedTexImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &internalformat, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &depth, 4); ptr += 4;
+		memcpy(ptr, &border, 4); ptr += 4;
+		memcpy(ptr, &imageSize, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_data,4);
+	stream->writeFully(data, __size_data);
+}
+
+void glCompressedTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  imageSize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_glCompressedTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &xoffset, 4); ptr += 4;
+		memcpy(ptr, &yoffset, 4); ptr += 4;
+		memcpy(ptr, &zoffset, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &depth, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &imageSize, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_data,4);
+	stream->writeFully(data, __size_data);
+}
+
+void glFramebufferTexture3DOES_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFramebufferTexture3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &attachment, 4); ptr += 4;
+		memcpy(ptr, &textarget, 4); ptr += 4;
+		memcpy(ptr, &texture, 4); ptr += 4;
+		memcpy(ptr, &level, 4); ptr += 4;
+		memcpy(ptr, &zoffset, 4); ptr += 4;
+}
+
+void glBindVertexArrayOES_enc(void *self , GLuint array)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glBindVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &array, 4); ptr += 4;
+}
+
+void glDeleteVertexArraysOES_enc(void *self , GLsizei n, const GLuint* arrays)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_arrays =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_arrays + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDeleteVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_arrays; ptr += 4;
+	memcpy(ptr, arrays, __size_arrays);ptr += __size_arrays;
+}
+
+void glGenVertexArraysOES_enc(void *self , GLsizei n, GLuint* arrays)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_arrays =  (n * sizeof(GLuint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_arrays + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGenVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &n, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_arrays; ptr += 4;
+	stream->readback(arrays, __size_arrays);
+}
+
+GLboolean glIsVertexArrayOES_enc(void *self , GLuint array)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glIsVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &array, 4); ptr += 4;
+
+	GLboolean retval;
+	stream->readback(&retval, 1);
+	return retval;
+}
+
+void glDiscardFramebufferEXT_enc(void *self , GLenum target, GLsizei numAttachments, const GLenum* attachments)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_attachments =  (numAttachments * sizeof(GLenum));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + __size_attachments + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDiscardFramebufferEXT;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &target, 4); ptr += 4;
+		memcpy(ptr, &numAttachments, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_attachments; ptr += 4;
+	memcpy(ptr, attachments, __size_attachments);ptr += __size_attachments;
+}
+
+void glVertexAttribPointerData_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void* data, GLuint datalen)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 1 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttribPointerData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &normalized, 1); ptr += 1;
+		memcpy(ptr, &stride, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glVertexAttribPointerOffset_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 1 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glVertexAttribPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &indx, 4); ptr += 4;
+		memcpy(ptr, &size, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &normalized, 1); ptr += 1;
+		memcpy(ptr, &stride, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glDrawElementsOffset_enc(void *self , GLenum mode, GLsizei count, GLenum type, GLuint offset)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawElementsOffset;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+		memcpy(ptr, &offset, 4); ptr += 4;
+}
+
+void glDrawElementsData_enc(void *self , GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_data =  datalen;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glDrawElementsData;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &mode, 4); ptr += 4;
+		memcpy(ptr, &count, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_data; ptr += 4;
+	memcpy(ptr, data, __size_data);ptr += __size_data;
+		memcpy(ptr, &datalen, 4); ptr += 4;
+}
+
+void glGetCompressedTextureFormats_enc(void *self , int count, GLint* formats)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_formats =  (count * sizeof(GLint));
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_formats + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glGetCompressedTextureFormats;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &count, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_formats; ptr += 4;
+	stream->readback(formats, __size_formats);
+}
+
+void glShaderString_enc(void *self , GLuint shader, const GLchar* string, GLsizei len)
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_string =  len;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_string + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glShaderString;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &shader, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_string; ptr += 4;
+	memcpy(ptr, string, __size_string);ptr += __size_string;
+		memcpy(ptr, &len, 4); ptr += 4;
+}
+
+int glFinishRoundTrip_enc(void *self )
+{
+
+	gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 0;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_glFinishRoundTrip;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+
+	int retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+gl2_encoder_context_t::gl2_encoder_context_t(IOStream *stream)
+{
+	m_stream = stream;
+
+	set_glActiveTexture(glActiveTexture_enc);
+	set_glAttachShader(glAttachShader_enc);
+	set_glBindAttribLocation(glBindAttribLocation_enc);
+	set_glBindBuffer(glBindBuffer_enc);
+	set_glBindFramebuffer(glBindFramebuffer_enc);
+	set_glBindRenderbuffer(glBindRenderbuffer_enc);
+	set_glBindTexture(glBindTexture_enc);
+	set_glBlendColor(glBlendColor_enc);
+	set_glBlendEquation(glBlendEquation_enc);
+	set_glBlendEquationSeparate(glBlendEquationSeparate_enc);
+	set_glBlendFunc(glBlendFunc_enc);
+	set_glBlendFuncSeparate(glBlendFuncSeparate_enc);
+	set_glBufferData(glBufferData_enc);
+	set_glBufferSubData(glBufferSubData_enc);
+	set_glCheckFramebufferStatus(glCheckFramebufferStatus_enc);
+	set_glClear(glClear_enc);
+	set_glClearColor(glClearColor_enc);
+	set_glClearDepthf(glClearDepthf_enc);
+	set_glClearStencil(glClearStencil_enc);
+	set_glColorMask(glColorMask_enc);
+	set_glCompileShader(glCompileShader_enc);
+	set_glCompressedTexImage2D(glCompressedTexImage2D_enc);
+	set_glCompressedTexSubImage2D(glCompressedTexSubImage2D_enc);
+	set_glCopyTexImage2D(glCopyTexImage2D_enc);
+	set_glCopyTexSubImage2D(glCopyTexSubImage2D_enc);
+	set_glCreateProgram(glCreateProgram_enc);
+	set_glCreateShader(glCreateShader_enc);
+	set_glCullFace(glCullFace_enc);
+	set_glDeleteBuffers(glDeleteBuffers_enc);
+	set_glDeleteFramebuffers(glDeleteFramebuffers_enc);
+	set_glDeleteProgram(glDeleteProgram_enc);
+	set_glDeleteRenderbuffers(glDeleteRenderbuffers_enc);
+	set_glDeleteShader(glDeleteShader_enc);
+	set_glDeleteTextures(glDeleteTextures_enc);
+	set_glDepthFunc(glDepthFunc_enc);
+	set_glDepthMask(glDepthMask_enc);
+	set_glDepthRangef(glDepthRangef_enc);
+	set_glDetachShader(glDetachShader_enc);
+	set_glDisable(glDisable_enc);
+	set_glDisableVertexAttribArray(glDisableVertexAttribArray_enc);
+	set_glDrawArrays(glDrawArrays_enc);
+	set_glDrawElements((glDrawElements_client_proc_t)(enc_unsupported));
+	set_glEnable(glEnable_enc);
+	set_glEnableVertexAttribArray(glEnableVertexAttribArray_enc);
+	set_glFinish(glFinish_enc);
+	set_glFlush(glFlush_enc);
+	set_glFramebufferRenderbuffer(glFramebufferRenderbuffer_enc);
+	set_glFramebufferTexture2D(glFramebufferTexture2D_enc);
+	set_glFrontFace(glFrontFace_enc);
+	set_glGenBuffers(glGenBuffers_enc);
+	set_glGenerateMipmap(glGenerateMipmap_enc);
+	set_glGenFramebuffers(glGenFramebuffers_enc);
+	set_glGenRenderbuffers(glGenRenderbuffers_enc);
+	set_glGenTextures(glGenTextures_enc);
+	set_glGetActiveAttrib(glGetActiveAttrib_enc);
+	set_glGetActiveUniform(glGetActiveUniform_enc);
+	set_glGetAttachedShaders(glGetAttachedShaders_enc);
+	set_glGetAttribLocation(glGetAttribLocation_enc);
+	set_glGetBooleanv(glGetBooleanv_enc);
+	set_glGetBufferParameteriv(glGetBufferParameteriv_enc);
+	set_glGetError(glGetError_enc);
+	set_glGetFloatv(glGetFloatv_enc);
+	set_glGetFramebufferAttachmentParameteriv(glGetFramebufferAttachmentParameteriv_enc);
+	set_glGetIntegerv(glGetIntegerv_enc);
+	set_glGetProgramiv(glGetProgramiv_enc);
+	set_glGetProgramInfoLog(glGetProgramInfoLog_enc);
+	set_glGetRenderbufferParameteriv(glGetRenderbufferParameteriv_enc);
+	set_glGetShaderiv(glGetShaderiv_enc);
+	set_glGetShaderInfoLog(glGetShaderInfoLog_enc);
+	set_glGetShaderPrecisionFormat(glGetShaderPrecisionFormat_enc);
+	set_glGetShaderSource(glGetShaderSource_enc);
+	set_glGetString((glGetString_client_proc_t)(enc_unsupported));
+	set_glGetTexParameterfv(glGetTexParameterfv_enc);
+	set_glGetTexParameteriv(glGetTexParameteriv_enc);
+	set_glGetUniformfv(glGetUniformfv_enc);
+	set_glGetUniformiv(glGetUniformiv_enc);
+	set_glGetUniformLocation(glGetUniformLocation_enc);
+	set_glGetVertexAttribfv(glGetVertexAttribfv_enc);
+	set_glGetVertexAttribiv(glGetVertexAttribiv_enc);
+	set_glGetVertexAttribPointerv((glGetVertexAttribPointerv_client_proc_t)(enc_unsupported));
+	set_glHint(glHint_enc);
+	set_glIsBuffer(glIsBuffer_enc);
+	set_glIsEnabled(glIsEnabled_enc);
+	set_glIsFramebuffer(glIsFramebuffer_enc);
+	set_glIsProgram(glIsProgram_enc);
+	set_glIsRenderbuffer(glIsRenderbuffer_enc);
+	set_glIsShader(glIsShader_enc);
+	set_glIsTexture(glIsTexture_enc);
+	set_glLineWidth(glLineWidth_enc);
+	set_glLinkProgram(glLinkProgram_enc);
+	set_glPixelStorei(glPixelStorei_enc);
+	set_glPolygonOffset(glPolygonOffset_enc);
+	set_glReadPixels(glReadPixels_enc);
+	set_glReleaseShaderCompiler(glReleaseShaderCompiler_enc);
+	set_glRenderbufferStorage(glRenderbufferStorage_enc);
+	set_glSampleCoverage(glSampleCoverage_enc);
+	set_glScissor(glScissor_enc);
+	set_glShaderBinary((glShaderBinary_client_proc_t)(enc_unsupported));
+	set_glShaderSource((glShaderSource_client_proc_t)(enc_unsupported));
+	set_glStencilFunc(glStencilFunc_enc);
+	set_glStencilFuncSeparate(glStencilFuncSeparate_enc);
+	set_glStencilMask(glStencilMask_enc);
+	set_glStencilMaskSeparate(glStencilMaskSeparate_enc);
+	set_glStencilOp(glStencilOp_enc);
+	set_glStencilOpSeparate(glStencilOpSeparate_enc);
+	set_glTexImage2D(glTexImage2D_enc);
+	set_glTexParameterf(glTexParameterf_enc);
+	set_glTexParameterfv(glTexParameterfv_enc);
+	set_glTexParameteri(glTexParameteri_enc);
+	set_glTexParameteriv(glTexParameteriv_enc);
+	set_glTexSubImage2D(glTexSubImage2D_enc);
+	set_glUniform1f(glUniform1f_enc);
+	set_glUniform1fv(glUniform1fv_enc);
+	set_glUniform1i(glUniform1i_enc);
+	set_glUniform1iv(glUniform1iv_enc);
+	set_glUniform2f(glUniform2f_enc);
+	set_glUniform2fv(glUniform2fv_enc);
+	set_glUniform2i(glUniform2i_enc);
+	set_glUniform2iv(glUniform2iv_enc);
+	set_glUniform3f(glUniform3f_enc);
+	set_glUniform3fv(glUniform3fv_enc);
+	set_glUniform3i(glUniform3i_enc);
+	set_glUniform3iv(glUniform3iv_enc);
+	set_glUniform4f(glUniform4f_enc);
+	set_glUniform4fv(glUniform4fv_enc);
+	set_glUniform4i(glUniform4i_enc);
+	set_glUniform4iv(glUniform4iv_enc);
+	set_glUniformMatrix2fv(glUniformMatrix2fv_enc);
+	set_glUniformMatrix3fv(glUniformMatrix3fv_enc);
+	set_glUniformMatrix4fv(glUniformMatrix4fv_enc);
+	set_glUseProgram(glUseProgram_enc);
+	set_glValidateProgram(glValidateProgram_enc);
+	set_glVertexAttrib1f(glVertexAttrib1f_enc);
+	set_glVertexAttrib1fv(glVertexAttrib1fv_enc);
+	set_glVertexAttrib2f(glVertexAttrib2f_enc);
+	set_glVertexAttrib2fv(glVertexAttrib2fv_enc);
+	set_glVertexAttrib3f(glVertexAttrib3f_enc);
+	set_glVertexAttrib3fv(glVertexAttrib3fv_enc);
+	set_glVertexAttrib4f(glVertexAttrib4f_enc);
+	set_glVertexAttrib4fv(glVertexAttrib4fv_enc);
+	set_glVertexAttribPointer((glVertexAttribPointer_client_proc_t)(enc_unsupported));
+	set_glViewport(glViewport_enc);
+	set_glEGLImageTargetTexture2DOES(glEGLImageTargetTexture2DOES_enc);
+	set_glEGLImageTargetRenderbufferStorageOES(glEGLImageTargetRenderbufferStorageOES_enc);
+	set_glGetProgramBinaryOES((glGetProgramBinaryOES_client_proc_t)(enc_unsupported));
+	set_glProgramBinaryOES((glProgramBinaryOES_client_proc_t)(enc_unsupported));
+	set_glMapBufferOES((glMapBufferOES_client_proc_t)(enc_unsupported));
+	set_glUnmapBufferOES(glUnmapBufferOES_enc);
+	set_glTexImage3DOES(glTexImage3DOES_enc);
+	set_glTexSubImage3DOES(glTexSubImage3DOES_enc);
+	set_glCopyTexSubImage3DOES(glCopyTexSubImage3DOES_enc);
+	set_glCompressedTexImage3DOES(glCompressedTexImage3DOES_enc);
+	set_glCompressedTexSubImage3DOES(glCompressedTexSubImage3DOES_enc);
+	set_glFramebufferTexture3DOES(glFramebufferTexture3DOES_enc);
+	set_glBindVertexArrayOES(glBindVertexArrayOES_enc);
+	set_glDeleteVertexArraysOES(glDeleteVertexArraysOES_enc);
+	set_glGenVertexArraysOES(glGenVertexArraysOES_enc);
+	set_glIsVertexArrayOES(glIsVertexArrayOES_enc);
+	set_glDiscardFramebufferEXT(glDiscardFramebufferEXT_enc);
+	set_glMultiDrawArraysEXT((glMultiDrawArraysEXT_client_proc_t)(enc_unsupported));
+	set_glMultiDrawElementsEXT((glMultiDrawElementsEXT_client_proc_t)(enc_unsupported));
+	set_glGetPerfMonitorGroupsAMD((glGetPerfMonitorGroupsAMD_client_proc_t)(enc_unsupported));
+	set_glGetPerfMonitorCountersAMD((glGetPerfMonitorCountersAMD_client_proc_t)(enc_unsupported));
+	set_glGetPerfMonitorGroupStringAMD((glGetPerfMonitorGroupStringAMD_client_proc_t)(enc_unsupported));
+	set_glGetPerfMonitorCounterStringAMD((glGetPerfMonitorCounterStringAMD_client_proc_t)(enc_unsupported));
+	set_glGetPerfMonitorCounterInfoAMD((glGetPerfMonitorCounterInfoAMD_client_proc_t)(enc_unsupported));
+	set_glGenPerfMonitorsAMD((glGenPerfMonitorsAMD_client_proc_t)(enc_unsupported));
+	set_glDeletePerfMonitorsAMD((glDeletePerfMonitorsAMD_client_proc_t)(enc_unsupported));
+	set_glSelectPerfMonitorCountersAMD((glSelectPerfMonitorCountersAMD_client_proc_t)(enc_unsupported));
+	set_glBeginPerfMonitorAMD((glBeginPerfMonitorAMD_client_proc_t)(enc_unsupported));
+	set_glEndPerfMonitorAMD((glEndPerfMonitorAMD_client_proc_t)(enc_unsupported));
+	set_glGetPerfMonitorCounterDataAMD((glGetPerfMonitorCounterDataAMD_client_proc_t)(enc_unsupported));
+	set_glRenderbufferStorageMultisampleIMG((glRenderbufferStorageMultisampleIMG_client_proc_t)(enc_unsupported));
+	set_glFramebufferTexture2DMultisampleIMG((glFramebufferTexture2DMultisampleIMG_client_proc_t)(enc_unsupported));
+	set_glDeleteFencesNV((glDeleteFencesNV_client_proc_t)(enc_unsupported));
+	set_glGenFencesNV((glGenFencesNV_client_proc_t)(enc_unsupported));
+	set_glIsFenceNV((glIsFenceNV_client_proc_t)(enc_unsupported));
+	set_glTestFenceNV((glTestFenceNV_client_proc_t)(enc_unsupported));
+	set_glGetFenceivNV((glGetFenceivNV_client_proc_t)(enc_unsupported));
+	set_glFinishFenceNV((glFinishFenceNV_client_proc_t)(enc_unsupported));
+	set_glSetFenceNV((glSetFenceNV_client_proc_t)(enc_unsupported));
+	set_glCoverageMaskNV((glCoverageMaskNV_client_proc_t)(enc_unsupported));
+	set_glCoverageOperationNV((glCoverageOperationNV_client_proc_t)(enc_unsupported));
+	set_glGetDriverControlsQCOM((glGetDriverControlsQCOM_client_proc_t)(enc_unsupported));
+	set_glGetDriverControlStringQCOM((glGetDriverControlStringQCOM_client_proc_t)(enc_unsupported));
+	set_glEnableDriverControlQCOM((glEnableDriverControlQCOM_client_proc_t)(enc_unsupported));
+	set_glDisableDriverControlQCOM((glDisableDriverControlQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetTexturesQCOM((glExtGetTexturesQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetBuffersQCOM((glExtGetBuffersQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetRenderbuffersQCOM((glExtGetRenderbuffersQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetFramebuffersQCOM((glExtGetFramebuffersQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetTexLevelParameterivQCOM((glExtGetTexLevelParameterivQCOM_client_proc_t)(enc_unsupported));
+	set_glExtTexObjectStateOverrideiQCOM((glExtTexObjectStateOverrideiQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetTexSubImageQCOM((glExtGetTexSubImageQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetBufferPointervQCOM((glExtGetBufferPointervQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetShadersQCOM((glExtGetShadersQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetProgramsQCOM((glExtGetProgramsQCOM_client_proc_t)(enc_unsupported));
+	set_glExtIsProgramBinaryQCOM((glExtIsProgramBinaryQCOM_client_proc_t)(enc_unsupported));
+	set_glExtGetProgramBinarySourceQCOM((glExtGetProgramBinarySourceQCOM_client_proc_t)(enc_unsupported));
+	set_glStartTilingQCOM((glStartTilingQCOM_client_proc_t)(enc_unsupported));
+	set_glEndTilingQCOM((glEndTilingQCOM_client_proc_t)(enc_unsupported));
+	set_glVertexAttribPointerData(glVertexAttribPointerData_enc);
+	set_glVertexAttribPointerOffset(glVertexAttribPointerOffset_enc);
+	set_glDrawElementsOffset(glDrawElementsOffset_enc);
+	set_glDrawElementsData(glDrawElementsData_enc);
+	set_glGetCompressedTextureFormats(glGetCompressedTextureFormats_enc);
+	set_glShaderString(glShaderString_enc);
+	set_glFinishRoundTrip(glFinishRoundTrip_enc);
+}
+
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_enc.h b/tools/emulator/opengl/system/GLESv2_enc/gl2_enc.h
new file mode 100644
index 0000000..f422c11
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_enc.h
@@ -0,0 +1,234 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+#ifndef GUARD_gl2_encoder_context_t
+#define GUARD_gl2_encoder_context_t
+
+#include "IOStream.h"
+#include "gl2_client_context.h"
+
+
+#include <string.h>
+#include "glUtils.h"
+#include "GL2EncoderUtils.h"
+
+struct gl2_encoder_context_t : public gl2_client_context_t {
+
+	IOStream *m_stream;
+
+	gl2_encoder_context_t(IOStream *stream);
+
+
+};
+
+extern "C" {
+	void glActiveTexture_enc(void *self , GLenum texture);
+	void glAttachShader_enc(void *self , GLuint program, GLuint shader);
+	void glBindAttribLocation_enc(void *self , GLuint program, GLuint index, const GLchar* name);
+	void glBindBuffer_enc(void *self , GLenum target, GLuint buffer);
+	void glBindFramebuffer_enc(void *self , GLenum target, GLuint framebuffer);
+	void glBindRenderbuffer_enc(void *self , GLenum target, GLuint renderbuffer);
+	void glBindTexture_enc(void *self , GLenum target, GLuint texture);
+	void glBlendColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+	void glBlendEquation_enc(void *self , GLenum mode);
+	void glBlendEquationSeparate_enc(void *self , GLenum modeRGB, GLenum modeAlpha);
+	void glBlendFunc_enc(void *self , GLenum sfactor, GLenum dfactor);
+	void glBlendFuncSeparate_enc(void *self , GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+	void glBufferData_enc(void *self , GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
+	void glBufferSubData_enc(void *self , GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+	GLenum glCheckFramebufferStatus_enc(void *self , GLenum target);
+	void glClear_enc(void *self , GLbitfield mask);
+	void glClearColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+	void glClearDepthf_enc(void *self , GLclampf depth);
+	void glClearStencil_enc(void *self , GLint s);
+	void glColorMask_enc(void *self , GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+	void glCompileShader_enc(void *self , GLuint shader);
+	void glCompressedTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
+	void glCompressedTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
+	void glCopyTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+	void glCopyTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+	GLuint glCreateProgram_enc(void *self );
+	GLuint glCreateShader_enc(void *self , GLenum type);
+	void glCullFace_enc(void *self , GLenum mode);
+	void glDeleteBuffers_enc(void *self , GLsizei n, const GLuint* buffers);
+	void glDeleteFramebuffers_enc(void *self , GLsizei n, const GLuint* framebuffers);
+	void glDeleteProgram_enc(void *self , GLuint program);
+	void glDeleteRenderbuffers_enc(void *self , GLsizei n, const GLuint* renderbuffers);
+	void glDeleteShader_enc(void *self , GLuint shader);
+	void glDeleteTextures_enc(void *self , GLsizei n, const GLuint* textures);
+	void glDepthFunc_enc(void *self , GLenum func);
+	void glDepthMask_enc(void *self , GLboolean flag);
+	void glDepthRangef_enc(void *self , GLclampf zNear, GLclampf zFar);
+	void glDetachShader_enc(void *self , GLuint program, GLuint shader);
+	void glDisable_enc(void *self , GLenum cap);
+	void glDisableVertexAttribArray_enc(void *self , GLuint index);
+	void glDrawArrays_enc(void *self , GLenum mode, GLint first, GLsizei count);
+	void glDrawElements_enc(void *self , GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+	void glEnable_enc(void *self , GLenum cap);
+	void glEnableVertexAttribArray_enc(void *self , GLuint index);
+	void glFinish_enc(void *self );
+	void glFlush_enc(void *self );
+	void glFramebufferRenderbuffer_enc(void *self , GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+	void glFramebufferTexture2D_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+	void glFrontFace_enc(void *self , GLenum mode);
+	void glGenBuffers_enc(void *self , GLsizei n, GLuint* buffers);
+	void glGenerateMipmap_enc(void *self , GLenum target);
+	void glGenFramebuffers_enc(void *self , GLsizei n, GLuint* framebuffers);
+	void glGenRenderbuffers_enc(void *self , GLsizei n, GLuint* renderbuffers);
+	void glGenTextures_enc(void *self , GLsizei n, GLuint* textures);
+	void glGetActiveAttrib_enc(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+	void glGetActiveUniform_enc(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+	void glGetAttachedShaders_enc(void *self , GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+	int glGetAttribLocation_enc(void *self , GLuint program, const GLchar* name);
+	void glGetBooleanv_enc(void *self , GLenum pname, GLboolean* params);
+	void glGetBufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params);
+	GLenum glGetError_enc(void *self );
+	void glGetFloatv_enc(void *self , GLenum pname, GLfloat* params);
+	void glGetFramebufferAttachmentParameteriv_enc(void *self , GLenum target, GLenum attachment, GLenum pname, GLint* params);
+	void glGetIntegerv_enc(void *self , GLenum pname, GLint* params);
+	void glGetProgramiv_enc(void *self , GLuint program, GLenum pname, GLint* params);
+	void glGetProgramInfoLog_enc(void *self , GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+	void glGetRenderbufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params);
+	void glGetShaderiv_enc(void *self , GLuint shader, GLenum pname, GLint* params);
+	void glGetShaderInfoLog_enc(void *self , GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+	void glGetShaderPrecisionFormat_enc(void *self , GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+	void glGetShaderSource_enc(void *self , GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+	const GLubyte* glGetString_enc(void *self , GLenum name);
+	void glGetTexParameterfv_enc(void *self , GLenum target, GLenum pname, GLfloat* params);
+	void glGetTexParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params);
+	void glGetUniformfv_enc(void *self , GLuint program, GLint location, GLfloat* params);
+	void glGetUniformiv_enc(void *self , GLuint program, GLint location, GLint* params);
+	int glGetUniformLocation_enc(void *self , GLuint program, const GLchar* name);
+	void glGetVertexAttribfv_enc(void *self , GLuint index, GLenum pname, GLfloat* params);
+	void glGetVertexAttribiv_enc(void *self , GLuint index, GLenum pname, GLint* params);
+	void glGetVertexAttribPointerv_enc(void *self , GLuint index, GLenum pname, GLvoid** pointer);
+	void glHint_enc(void *self , GLenum target, GLenum mode);
+	GLboolean glIsBuffer_enc(void *self , GLuint buffer);
+	GLboolean glIsEnabled_enc(void *self , GLenum cap);
+	GLboolean glIsFramebuffer_enc(void *self , GLuint framebuffer);
+	GLboolean glIsProgram_enc(void *self , GLuint program);
+	GLboolean glIsRenderbuffer_enc(void *self , GLuint renderbuffer);
+	GLboolean glIsShader_enc(void *self , GLuint shader);
+	GLboolean glIsTexture_enc(void *self , GLuint texture);
+	void glLineWidth_enc(void *self , GLfloat width);
+	void glLinkProgram_enc(void *self , GLuint program);
+	void glPixelStorei_enc(void *self , GLenum pname, GLint param);
+	void glPolygonOffset_enc(void *self , GLfloat factor, GLfloat units);
+	void glReadPixels_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+	void glReleaseShaderCompiler_enc(void *self );
+	void glRenderbufferStorage_enc(void *self , GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+	void glSampleCoverage_enc(void *self , GLclampf value, GLboolean invert);
+	void glScissor_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height);
+	void glShaderBinary_enc(void *self , GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
+	void glShaderSource_enc(void *self , GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
+	void glStencilFunc_enc(void *self , GLenum func, GLint ref, GLuint mask);
+	void glStencilFuncSeparate_enc(void *self , GLenum face, GLenum func, GLint ref, GLuint mask);
+	void glStencilMask_enc(void *self , GLuint mask);
+	void glStencilMaskSeparate_enc(void *self , GLenum face, GLuint mask);
+	void glStencilOp_enc(void *self , GLenum fail, GLenum zfail, GLenum zpass);
+	void glStencilOpSeparate_enc(void *self , GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+	void glTexImage2D_enc(void *self , GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+	void glTexParameterf_enc(void *self , GLenum target, GLenum pname, GLfloat param);
+	void glTexParameterfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params);
+	void glTexParameteri_enc(void *self , GLenum target, GLenum pname, GLint param);
+	void glTexParameteriv_enc(void *self , GLenum target, GLenum pname, const GLint* params);
+	void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+	void glUniform1f_enc(void *self , GLint location, GLfloat x);
+	void glUniform1fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v);
+	void glUniform1i_enc(void *self , GLint location, GLint x);
+	void glUniform1iv_enc(void *self , GLint location, GLsizei count, const GLint* v);
+	void glUniform2f_enc(void *self , GLint location, GLfloat x, GLfloat y);
+	void glUniform2fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v);
+	void glUniform2i_enc(void *self , GLint location, GLint x, GLint y);
+	void glUniform2iv_enc(void *self , GLint location, GLsizei count, const GLint* v);
+	void glUniform3f_enc(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z);
+	void glUniform3fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v);
+	void glUniform3i_enc(void *self , GLint location, GLint x, GLint y, GLint z);
+	void glUniform3iv_enc(void *self , GLint location, GLsizei count, const GLint* v);
+	void glUniform4f_enc(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+	void glUniform4fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v);
+	void glUniform4i_enc(void *self , GLint location, GLint x, GLint y, GLint z, GLint w);
+	void glUniform4iv_enc(void *self , GLint location, GLsizei count, const GLint* v);
+	void glUniformMatrix2fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+	void glUniformMatrix3fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+	void glUniformMatrix4fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+	void glUseProgram_enc(void *self , GLuint program);
+	void glValidateProgram_enc(void *self , GLuint program);
+	void glVertexAttrib1f_enc(void *self , GLuint indx, GLfloat x);
+	void glVertexAttrib1fv_enc(void *self , GLuint indx, const GLfloat* values);
+	void glVertexAttrib2f_enc(void *self , GLuint indx, GLfloat x, GLfloat y);
+	void glVertexAttrib2fv_enc(void *self , GLuint indx, const GLfloat* values);
+	void glVertexAttrib3f_enc(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+	void glVertexAttrib3fv_enc(void *self , GLuint indx, const GLfloat* values);
+	void glVertexAttrib4f_enc(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+	void glVertexAttrib4fv_enc(void *self , GLuint indx, const GLfloat* values);
+	void glVertexAttribPointer_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+	void glViewport_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height);
+	void glEGLImageTargetTexture2DOES_enc(void *self , GLenum target, GLeglImageOES image);
+	void glEGLImageTargetRenderbufferStorageOES_enc(void *self , GLenum target, GLeglImageOES image);
+	void glGetProgramBinaryOES_enc(void *self , GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
+	void glProgramBinaryOES_enc(void *self , GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length);
+	void* glMapBufferOES_enc(void *self , GLenum target, GLenum access);
+	GLboolean glUnmapBufferOES_enc(void *self , GLenum target);
+	void glTexImage3DOES_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+	void glTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+	void glCopyTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+	void glCompressedTexImage3DOES_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
+	void glCompressedTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+	void glFramebufferTexture3DOES_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+	void glBindVertexArrayOES_enc(void *self , GLuint array);
+	void glDeleteVertexArraysOES_enc(void *self , GLsizei n, const GLuint* arrays);
+	void glGenVertexArraysOES_enc(void *self , GLsizei n, GLuint* arrays);
+	GLboolean glIsVertexArrayOES_enc(void *self , GLuint array);
+	void glDiscardFramebufferEXT_enc(void *self , GLenum target, GLsizei numAttachments, const GLenum* attachments);
+	void glMultiDrawArraysEXT_enc(void *self , GLenum mode, GLint* first, GLsizei* count, GLsizei primcount);
+	void glMultiDrawElementsEXT_enc(void *self , GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount);
+	void glGetPerfMonitorGroupsAMD_enc(void *self , GLint* numGroups, GLsizei groupsSize, GLuint* groups);
+	void glGetPerfMonitorCountersAMD_enc(void *self , GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters);
+	void glGetPerfMonitorGroupStringAMD_enc(void *self , GLuint group, GLsizei bufSize, GLsizei* length, GLchar* groupString);
+	void glGetPerfMonitorCounterStringAMD_enc(void *self , GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar* counterString);
+	void glGetPerfMonitorCounterInfoAMD_enc(void *self , GLuint group, GLuint counter, GLenum pname, GLvoid* data);
+	void glGenPerfMonitorsAMD_enc(void *self , GLsizei n, GLuint* monitors);
+	void glDeletePerfMonitorsAMD_enc(void *self , GLsizei n, GLuint* monitors);
+	void glSelectPerfMonitorCountersAMD_enc(void *self , GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* countersList);
+	void glBeginPerfMonitorAMD_enc(void *self , GLuint monitor);
+	void glEndPerfMonitorAMD_enc(void *self , GLuint monitor);
+	void glGetPerfMonitorCounterDataAMD_enc(void *self , GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten);
+	void glRenderbufferStorageMultisampleIMG_enc(void *self , GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+	void glFramebufferTexture2DMultisampleIMG_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+	void glDeleteFencesNV_enc(void *self , GLsizei n, const GLuint* fences);
+	void glGenFencesNV_enc(void *self , GLsizei n, GLuint* fences);
+	GLboolean glIsFenceNV_enc(void *self , GLuint fence);
+	GLboolean glTestFenceNV_enc(void *self , GLuint fence);
+	void glGetFenceivNV_enc(void *self , GLuint fence, GLenum pname, GLint* params);
+	void glFinishFenceNV_enc(void *self , GLuint fence);
+	void glSetFenceNV_enc(void *self , GLuint fence, GLenum condition);
+	void glCoverageMaskNV_enc(void *self , GLboolean mask);
+	void glCoverageOperationNV_enc(void *self , GLenum operation);
+	void glGetDriverControlsQCOM_enc(void *self , GLint* num, GLsizei size, GLuint* driverControls);
+	void glGetDriverControlStringQCOM_enc(void *self , GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString);
+	void glEnableDriverControlQCOM_enc(void *self , GLuint driverControl);
+	void glDisableDriverControlQCOM_enc(void *self , GLuint driverControl);
+	void glExtGetTexturesQCOM_enc(void *self , GLuint* textures, GLint maxTextures, GLint* numTextures);
+	void glExtGetBuffersQCOM_enc(void *self , GLuint* buffers, GLint maxBuffers, GLint* numBuffers);
+	void glExtGetRenderbuffersQCOM_enc(void *self , GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers);
+	void glExtGetFramebuffersQCOM_enc(void *self , GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers);
+	void glExtGetTexLevelParameterivQCOM_enc(void *self , GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params);
+	void glExtTexObjectStateOverrideiQCOM_enc(void *self , GLenum target, GLenum pname, GLint param);
+	void glExtGetTexSubImageQCOM_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* texels);
+	void glExtGetBufferPointervQCOM_enc(void *self , GLenum target, GLvoidptr* params);
+	void glExtGetShadersQCOM_enc(void *self , GLuint* shaders, GLint maxShaders, GLint* numShaders);
+	void glExtGetProgramsQCOM_enc(void *self , GLuint* programs, GLint maxPrograms, GLint* numPrograms);
+	GLboolean glExtIsProgramBinaryQCOM_enc(void *self , GLuint program);
+	void glExtGetProgramBinarySourceQCOM_enc(void *self , GLuint program, GLenum shadertype, GLchar* source, GLint* length);
+	void glStartTilingQCOM_enc(void *self , GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+	void glEndTilingQCOM_enc(void *self , GLbitfield preserveMask);
+	void glVertexAttribPointerData_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void* data, GLuint datalen);
+	void glVertexAttribPointerOffset_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset);
+	void glDrawElementsOffset_enc(void *self , GLenum mode, GLsizei count, GLenum type, GLuint offset);
+	void glDrawElementsData_enc(void *self , GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen);
+	void glGetCompressedTextureFormats_enc(void *self , int count, GLint* formats);
+	void glShaderString_enc(void *self , GLuint shader, const GLchar* string, GLsizei len);
+	int glFinishRoundTrip_enc(void *self );
+};
+#endif
\ No newline at end of file
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_entry.cpp b/tools/emulator/opengl/system/GLESv2_enc/gl2_entry.cpp
new file mode 100644
index 0000000..f98fe75
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_entry.cpp
@@ -0,0 +1,1483 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#include <stdio.h>
+#include <stdlib.h>
+#include "gl2_client_context.h"
+
+#ifndef GL_TRUE
+extern "C" {
+	void glActiveTexture(GLenum texture);
+	void glAttachShader(GLuint program, GLuint shader);
+	void glBindAttribLocation(GLuint program, GLuint index, const GLchar* name);
+	void glBindBuffer(GLenum target, GLuint buffer);
+	void glBindFramebuffer(GLenum target, GLuint framebuffer);
+	void glBindRenderbuffer(GLenum target, GLuint renderbuffer);
+	void glBindTexture(GLenum target, GLuint texture);
+	void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+	void glBlendEquation(GLenum mode);
+	void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
+	void glBlendFunc(GLenum sfactor, GLenum dfactor);
+	void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+	void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
+	void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+	GLenum glCheckFramebufferStatus(GLenum target);
+	void glClear(GLbitfield mask);
+	void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+	void glClearDepthf(GLclampf depth);
+	void glClearStencil(GLint s);
+	void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+	void glCompileShader(GLuint shader);
+	void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
+	void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
+	void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+	void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+	GLuint glCreateProgram();
+	GLuint glCreateShader(GLenum type);
+	void glCullFace(GLenum mode);
+	void glDeleteBuffers(GLsizei n, const GLuint* buffers);
+	void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
+	void glDeleteProgram(GLuint program);
+	void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
+	void glDeleteShader(GLuint shader);
+	void glDeleteTextures(GLsizei n, const GLuint* textures);
+	void glDepthFunc(GLenum func);
+	void glDepthMask(GLboolean flag);
+	void glDepthRangef(GLclampf zNear, GLclampf zFar);
+	void glDetachShader(GLuint program, GLuint shader);
+	void glDisable(GLenum cap);
+	void glDisableVertexAttribArray(GLuint index);
+	void glDrawArrays(GLenum mode, GLint first, GLsizei count);
+	void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+	void glEnable(GLenum cap);
+	void glEnableVertexAttribArray(GLuint index);
+	void glFinish();
+	void glFlush();
+	void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+	void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+	void glFrontFace(GLenum mode);
+	void glGenBuffers(GLsizei n, GLuint* buffers);
+	void glGenerateMipmap(GLenum target);
+	void glGenFramebuffers(GLsizei n, GLuint* framebuffers);
+	void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers);
+	void glGenTextures(GLsizei n, GLuint* textures);
+	void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+	void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+	void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+	int glGetAttribLocation(GLuint program, const GLchar* name);
+	void glGetBooleanv(GLenum pname, GLboolean* params);
+	void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
+	GLenum glGetError();
+	void glGetFloatv(GLenum pname, GLfloat* params);
+	void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+	void glGetIntegerv(GLenum pname, GLint* params);
+	void glGetProgramiv(GLuint program, GLenum pname, GLint* params);
+	void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+	void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params);
+	void glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
+	void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+	void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+	void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+	const GLubyte* glGetString(GLenum name);
+	void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params);
+	void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params);
+	void glGetUniformfv(GLuint program, GLint location, GLfloat* params);
+	void glGetUniformiv(GLuint program, GLint location, GLint* params);
+	int glGetUniformLocation(GLuint program, const GLchar* name);
+	void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
+	void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
+	void glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer);
+	void glHint(GLenum target, GLenum mode);
+	GLboolean glIsBuffer(GLuint buffer);
+	GLboolean glIsEnabled(GLenum cap);
+	GLboolean glIsFramebuffer(GLuint framebuffer);
+	GLboolean glIsProgram(GLuint program);
+	GLboolean glIsRenderbuffer(GLuint renderbuffer);
+	GLboolean glIsShader(GLuint shader);
+	GLboolean glIsTexture(GLuint texture);
+	void glLineWidth(GLfloat width);
+	void glLinkProgram(GLuint program);
+	void glPixelStorei(GLenum pname, GLint param);
+	void glPolygonOffset(GLfloat factor, GLfloat units);
+	void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+	void glReleaseShaderCompiler();
+	void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+	void glSampleCoverage(GLclampf value, GLboolean invert);
+	void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
+	void glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
+	void glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
+	void glStencilFunc(GLenum func, GLint ref, GLuint mask);
+	void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
+	void glStencilMask(GLuint mask);
+	void glStencilMaskSeparate(GLenum face, GLuint mask);
+	void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
+	void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+	void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+	void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
+	void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params);
+	void glTexParameteri(GLenum target, GLenum pname, GLint param);
+	void glTexParameteriv(GLenum target, GLenum pname, const GLint* params);
+	void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+	void glUniform1f(GLint location, GLfloat x);
+	void glUniform1fv(GLint location, GLsizei count, const GLfloat* v);
+	void glUniform1i(GLint location, GLint x);
+	void glUniform1iv(GLint location, GLsizei count, const GLint* v);
+	void glUniform2f(GLint location, GLfloat x, GLfloat y);
+	void glUniform2fv(GLint location, GLsizei count, const GLfloat* v);
+	void glUniform2i(GLint location, GLint x, GLint y);
+	void glUniform2iv(GLint location, GLsizei count, const GLint* v);
+	void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
+	void glUniform3fv(GLint location, GLsizei count, const GLfloat* v);
+	void glUniform3i(GLint location, GLint x, GLint y, GLint z);
+	void glUniform3iv(GLint location, GLsizei count, const GLint* v);
+	void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+	void glUniform4fv(GLint location, GLsizei count, const GLfloat* v);
+	void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
+	void glUniform4iv(GLint location, GLsizei count, const GLint* v);
+	void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+	void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+	void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+	void glUseProgram(GLuint program);
+	void glValidateProgram(GLuint program);
+	void glVertexAttrib1f(GLuint indx, GLfloat x);
+	void glVertexAttrib1fv(GLuint indx, const GLfloat* values);
+	void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
+	void glVertexAttrib2fv(GLuint indx, const GLfloat* values);
+	void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+	void glVertexAttrib3fv(GLuint indx, const GLfloat* values);
+	void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+	void glVertexAttrib4fv(GLuint indx, const GLfloat* values);
+	void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+	void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
+	void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
+	void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
+	void glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
+	void glProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length);
+	void* glMapBufferOES(GLenum target, GLenum access);
+	GLboolean glUnmapBufferOES(GLenum target);
+	void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+	void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+	void glCopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+	void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
+	void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+	void glFramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+	void glBindVertexArrayOES(GLuint array);
+	void glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays);
+	void glGenVertexArraysOES(GLsizei n, GLuint* arrays);
+	GLboolean glIsVertexArrayOES(GLuint array);
+	void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum* attachments);
+	void glMultiDrawArraysEXT(GLenum mode, GLint* first, GLsizei* count, GLsizei primcount);
+	void glMultiDrawElementsEXT(GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount);
+	void glGetPerfMonitorGroupsAMD(GLint* numGroups, GLsizei groupsSize, GLuint* groups);
+	void glGetPerfMonitorCountersAMD(GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters);
+	void glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei* length, GLchar* groupString);
+	void glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar* counterString);
+	void glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid* data);
+	void glGenPerfMonitorsAMD(GLsizei n, GLuint* monitors);
+	void glDeletePerfMonitorsAMD(GLsizei n, GLuint* monitors);
+	void glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* countersList);
+	void glBeginPerfMonitorAMD(GLuint monitor);
+	void glEndPerfMonitorAMD(GLuint monitor);
+	void glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten);
+	void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+	void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+	void glDeleteFencesNV(GLsizei n, const GLuint* fences);
+	void glGenFencesNV(GLsizei n, GLuint* fences);
+	GLboolean glIsFenceNV(GLuint fence);
+	GLboolean glTestFenceNV(GLuint fence);
+	void glGetFenceivNV(GLuint fence, GLenum pname, GLint* params);
+	void glFinishFenceNV(GLuint fence);
+	void glSetFenceNV(GLuint fence, GLenum condition);
+	void glCoverageMaskNV(GLboolean mask);
+	void glCoverageOperationNV(GLenum operation);
+	void glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls);
+	void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString);
+	void glEnableDriverControlQCOM(GLuint driverControl);
+	void glDisableDriverControlQCOM(GLuint driverControl);
+	void glExtGetTexturesQCOM(GLuint* textures, GLint maxTextures, GLint* numTextures);
+	void glExtGetBuffersQCOM(GLuint* buffers, GLint maxBuffers, GLint* numBuffers);
+	void glExtGetRenderbuffersQCOM(GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers);
+	void glExtGetFramebuffersQCOM(GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers);
+	void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params);
+	void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint 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);
+	void glExtGetBufferPointervQCOM(GLenum target, GLvoidptr* params);
+	void glExtGetShadersQCOM(GLuint* shaders, GLint maxShaders, GLint* numShaders);
+	void glExtGetProgramsQCOM(GLuint* programs, GLint maxPrograms, GLint* numPrograms);
+	GLboolean glExtIsProgramBinaryQCOM(GLuint program);
+	void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar* source, GLint* length);
+	void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+	void glEndTilingQCOM(GLbitfield preserveMask);
+	void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void* data, GLuint datalen);
+	void glVertexAttribPointerOffset(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset);
+	void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset);
+	void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen);
+	void glGetCompressedTextureFormats(int count, GLint* formats);
+	void glShaderString(GLuint shader, const GLchar* string, GLsizei len);
+	int glFinishRoundTrip();
+};
+
+#endif
+#ifndef GET_CONTEXT
+static gl2_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
+void gl2_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
+#define GET_CONTEXT gl2_client_context_t * ctx = getCurrentContext() 
+#endif
+
+void glActiveTexture(GLenum texture)
+{
+	GET_CONTEXT; 
+	 ctx->glActiveTexture(ctx, texture);
+}
+
+void glAttachShader(GLuint program, GLuint shader)
+{
+	GET_CONTEXT; 
+	 ctx->glAttachShader(ctx, program, shader);
+}
+
+void glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
+{
+	GET_CONTEXT; 
+	 ctx->glBindAttribLocation(ctx, program, index, name);
+}
+
+void glBindBuffer(GLenum target, GLuint buffer)
+{
+	GET_CONTEXT; 
+	 ctx->glBindBuffer(ctx, target, buffer);
+}
+
+void glBindFramebuffer(GLenum target, GLuint framebuffer)
+{
+	GET_CONTEXT; 
+	 ctx->glBindFramebuffer(ctx, target, framebuffer);
+}
+
+void glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+	GET_CONTEXT; 
+	 ctx->glBindRenderbuffer(ctx, target, renderbuffer);
+}
+
+void glBindTexture(GLenum target, GLuint texture)
+{
+	GET_CONTEXT; 
+	 ctx->glBindTexture(ctx, target, texture);
+}
+
+void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendColor(ctx, red, green, blue, alpha);
+}
+
+void glBlendEquation(GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendEquation(ctx, mode);
+}
+
+void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendEquationSeparate(ctx, modeRGB, modeAlpha);
+}
+
+void glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendFunc(ctx, sfactor, dfactor);
+}
+
+void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+	GET_CONTEXT; 
+	 ctx->glBlendFuncSeparate(ctx, srcRGB, dstRGB, srcAlpha, dstAlpha);
+}
+
+void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
+{
+	GET_CONTEXT; 
+	 ctx->glBufferData(ctx, target, size, data, usage);
+}
+
+void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
+{
+	GET_CONTEXT; 
+	 ctx->glBufferSubData(ctx, target, offset, size, data);
+}
+
+GLenum glCheckFramebufferStatus(GLenum target)
+{
+	GET_CONTEXT; 
+	 return ctx->glCheckFramebufferStatus(ctx, target);
+}
+
+void glClear(GLbitfield mask)
+{
+	GET_CONTEXT; 
+	 ctx->glClear(ctx, mask);
+}
+
+void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glClearColor(ctx, red, green, blue, alpha);
+}
+
+void glClearDepthf(GLclampf depth)
+{
+	GET_CONTEXT; 
+	 ctx->glClearDepthf(ctx, depth);
+}
+
+void glClearStencil(GLint s)
+{
+	GET_CONTEXT; 
+	 ctx->glClearStencil(ctx, s);
+}
+
+void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+	GET_CONTEXT; 
+	 ctx->glColorMask(ctx, red, green, blue, alpha);
+}
+
+void glCompileShader(GLuint shader)
+{
+	GET_CONTEXT; 
+	 ctx->glCompileShader(ctx, shader);
+}
+
+void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+	GET_CONTEXT; 
+	 ctx->glCompressedTexImage2D(ctx, 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)
+{
+	GET_CONTEXT; 
+	 ctx->glCompressedTexSubImage2D(ctx, 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)
+{
+	GET_CONTEXT; 
+	 ctx->glCopyTexImage2D(ctx, 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)
+{
+	GET_CONTEXT; 
+	 ctx->glCopyTexSubImage2D(ctx, target, level, xoffset, yoffset, x, y, width, height);
+}
+
+GLuint glCreateProgram()
+{
+	GET_CONTEXT; 
+	 return ctx->glCreateProgram(ctx);
+}
+
+GLuint glCreateShader(GLenum type)
+{
+	GET_CONTEXT; 
+	 return ctx->glCreateShader(ctx, type);
+}
+
+void glCullFace(GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glCullFace(ctx, mode);
+}
+
+void glDeleteBuffers(GLsizei n, const GLuint* buffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteBuffers(ctx, n, buffers);
+}
+
+void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteFramebuffers(ctx, n, framebuffers);
+}
+
+void glDeleteProgram(GLuint program)
+{
+	GET_CONTEXT; 
+	 ctx->glDeleteProgram(ctx, program);
+}
+
+void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteRenderbuffers(ctx, n, renderbuffers);
+}
+
+void glDeleteShader(GLuint shader)
+{
+	GET_CONTEXT; 
+	 ctx->glDeleteShader(ctx, shader);
+}
+
+void glDeleteTextures(GLsizei n, const GLuint* textures)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteTextures(ctx, n, textures);
+}
+
+void glDepthFunc(GLenum func)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthFunc(ctx, func);
+}
+
+void glDepthMask(GLboolean flag)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthMask(ctx, flag);
+}
+
+void glDepthRangef(GLclampf zNear, GLclampf zFar)
+{
+	GET_CONTEXT; 
+	 ctx->glDepthRangef(ctx, zNear, zFar);
+}
+
+void glDetachShader(GLuint program, GLuint shader)
+{
+	GET_CONTEXT; 
+	 ctx->glDetachShader(ctx, program, shader);
+}
+
+void glDisable(GLenum cap)
+{
+	GET_CONTEXT; 
+	 ctx->glDisable(ctx, cap);
+}
+
+void glDisableVertexAttribArray(GLuint index)
+{
+	GET_CONTEXT; 
+	 ctx->glDisableVertexAttribArray(ctx, index);
+}
+
+void glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawArrays(ctx, mode, first, count);
+}
+
+void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawElements(ctx, mode, count, type, indices);
+}
+
+void glEnable(GLenum cap)
+{
+	GET_CONTEXT; 
+	 ctx->glEnable(ctx, cap);
+}
+
+void glEnableVertexAttribArray(GLuint index)
+{
+	GET_CONTEXT; 
+	 ctx->glEnableVertexAttribArray(ctx, index);
+}
+
+void glFinish()
+{
+	GET_CONTEXT; 
+	 ctx->glFinish(ctx);
+}
+
+void glFlush()
+{
+	GET_CONTEXT; 
+	 ctx->glFlush(ctx);
+}
+
+void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+	GET_CONTEXT; 
+	 ctx->glFramebufferRenderbuffer(ctx, target, attachment, renderbuffertarget, renderbuffer);
+}
+
+void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+	GET_CONTEXT; 
+	 ctx->glFramebufferTexture2D(ctx, target, attachment, textarget, texture, level);
+}
+
+void glFrontFace(GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glFrontFace(ctx, mode);
+}
+
+void glGenBuffers(GLsizei n, GLuint* buffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenBuffers(ctx, n, buffers);
+}
+
+void glGenerateMipmap(GLenum target)
+{
+	GET_CONTEXT; 
+	 ctx->glGenerateMipmap(ctx, target);
+}
+
+void glGenFramebuffers(GLsizei n, GLuint* framebuffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenFramebuffers(ctx, n, framebuffers);
+}
+
+void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenRenderbuffers(ctx, n, renderbuffers);
+}
+
+void glGenTextures(GLsizei n, GLuint* textures)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenTextures(ctx, n, textures);
+}
+
+void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
+{
+	GET_CONTEXT; 
+	 ctx->glGetActiveAttrib(ctx, program, index, bufsize, length, size, type, name);
+}
+
+void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
+{
+	GET_CONTEXT; 
+	 ctx->glGetActiveUniform(ctx, program, index, bufsize, length, size, type, name);
+}
+
+void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+{
+	GET_CONTEXT; 
+	 ctx->glGetAttachedShaders(ctx, program, maxcount, count, shaders);
+}
+
+int glGetAttribLocation(GLuint program, const GLchar* name)
+{
+	GET_CONTEXT; 
+	 return ctx->glGetAttribLocation(ctx, program, name);
+}
+
+void glGetBooleanv(GLenum pname, GLboolean* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetBooleanv(ctx, pname, params);
+}
+
+void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetBufferParameteriv(ctx, target, pname, params);
+}
+
+GLenum glGetError()
+{
+	GET_CONTEXT; 
+	 return ctx->glGetError(ctx);
+}
+
+void glGetFloatv(GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetFloatv(ctx, pname, params);
+}
+
+void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetFramebufferAttachmentParameteriv(ctx, target, attachment, pname, params);
+}
+
+void glGetIntegerv(GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetIntegerv(ctx, pname, params);
+}
+
+void glGetProgramiv(GLuint program, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetProgramiv(ctx, program, pname, params);
+}
+
+void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+{
+	GET_CONTEXT; 
+	 ctx->glGetProgramInfoLog(ctx, program, bufsize, length, infolog);
+}
+
+void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetRenderbufferParameteriv(ctx, target, pname, params);
+}
+
+void glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetShaderiv(ctx, shader, pname, params);
+}
+
+void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+{
+	GET_CONTEXT; 
+	 ctx->glGetShaderInfoLog(ctx, shader, bufsize, length, infolog);
+}
+
+void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+{
+	GET_CONTEXT; 
+	 ctx->glGetShaderPrecisionFormat(ctx, shadertype, precisiontype, range, precision);
+}
+
+void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
+{
+	GET_CONTEXT; 
+	 ctx->glGetShaderSource(ctx, shader, bufsize, length, source);
+}
+
+const GLubyte* glGetString(GLenum name)
+{
+	GET_CONTEXT; 
+	 return ctx->glGetString(ctx, name);
+}
+
+void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexParameterfv(ctx, target, pname, params);
+}
+
+void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetTexParameteriv(ctx, target, pname, params);
+}
+
+void glGetUniformfv(GLuint program, GLint location, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetUniformfv(ctx, program, location, params);
+}
+
+void glGetUniformiv(GLuint program, GLint location, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetUniformiv(ctx, program, location, params);
+}
+
+int glGetUniformLocation(GLuint program, const GLchar* name)
+{
+	GET_CONTEXT; 
+	 return ctx->glGetUniformLocation(ctx, program, name);
+}
+
+void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetVertexAttribfv(ctx, index, pname, params);
+}
+
+void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetVertexAttribiv(ctx, index, pname, params);
+}
+
+void glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
+{
+	GET_CONTEXT; 
+	 ctx->glGetVertexAttribPointerv(ctx, index, pname, pointer);
+}
+
+void glHint(GLenum target, GLenum mode)
+{
+	GET_CONTEXT; 
+	 ctx->glHint(ctx, target, mode);
+}
+
+GLboolean glIsBuffer(GLuint buffer)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsBuffer(ctx, buffer);
+}
+
+GLboolean glIsEnabled(GLenum cap)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsEnabled(ctx, cap);
+}
+
+GLboolean glIsFramebuffer(GLuint framebuffer)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsFramebuffer(ctx, framebuffer);
+}
+
+GLboolean glIsProgram(GLuint program)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsProgram(ctx, program);
+}
+
+GLboolean glIsRenderbuffer(GLuint renderbuffer)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsRenderbuffer(ctx, renderbuffer);
+}
+
+GLboolean glIsShader(GLuint shader)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsShader(ctx, shader);
+}
+
+GLboolean glIsTexture(GLuint texture)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsTexture(ctx, texture);
+}
+
+void glLineWidth(GLfloat width)
+{
+	GET_CONTEXT; 
+	 ctx->glLineWidth(ctx, width);
+}
+
+void glLinkProgram(GLuint program)
+{
+	GET_CONTEXT; 
+	 ctx->glLinkProgram(ctx, program);
+}
+
+void glPixelStorei(GLenum pname, GLint param)
+{
+	GET_CONTEXT; 
+	 ctx->glPixelStorei(ctx, pname, param);
+}
+
+void glPolygonOffset(GLfloat factor, GLfloat units)
+{
+	GET_CONTEXT; 
+	 ctx->glPolygonOffset(ctx, factor, units);
+}
+
+void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->glReadPixels(ctx, x, y, width, height, format, type, pixels);
+}
+
+void glReleaseShaderCompiler()
+{
+	GET_CONTEXT; 
+	 ctx->glReleaseShaderCompiler(ctx);
+}
+
+void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glRenderbufferStorage(ctx, target, internalformat, width, height);
+}
+
+void glSampleCoverage(GLclampf value, GLboolean invert)
+{
+	GET_CONTEXT; 
+	 ctx->glSampleCoverage(ctx, value, invert);
+}
+
+void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glScissor(ctx, x, y, width, height);
+}
+
+void glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
+{
+	GET_CONTEXT; 
+	 ctx->glShaderBinary(ctx, n, shaders, binaryformat, binary, length);
+}
+
+void glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length)
+{
+	GET_CONTEXT; 
+	 ctx->glShaderSource(ctx, shader, count, string, length);
+}
+
+void glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilFunc(ctx, func, ref, mask);
+}
+
+void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilFuncSeparate(ctx, face, func, ref, mask);
+}
+
+void glStencilMask(GLuint mask)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilMask(ctx, mask);
+}
+
+void glStencilMaskSeparate(GLenum face, GLuint mask)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilMaskSeparate(ctx, face, mask);
+}
+
+void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilOp(ctx, fail, zfail, zpass);
+}
+
+void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+	GET_CONTEXT; 
+	 ctx->glStencilOpSeparate(ctx, face, fail, zfail, zpass);
+}
+
+void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->glTexImage2D(ctx, target, level, internalformat, width, height, border, format, type, pixels);
+}
+
+void glTexParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameterf(ctx, target, pname, param);
+}
+
+void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameterfv(ctx, target, pname, params);
+}
+
+void glTexParameteri(GLenum target, GLenum pname, GLint param)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameteri(ctx, target, pname, param);
+}
+
+void glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glTexParameteriv(ctx, target, pname, params);
+}
+
+void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->glTexSubImage2D(ctx, target, level, xoffset, yoffset, width, height, format, type, pixels);
+}
+
+void glUniform1f(GLint location, GLfloat x)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform1f(ctx, location, x);
+}
+
+void glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform1fv(ctx, location, count, v);
+}
+
+void glUniform1i(GLint location, GLint x)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform1i(ctx, location, x);
+}
+
+void glUniform1iv(GLint location, GLsizei count, const GLint* v)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform1iv(ctx, location, count, v);
+}
+
+void glUniform2f(GLint location, GLfloat x, GLfloat y)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform2f(ctx, location, x, y);
+}
+
+void glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform2fv(ctx, location, count, v);
+}
+
+void glUniform2i(GLint location, GLint x, GLint y)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform2i(ctx, location, x, y);
+}
+
+void glUniform2iv(GLint location, GLsizei count, const GLint* v)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform2iv(ctx, location, count, v);
+}
+
+void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform3f(ctx, location, x, y, z);
+}
+
+void glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform3fv(ctx, location, count, v);
+}
+
+void glUniform3i(GLint location, GLint x, GLint y, GLint z)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform3i(ctx, location, x, y, z);
+}
+
+void glUniform3iv(GLint location, GLsizei count, const GLint* v)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform3iv(ctx, location, count, v);
+}
+
+void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform4f(ctx, location, x, y, z, w);
+}
+
+void glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform4fv(ctx, location, count, v);
+}
+
+void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform4i(ctx, location, x, y, z, w);
+}
+
+void glUniform4iv(GLint location, GLsizei count, const GLint* v)
+{
+	GET_CONTEXT; 
+	 ctx->glUniform4iv(ctx, location, count, v);
+}
+
+void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+	GET_CONTEXT; 
+	 ctx->glUniformMatrix2fv(ctx, location, count, transpose, value);
+}
+
+void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+	GET_CONTEXT; 
+	 ctx->glUniformMatrix3fv(ctx, location, count, transpose, value);
+}
+
+void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+	GET_CONTEXT; 
+	 ctx->glUniformMatrix4fv(ctx, location, count, transpose, value);
+}
+
+void glUseProgram(GLuint program)
+{
+	GET_CONTEXT; 
+	 ctx->glUseProgram(ctx, program);
+}
+
+void glValidateProgram(GLuint program)
+{
+	GET_CONTEXT; 
+	 ctx->glValidateProgram(ctx, program);
+}
+
+void glVertexAttrib1f(GLuint indx, GLfloat x)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttrib1f(ctx, indx, x);
+}
+
+void glVertexAttrib1fv(GLuint indx, const GLfloat* values)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttrib1fv(ctx, indx, values);
+}
+
+void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttrib2f(ctx, indx, x, y);
+}
+
+void glVertexAttrib2fv(GLuint indx, const GLfloat* values)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttrib2fv(ctx, indx, values);
+}
+
+void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttrib3f(ctx, indx, x, y, z);
+}
+
+void glVertexAttrib3fv(GLuint indx, const GLfloat* values)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttrib3fv(ctx, indx, values);
+}
+
+void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttrib4f(ctx, indx, x, y, z, w);
+}
+
+void glVertexAttrib4fv(GLuint indx, const GLfloat* values)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttrib4fv(ctx, indx, values);
+}
+
+void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttribPointer(ctx, indx, size, type, normalized, stride, ptr);
+}
+
+void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glViewport(ctx, x, y, width, height);
+}
+
+void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+	GET_CONTEXT; 
+	 ctx->glEGLImageTargetTexture2DOES(ctx, target, image);
+}
+
+void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+	GET_CONTEXT; 
+	 ctx->glEGLImageTargetRenderbufferStorageOES(ctx, target, image);
+}
+
+void glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
+{
+	GET_CONTEXT; 
+	 ctx->glGetProgramBinaryOES(ctx, program, bufSize, length, binaryFormat, binary);
+}
+
+void glProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length)
+{
+	GET_CONTEXT; 
+	 ctx->glProgramBinaryOES(ctx, program, binaryFormat, binary, length);
+}
+
+void* glMapBufferOES(GLenum target, GLenum access)
+{
+	GET_CONTEXT; 
+	 return ctx->glMapBufferOES(ctx, target, access);
+}
+
+GLboolean glUnmapBufferOES(GLenum target)
+{
+	GET_CONTEXT; 
+	 return ctx->glUnmapBufferOES(ctx, target);
+}
+
+void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->glTexImage3DOES(ctx, target, level, internalformat, width, height, depth, border, format, type, pixels);
+}
+
+void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->glTexSubImage3DOES(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
+}
+
+void glCopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glCopyTexSubImage3DOES(ctx, target, level, xoffset, yoffset, zoffset, x, y, width, height);
+}
+
+void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
+{
+	GET_CONTEXT; 
+	 ctx->glCompressedTexImage3DOES(ctx, target, level, internalformat, width, height, depth, border, imageSize, data);
+}
+
+void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
+{
+	GET_CONTEXT; 
+	 ctx->glCompressedTexSubImage3DOES(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
+}
+
+void glFramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
+{
+	GET_CONTEXT; 
+	 ctx->glFramebufferTexture3DOES(ctx, target, attachment, textarget, texture, level, zoffset);
+}
+
+void glBindVertexArrayOES(GLuint array)
+{
+	GET_CONTEXT; 
+	 ctx->glBindVertexArrayOES(ctx, array);
+}
+
+void glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glDeleteVertexArraysOES(ctx, n, arrays);
+}
+
+void glGenVertexArraysOES(GLsizei n, GLuint* arrays)
+{
+	GET_CONTEXT; 
+	 if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+	 ctx->glGenVertexArraysOES(ctx, n, arrays);
+}
+
+GLboolean glIsVertexArrayOES(GLuint array)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsVertexArrayOES(ctx, array);
+}
+
+void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum* attachments)
+{
+	GET_CONTEXT; 
+	 ctx->glDiscardFramebufferEXT(ctx, target, numAttachments, attachments);
+}
+
+void glMultiDrawArraysEXT(GLenum mode, GLint* first, GLsizei* count, GLsizei primcount)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiDrawArraysEXT(ctx, mode, first, count, primcount);
+}
+
+void glMultiDrawElementsEXT(GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount)
+{
+	GET_CONTEXT; 
+	 ctx->glMultiDrawElementsEXT(ctx, mode, count, type, indices, primcount);
+}
+
+void glGetPerfMonitorGroupsAMD(GLint* numGroups, GLsizei groupsSize, GLuint* groups)
+{
+	GET_CONTEXT; 
+	 ctx->glGetPerfMonitorGroupsAMD(ctx, numGroups, groupsSize, groups);
+}
+
+void glGetPerfMonitorCountersAMD(GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters)
+{
+	GET_CONTEXT; 
+	 ctx->glGetPerfMonitorCountersAMD(ctx, group, numCounters, maxActiveCounters, counterSize, counters);
+}
+
+void glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei* length, GLchar* groupString)
+{
+	GET_CONTEXT; 
+	 ctx->glGetPerfMonitorGroupStringAMD(ctx, group, bufSize, length, groupString);
+}
+
+void glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar* counterString)
+{
+	GET_CONTEXT; 
+	 ctx->glGetPerfMonitorCounterStringAMD(ctx, group, counter, bufSize, length, counterString);
+}
+
+void glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid* data)
+{
+	GET_CONTEXT; 
+	 ctx->glGetPerfMonitorCounterInfoAMD(ctx, group, counter, pname, data);
+}
+
+void glGenPerfMonitorsAMD(GLsizei n, GLuint* monitors)
+{
+	GET_CONTEXT; 
+	 ctx->glGenPerfMonitorsAMD(ctx, n, monitors);
+}
+
+void glDeletePerfMonitorsAMD(GLsizei n, GLuint* monitors)
+{
+	GET_CONTEXT; 
+	 ctx->glDeletePerfMonitorsAMD(ctx, n, monitors);
+}
+
+void glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* countersList)
+{
+	GET_CONTEXT; 
+	 ctx->glSelectPerfMonitorCountersAMD(ctx, monitor, enable, group, numCounters, countersList);
+}
+
+void glBeginPerfMonitorAMD(GLuint monitor)
+{
+	GET_CONTEXT; 
+	 ctx->glBeginPerfMonitorAMD(ctx, monitor);
+}
+
+void glEndPerfMonitorAMD(GLuint monitor)
+{
+	GET_CONTEXT; 
+	 ctx->glEndPerfMonitorAMD(ctx, monitor);
+}
+
+void glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten)
+{
+	GET_CONTEXT; 
+	 ctx->glGetPerfMonitorCounterDataAMD(ctx, monitor, pname, dataSize, data, bytesWritten);
+}
+
+void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+{
+	GET_CONTEXT; 
+	 ctx->glRenderbufferStorageMultisampleIMG(ctx, target, samples, internalformat, width, height);
+}
+
+void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
+{
+	GET_CONTEXT; 
+	 ctx->glFramebufferTexture2DMultisampleIMG(ctx, target, attachment, textarget, texture, level, samples);
+}
+
+void glDeleteFencesNV(GLsizei n, const GLuint* fences)
+{
+	GET_CONTEXT; 
+	 ctx->glDeleteFencesNV(ctx, n, fences);
+}
+
+void glGenFencesNV(GLsizei n, GLuint* fences)
+{
+	GET_CONTEXT; 
+	 ctx->glGenFencesNV(ctx, n, fences);
+}
+
+GLboolean glIsFenceNV(GLuint fence)
+{
+	GET_CONTEXT; 
+	 return ctx->glIsFenceNV(ctx, fence);
+}
+
+GLboolean glTestFenceNV(GLuint fence)
+{
+	GET_CONTEXT; 
+	 return ctx->glTestFenceNV(ctx, fence);
+}
+
+void glGetFenceivNV(GLuint fence, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glGetFenceivNV(ctx, fence, pname, params);
+}
+
+void glFinishFenceNV(GLuint fence)
+{
+	GET_CONTEXT; 
+	 ctx->glFinishFenceNV(ctx, fence);
+}
+
+void glSetFenceNV(GLuint fence, GLenum condition)
+{
+	GET_CONTEXT; 
+	 ctx->glSetFenceNV(ctx, fence, condition);
+}
+
+void glCoverageMaskNV(GLboolean mask)
+{
+	GET_CONTEXT; 
+	 ctx->glCoverageMaskNV(ctx, mask);
+}
+
+void glCoverageOperationNV(GLenum operation)
+{
+	GET_CONTEXT; 
+	 ctx->glCoverageOperationNV(ctx, operation);
+}
+
+void glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls)
+{
+	GET_CONTEXT; 
+	 ctx->glGetDriverControlsQCOM(ctx, num, size, driverControls);
+}
+
+void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString)
+{
+	GET_CONTEXT; 
+	 ctx->glGetDriverControlStringQCOM(ctx, driverControl, bufSize, length, driverControlString);
+}
+
+void glEnableDriverControlQCOM(GLuint driverControl)
+{
+	GET_CONTEXT; 
+	 ctx->glEnableDriverControlQCOM(ctx, driverControl);
+}
+
+void glDisableDriverControlQCOM(GLuint driverControl)
+{
+	GET_CONTEXT; 
+	 ctx->glDisableDriverControlQCOM(ctx, driverControl);
+}
+
+void glExtGetTexturesQCOM(GLuint* textures, GLint maxTextures, GLint* numTextures)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetTexturesQCOM(ctx, textures, maxTextures, numTextures);
+}
+
+void glExtGetBuffersQCOM(GLuint* buffers, GLint maxBuffers, GLint* numBuffers)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetBuffersQCOM(ctx, buffers, maxBuffers, numBuffers);
+}
+
+void glExtGetRenderbuffersQCOM(GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetRenderbuffersQCOM(ctx, renderbuffers, maxRenderbuffers, numRenderbuffers);
+}
+
+void glExtGetFramebuffersQCOM(GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetFramebuffersQCOM(ctx, framebuffers, maxFramebuffers, numFramebuffers);
+}
+
+void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetTexLevelParameterivQCOM(ctx, texture, face, level, pname, params);
+}
+
+void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param)
+{
+	GET_CONTEXT; 
+	 ctx->glExtTexObjectStateOverrideiQCOM(ctx, 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)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetTexSubImageQCOM(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels);
+}
+
+void glExtGetBufferPointervQCOM(GLenum target, GLvoidptr* params)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetBufferPointervQCOM(ctx, target, params);
+}
+
+void glExtGetShadersQCOM(GLuint* shaders, GLint maxShaders, GLint* numShaders)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetShadersQCOM(ctx, shaders, maxShaders, numShaders);
+}
+
+void glExtGetProgramsQCOM(GLuint* programs, GLint maxPrograms, GLint* numPrograms)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetProgramsQCOM(ctx, programs, maxPrograms, numPrograms);
+}
+
+GLboolean glExtIsProgramBinaryQCOM(GLuint program)
+{
+	GET_CONTEXT; 
+	 return ctx->glExtIsProgramBinaryQCOM(ctx, program);
+}
+
+void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar* source, GLint* length)
+{
+	GET_CONTEXT; 
+	 ctx->glExtGetProgramBinarySourceQCOM(ctx, program, shadertype, source, length);
+}
+
+void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
+{
+	GET_CONTEXT; 
+	 ctx->glStartTilingQCOM(ctx, x, y, width, height, preserveMask);
+}
+
+void glEndTilingQCOM(GLbitfield preserveMask)
+{
+	GET_CONTEXT; 
+	 ctx->glEndTilingQCOM(ctx, preserveMask);
+}
+
+void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttribPointerData(ctx, indx, size, type, normalized, stride, data, datalen);
+}
+
+void glVertexAttribPointerOffset(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glVertexAttribPointerOffset(ctx, indx, size, type, normalized, stride, offset);
+}
+
+void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawElementsOffset(ctx, mode, count, type, offset);
+}
+
+void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen)
+{
+	GET_CONTEXT; 
+	 ctx->glDrawElementsData(ctx, mode, count, type, data, datalen);
+}
+
+void glGetCompressedTextureFormats(int count, GLint* formats)
+{
+	GET_CONTEXT; 
+	 ctx->glGetCompressedTextureFormats(ctx, count, formats);
+}
+
+void glShaderString(GLuint shader, const GLchar* string, GLsizei len)
+{
+	GET_CONTEXT; 
+	 ctx->glShaderString(ctx, shader, string, len);
+}
+
+int glFinishRoundTrip()
+{
+	GET_CONTEXT; 
+	 return ctx->glFinishRoundTrip(ctx);
+}
+
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_ftable.h b/tools/emulator/opengl/system/GLESv2_enc/gl2_ftable.h
new file mode 100644
index 0000000..4cbda78
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_ftable.h
@@ -0,0 +1,216 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __gl2_client_ftable_t_h
+#define __gl2_client_ftable_t_h
+
+
+static struct _gl2_funcs_by_name {
+	const char *name;
+	void *proc;
+} gl2_funcs_by_name[] = {
+	{"glActiveTexture", (void*)glActiveTexture},
+	{"glAttachShader", (void*)glAttachShader},
+	{"glBindAttribLocation", (void*)glBindAttribLocation},
+	{"glBindBuffer", (void*)glBindBuffer},
+	{"glBindFramebuffer", (void*)glBindFramebuffer},
+	{"glBindRenderbuffer", (void*)glBindRenderbuffer},
+	{"glBindTexture", (void*)glBindTexture},
+	{"glBlendColor", (void*)glBlendColor},
+	{"glBlendEquation", (void*)glBlendEquation},
+	{"glBlendEquationSeparate", (void*)glBlendEquationSeparate},
+	{"glBlendFunc", (void*)glBlendFunc},
+	{"glBlendFuncSeparate", (void*)glBlendFuncSeparate},
+	{"glBufferData", (void*)glBufferData},
+	{"glBufferSubData", (void*)glBufferSubData},
+	{"glCheckFramebufferStatus", (void*)glCheckFramebufferStatus},
+	{"glClear", (void*)glClear},
+	{"glClearColor", (void*)glClearColor},
+	{"glClearDepthf", (void*)glClearDepthf},
+	{"glClearStencil", (void*)glClearStencil},
+	{"glColorMask", (void*)glColorMask},
+	{"glCompileShader", (void*)glCompileShader},
+	{"glCompressedTexImage2D", (void*)glCompressedTexImage2D},
+	{"glCompressedTexSubImage2D", (void*)glCompressedTexSubImage2D},
+	{"glCopyTexImage2D", (void*)glCopyTexImage2D},
+	{"glCopyTexSubImage2D", (void*)glCopyTexSubImage2D},
+	{"glCreateProgram", (void*)glCreateProgram},
+	{"glCreateShader", (void*)glCreateShader},
+	{"glCullFace", (void*)glCullFace},
+	{"glDeleteBuffers", (void*)glDeleteBuffers},
+	{"glDeleteFramebuffers", (void*)glDeleteFramebuffers},
+	{"glDeleteProgram", (void*)glDeleteProgram},
+	{"glDeleteRenderbuffers", (void*)glDeleteRenderbuffers},
+	{"glDeleteShader", (void*)glDeleteShader},
+	{"glDeleteTextures", (void*)glDeleteTextures},
+	{"glDepthFunc", (void*)glDepthFunc},
+	{"glDepthMask", (void*)glDepthMask},
+	{"glDepthRangef", (void*)glDepthRangef},
+	{"glDetachShader", (void*)glDetachShader},
+	{"glDisable", (void*)glDisable},
+	{"glDisableVertexAttribArray", (void*)glDisableVertexAttribArray},
+	{"glDrawArrays", (void*)glDrawArrays},
+	{"glDrawElements", (void*)glDrawElements},
+	{"glEnable", (void*)glEnable},
+	{"glEnableVertexAttribArray", (void*)glEnableVertexAttribArray},
+	{"glFinish", (void*)glFinish},
+	{"glFlush", (void*)glFlush},
+	{"glFramebufferRenderbuffer", (void*)glFramebufferRenderbuffer},
+	{"glFramebufferTexture2D", (void*)glFramebufferTexture2D},
+	{"glFrontFace", (void*)glFrontFace},
+	{"glGenBuffers", (void*)glGenBuffers},
+	{"glGenerateMipmap", (void*)glGenerateMipmap},
+	{"glGenFramebuffers", (void*)glGenFramebuffers},
+	{"glGenRenderbuffers", (void*)glGenRenderbuffers},
+	{"glGenTextures", (void*)glGenTextures},
+	{"glGetActiveAttrib", (void*)glGetActiveAttrib},
+	{"glGetActiveUniform", (void*)glGetActiveUniform},
+	{"glGetAttachedShaders", (void*)glGetAttachedShaders},
+	{"glGetAttribLocation", (void*)glGetAttribLocation},
+	{"glGetBooleanv", (void*)glGetBooleanv},
+	{"glGetBufferParameteriv", (void*)glGetBufferParameteriv},
+	{"glGetError", (void*)glGetError},
+	{"glGetFloatv", (void*)glGetFloatv},
+	{"glGetFramebufferAttachmentParameteriv", (void*)glGetFramebufferAttachmentParameteriv},
+	{"glGetIntegerv", (void*)glGetIntegerv},
+	{"glGetProgramiv", (void*)glGetProgramiv},
+	{"glGetProgramInfoLog", (void*)glGetProgramInfoLog},
+	{"glGetRenderbufferParameteriv", (void*)glGetRenderbufferParameteriv},
+	{"glGetShaderiv", (void*)glGetShaderiv},
+	{"glGetShaderInfoLog", (void*)glGetShaderInfoLog},
+	{"glGetShaderPrecisionFormat", (void*)glGetShaderPrecisionFormat},
+	{"glGetShaderSource", (void*)glGetShaderSource},
+	{"glGetString", (void*)glGetString},
+	{"glGetTexParameterfv", (void*)glGetTexParameterfv},
+	{"glGetTexParameteriv", (void*)glGetTexParameteriv},
+	{"glGetUniformfv", (void*)glGetUniformfv},
+	{"glGetUniformiv", (void*)glGetUniformiv},
+	{"glGetUniformLocation", (void*)glGetUniformLocation},
+	{"glGetVertexAttribfv", (void*)glGetVertexAttribfv},
+	{"glGetVertexAttribiv", (void*)glGetVertexAttribiv},
+	{"glGetVertexAttribPointerv", (void*)glGetVertexAttribPointerv},
+	{"glHint", (void*)glHint},
+	{"glIsBuffer", (void*)glIsBuffer},
+	{"glIsEnabled", (void*)glIsEnabled},
+	{"glIsFramebuffer", (void*)glIsFramebuffer},
+	{"glIsProgram", (void*)glIsProgram},
+	{"glIsRenderbuffer", (void*)glIsRenderbuffer},
+	{"glIsShader", (void*)glIsShader},
+	{"glIsTexture", (void*)glIsTexture},
+	{"glLineWidth", (void*)glLineWidth},
+	{"glLinkProgram", (void*)glLinkProgram},
+	{"glPixelStorei", (void*)glPixelStorei},
+	{"glPolygonOffset", (void*)glPolygonOffset},
+	{"glReadPixels", (void*)glReadPixels},
+	{"glReleaseShaderCompiler", (void*)glReleaseShaderCompiler},
+	{"glRenderbufferStorage", (void*)glRenderbufferStorage},
+	{"glSampleCoverage", (void*)glSampleCoverage},
+	{"glScissor", (void*)glScissor},
+	{"glShaderBinary", (void*)glShaderBinary},
+	{"glShaderSource", (void*)glShaderSource},
+	{"glStencilFunc", (void*)glStencilFunc},
+	{"glStencilFuncSeparate", (void*)glStencilFuncSeparate},
+	{"glStencilMask", (void*)glStencilMask},
+	{"glStencilMaskSeparate", (void*)glStencilMaskSeparate},
+	{"glStencilOp", (void*)glStencilOp},
+	{"glStencilOpSeparate", (void*)glStencilOpSeparate},
+	{"glTexImage2D", (void*)glTexImage2D},
+	{"glTexParameterf", (void*)glTexParameterf},
+	{"glTexParameterfv", (void*)glTexParameterfv},
+	{"glTexParameteri", (void*)glTexParameteri},
+	{"glTexParameteriv", (void*)glTexParameteriv},
+	{"glTexSubImage2D", (void*)glTexSubImage2D},
+	{"glUniform1f", (void*)glUniform1f},
+	{"glUniform1fv", (void*)glUniform1fv},
+	{"glUniform1i", (void*)glUniform1i},
+	{"glUniform1iv", (void*)glUniform1iv},
+	{"glUniform2f", (void*)glUniform2f},
+	{"glUniform2fv", (void*)glUniform2fv},
+	{"glUniform2i", (void*)glUniform2i},
+	{"glUniform2iv", (void*)glUniform2iv},
+	{"glUniform3f", (void*)glUniform3f},
+	{"glUniform3fv", (void*)glUniform3fv},
+	{"glUniform3i", (void*)glUniform3i},
+	{"glUniform3iv", (void*)glUniform3iv},
+	{"glUniform4f", (void*)glUniform4f},
+	{"glUniform4fv", (void*)glUniform4fv},
+	{"glUniform4i", (void*)glUniform4i},
+	{"glUniform4iv", (void*)glUniform4iv},
+	{"glUniformMatrix2fv", (void*)glUniformMatrix2fv},
+	{"glUniformMatrix3fv", (void*)glUniformMatrix3fv},
+	{"glUniformMatrix4fv", (void*)glUniformMatrix4fv},
+	{"glUseProgram", (void*)glUseProgram},
+	{"glValidateProgram", (void*)glValidateProgram},
+	{"glVertexAttrib1f", (void*)glVertexAttrib1f},
+	{"glVertexAttrib1fv", (void*)glVertexAttrib1fv},
+	{"glVertexAttrib2f", (void*)glVertexAttrib2f},
+	{"glVertexAttrib2fv", (void*)glVertexAttrib2fv},
+	{"glVertexAttrib3f", (void*)glVertexAttrib3f},
+	{"glVertexAttrib3fv", (void*)glVertexAttrib3fv},
+	{"glVertexAttrib4f", (void*)glVertexAttrib4f},
+	{"glVertexAttrib4fv", (void*)glVertexAttrib4fv},
+	{"glVertexAttribPointer", (void*)glVertexAttribPointer},
+	{"glViewport", (void*)glViewport},
+	{"glEGLImageTargetTexture2DOES", (void*)glEGLImageTargetTexture2DOES},
+	{"glEGLImageTargetRenderbufferStorageOES", (void*)glEGLImageTargetRenderbufferStorageOES},
+	{"glGetProgramBinaryOES", (void*)glGetProgramBinaryOES},
+	{"glProgramBinaryOES", (void*)glProgramBinaryOES},
+	{"glMapBufferOES", (void*)glMapBufferOES},
+	{"glUnmapBufferOES", (void*)glUnmapBufferOES},
+	{"glTexImage3DOES", (void*)glTexImage3DOES},
+	{"glTexSubImage3DOES", (void*)glTexSubImage3DOES},
+	{"glCopyTexSubImage3DOES", (void*)glCopyTexSubImage3DOES},
+	{"glCompressedTexImage3DOES", (void*)glCompressedTexImage3DOES},
+	{"glCompressedTexSubImage3DOES", (void*)glCompressedTexSubImage3DOES},
+	{"glFramebufferTexture3DOES", (void*)glFramebufferTexture3DOES},
+	{"glBindVertexArrayOES", (void*)glBindVertexArrayOES},
+	{"glDeleteVertexArraysOES", (void*)glDeleteVertexArraysOES},
+	{"glGenVertexArraysOES", (void*)glGenVertexArraysOES},
+	{"glIsVertexArrayOES", (void*)glIsVertexArrayOES},
+	{"glDiscardFramebufferEXT", (void*)glDiscardFramebufferEXT},
+	{"glMultiDrawArraysEXT", (void*)glMultiDrawArraysEXT},
+	{"glMultiDrawElementsEXT", (void*)glMultiDrawElementsEXT},
+	{"glGetPerfMonitorGroupsAMD", (void*)glGetPerfMonitorGroupsAMD},
+	{"glGetPerfMonitorCountersAMD", (void*)glGetPerfMonitorCountersAMD},
+	{"glGetPerfMonitorGroupStringAMD", (void*)glGetPerfMonitorGroupStringAMD},
+	{"glGetPerfMonitorCounterStringAMD", (void*)glGetPerfMonitorCounterStringAMD},
+	{"glGetPerfMonitorCounterInfoAMD", (void*)glGetPerfMonitorCounterInfoAMD},
+	{"glGenPerfMonitorsAMD", (void*)glGenPerfMonitorsAMD},
+	{"glDeletePerfMonitorsAMD", (void*)glDeletePerfMonitorsAMD},
+	{"glSelectPerfMonitorCountersAMD", (void*)glSelectPerfMonitorCountersAMD},
+	{"glBeginPerfMonitorAMD", (void*)glBeginPerfMonitorAMD},
+	{"glEndPerfMonitorAMD", (void*)glEndPerfMonitorAMD},
+	{"glGetPerfMonitorCounterDataAMD", (void*)glGetPerfMonitorCounterDataAMD},
+	{"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},
+	{"glCoverageMaskNV", (void*)glCoverageMaskNV},
+	{"glCoverageOperationNV", (void*)glCoverageOperationNV},
+	{"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 gl2_num_funcs = sizeof(gl2_funcs_by_name) / sizeof(struct _gl2_funcs_by_name);
+
+
+#endif
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_opcodes.h b/tools/emulator/opengl/system/GLESv2_enc/gl2_opcodes.h
new file mode 100644
index 0000000..5e7857f
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_opcodes.h
@@ -0,0 +1,217 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __GUARD_gl2_opcodes_h_
+#define __GUARD_gl2_opcodes_h_
+
+#define OP_glActiveTexture 					2048
+#define OP_glAttachShader 					2049
+#define OP_glBindAttribLocation 					2050
+#define OP_glBindBuffer 					2051
+#define OP_glBindFramebuffer 					2052
+#define OP_glBindRenderbuffer 					2053
+#define OP_glBindTexture 					2054
+#define OP_glBlendColor 					2055
+#define OP_glBlendEquation 					2056
+#define OP_glBlendEquationSeparate 					2057
+#define OP_glBlendFunc 					2058
+#define OP_glBlendFuncSeparate 					2059
+#define OP_glBufferData 					2060
+#define OP_glBufferSubData 					2061
+#define OP_glCheckFramebufferStatus 					2062
+#define OP_glClear 					2063
+#define OP_glClearColor 					2064
+#define OP_glClearDepthf 					2065
+#define OP_glClearStencil 					2066
+#define OP_glColorMask 					2067
+#define OP_glCompileShader 					2068
+#define OP_glCompressedTexImage2D 					2069
+#define OP_glCompressedTexSubImage2D 					2070
+#define OP_glCopyTexImage2D 					2071
+#define OP_glCopyTexSubImage2D 					2072
+#define OP_glCreateProgram 					2073
+#define OP_glCreateShader 					2074
+#define OP_glCullFace 					2075
+#define OP_glDeleteBuffers 					2076
+#define OP_glDeleteFramebuffers 					2077
+#define OP_glDeleteProgram 					2078
+#define OP_glDeleteRenderbuffers 					2079
+#define OP_glDeleteShader 					2080
+#define OP_glDeleteTextures 					2081
+#define OP_glDepthFunc 					2082
+#define OP_glDepthMask 					2083
+#define OP_glDepthRangef 					2084
+#define OP_glDetachShader 					2085
+#define OP_glDisable 					2086
+#define OP_glDisableVertexAttribArray 					2087
+#define OP_glDrawArrays 					2088
+#define OP_glDrawElements 					2089
+#define OP_glEnable 					2090
+#define OP_glEnableVertexAttribArray 					2091
+#define OP_glFinish 					2092
+#define OP_glFlush 					2093
+#define OP_glFramebufferRenderbuffer 					2094
+#define OP_glFramebufferTexture2D 					2095
+#define OP_glFrontFace 					2096
+#define OP_glGenBuffers 					2097
+#define OP_glGenerateMipmap 					2098
+#define OP_glGenFramebuffers 					2099
+#define OP_glGenRenderbuffers 					2100
+#define OP_glGenTextures 					2101
+#define OP_glGetActiveAttrib 					2102
+#define OP_glGetActiveUniform 					2103
+#define OP_glGetAttachedShaders 					2104
+#define OP_glGetAttribLocation 					2105
+#define OP_glGetBooleanv 					2106
+#define OP_glGetBufferParameteriv 					2107
+#define OP_glGetError 					2108
+#define OP_glGetFloatv 					2109
+#define OP_glGetFramebufferAttachmentParameteriv 					2110
+#define OP_glGetIntegerv 					2111
+#define OP_glGetProgramiv 					2112
+#define OP_glGetProgramInfoLog 					2113
+#define OP_glGetRenderbufferParameteriv 					2114
+#define OP_glGetShaderiv 					2115
+#define OP_glGetShaderInfoLog 					2116
+#define OP_glGetShaderPrecisionFormat 					2117
+#define OP_glGetShaderSource 					2118
+#define OP_glGetString 					2119
+#define OP_glGetTexParameterfv 					2120
+#define OP_glGetTexParameteriv 					2121
+#define OP_glGetUniformfv 					2122
+#define OP_glGetUniformiv 					2123
+#define OP_glGetUniformLocation 					2124
+#define OP_glGetVertexAttribfv 					2125
+#define OP_glGetVertexAttribiv 					2126
+#define OP_glGetVertexAttribPointerv 					2127
+#define OP_glHint 					2128
+#define OP_glIsBuffer 					2129
+#define OP_glIsEnabled 					2130
+#define OP_glIsFramebuffer 					2131
+#define OP_glIsProgram 					2132
+#define OP_glIsRenderbuffer 					2133
+#define OP_glIsShader 					2134
+#define OP_glIsTexture 					2135
+#define OP_glLineWidth 					2136
+#define OP_glLinkProgram 					2137
+#define OP_glPixelStorei 					2138
+#define OP_glPolygonOffset 					2139
+#define OP_glReadPixels 					2140
+#define OP_glReleaseShaderCompiler 					2141
+#define OP_glRenderbufferStorage 					2142
+#define OP_glSampleCoverage 					2143
+#define OP_glScissor 					2144
+#define OP_glShaderBinary 					2145
+#define OP_glShaderSource 					2146
+#define OP_glStencilFunc 					2147
+#define OP_glStencilFuncSeparate 					2148
+#define OP_glStencilMask 					2149
+#define OP_glStencilMaskSeparate 					2150
+#define OP_glStencilOp 					2151
+#define OP_glStencilOpSeparate 					2152
+#define OP_glTexImage2D 					2153
+#define OP_glTexParameterf 					2154
+#define OP_glTexParameterfv 					2155
+#define OP_glTexParameteri 					2156
+#define OP_glTexParameteriv 					2157
+#define OP_glTexSubImage2D 					2158
+#define OP_glUniform1f 					2159
+#define OP_glUniform1fv 					2160
+#define OP_glUniform1i 					2161
+#define OP_glUniform1iv 					2162
+#define OP_glUniform2f 					2163
+#define OP_glUniform2fv 					2164
+#define OP_glUniform2i 					2165
+#define OP_glUniform2iv 					2166
+#define OP_glUniform3f 					2167
+#define OP_glUniform3fv 					2168
+#define OP_glUniform3i 					2169
+#define OP_glUniform3iv 					2170
+#define OP_glUniform4f 					2171
+#define OP_glUniform4fv 					2172
+#define OP_glUniform4i 					2173
+#define OP_glUniform4iv 					2174
+#define OP_glUniformMatrix2fv 					2175
+#define OP_glUniformMatrix3fv 					2176
+#define OP_glUniformMatrix4fv 					2177
+#define OP_glUseProgram 					2178
+#define OP_glValidateProgram 					2179
+#define OP_glVertexAttrib1f 					2180
+#define OP_glVertexAttrib1fv 					2181
+#define OP_glVertexAttrib2f 					2182
+#define OP_glVertexAttrib2fv 					2183
+#define OP_glVertexAttrib3f 					2184
+#define OP_glVertexAttrib3fv 					2185
+#define OP_glVertexAttrib4f 					2186
+#define OP_glVertexAttrib4fv 					2187
+#define OP_glVertexAttribPointer 					2188
+#define OP_glViewport 					2189
+#define OP_glEGLImageTargetTexture2DOES 					2190
+#define OP_glEGLImageTargetRenderbufferStorageOES 					2191
+#define OP_glGetProgramBinaryOES 					2192
+#define OP_glProgramBinaryOES 					2193
+#define OP_glMapBufferOES 					2194
+#define OP_glUnmapBufferOES 					2195
+#define OP_glTexImage3DOES 					2196
+#define OP_glTexSubImage3DOES 					2197
+#define OP_glCopyTexSubImage3DOES 					2198
+#define OP_glCompressedTexImage3DOES 					2199
+#define OP_glCompressedTexSubImage3DOES 					2200
+#define OP_glFramebufferTexture3DOES 					2201
+#define OP_glBindVertexArrayOES 					2202
+#define OP_glDeleteVertexArraysOES 					2203
+#define OP_glGenVertexArraysOES 					2204
+#define OP_glIsVertexArrayOES 					2205
+#define OP_glDiscardFramebufferEXT 					2206
+#define OP_glMultiDrawArraysEXT 					2207
+#define OP_glMultiDrawElementsEXT 					2208
+#define OP_glGetPerfMonitorGroupsAMD 					2209
+#define OP_glGetPerfMonitorCountersAMD 					2210
+#define OP_glGetPerfMonitorGroupStringAMD 					2211
+#define OP_glGetPerfMonitorCounterStringAMD 					2212
+#define OP_glGetPerfMonitorCounterInfoAMD 					2213
+#define OP_glGenPerfMonitorsAMD 					2214
+#define OP_glDeletePerfMonitorsAMD 					2215
+#define OP_glSelectPerfMonitorCountersAMD 					2216
+#define OP_glBeginPerfMonitorAMD 					2217
+#define OP_glEndPerfMonitorAMD 					2218
+#define OP_glGetPerfMonitorCounterDataAMD 					2219
+#define OP_glRenderbufferStorageMultisampleIMG 					2220
+#define OP_glFramebufferTexture2DMultisampleIMG 					2221
+#define OP_glDeleteFencesNV 					2222
+#define OP_glGenFencesNV 					2223
+#define OP_glIsFenceNV 					2224
+#define OP_glTestFenceNV 					2225
+#define OP_glGetFenceivNV 					2226
+#define OP_glFinishFenceNV 					2227
+#define OP_glSetFenceNV 					2228
+#define OP_glCoverageMaskNV 					2229
+#define OP_glCoverageOperationNV 					2230
+#define OP_glGetDriverControlsQCOM 					2231
+#define OP_glGetDriverControlStringQCOM 					2232
+#define OP_glEnableDriverControlQCOM 					2233
+#define OP_glDisableDriverControlQCOM 					2234
+#define OP_glExtGetTexturesQCOM 					2235
+#define OP_glExtGetBuffersQCOM 					2236
+#define OP_glExtGetRenderbuffersQCOM 					2237
+#define OP_glExtGetFramebuffersQCOM 					2238
+#define OP_glExtGetTexLevelParameterivQCOM 					2239
+#define OP_glExtTexObjectStateOverrideiQCOM 					2240
+#define OP_glExtGetTexSubImageQCOM 					2241
+#define OP_glExtGetBufferPointervQCOM 					2242
+#define OP_glExtGetShadersQCOM 					2243
+#define OP_glExtGetProgramsQCOM 					2244
+#define OP_glExtIsProgramBinaryQCOM 					2245
+#define OP_glExtGetProgramBinarySourceQCOM 					2246
+#define OP_glStartTilingQCOM 					2247
+#define OP_glEndTilingQCOM 					2248
+#define OP_glVertexAttribPointerData 					2249
+#define OP_glVertexAttribPointerOffset 					2250
+#define OP_glDrawElementsOffset 					2251
+#define OP_glDrawElementsData 					2252
+#define OP_glGetCompressedTextureFormats 					2253
+#define OP_glShaderString 					2254
+#define OP_glFinishRoundTrip 					2255
+#define OP_last 					2256
+
+
+#endif
diff --git a/tools/emulator/opengl/system/GLESv2_enc/gl2_types.h b/tools/emulator/opengl/system/GLESv2_enc/gl2_types.h
new file mode 100644
index 0000000..bfff61d
--- /dev/null
+++ b/tools/emulator/opengl/system/GLESv2_enc/gl2_types.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 _GL_2_TYPES_H_
+#define _GL_2_TYPES_H_
+#include "gl_base_types.h"
+
+typedef void *GLvoidptr;
+#endif
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/Android.mk b/tools/emulator/opengl/system/OpenglSystemCommon/Android.mk
new file mode 100644
index 0000000..6198748
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+
+$(call emugl-begin-shared-library,libOpenglSystemCommon)
+$(call emugl-import,libGLESv1_enc libGLESv2_enc lib_renderControl_enc)
+
+LOCAL_SRC_FILES := \
+    HostConnection.cpp \
+    QemuPipeStream.cpp \
+    ThreadInfo.cpp
+
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH) bionic/libc/private)
+
+$(call emugl-end-module)
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h b/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h
new file mode 100644
index 0000000..3c8cb55
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h
@@ -0,0 +1,41 @@
+/*
+* Copyright 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 _SYSTEM_COMMON_EGL_CLIENT_IFACE_H
+#define _SYSTEM_COMMON_EGL_CLIENT_IFACE_H
+
+struct EGLThreadInfo;  // defined in ThreadInfo.h
+
+typedef struct {
+    EGLThreadInfo* (*getThreadInfo)();
+    const char* (*getGLString)(int glEnum);
+} EGLClient_eglInterface;
+
+typedef struct {
+    void* (*getProcAddress)(const char *funcName);
+    void (*init)();
+    void (*finish)();
+} EGLClient_glesInterface;
+
+//
+// Any GLES/GLES2 client API library should define a function named "init_emul_gles"
+// with the following prototype,
+// It will be called by EGL after loading the GLES library for initialization
+// and exchanging interface function pointers.
+//
+typedef EGLClient_glesInterface *(*init_emul_gles_t)(EGLClient_eglInterface *eglIface);
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.cpp b/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.cpp
new file mode 100644
index 0000000..940f5ae
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.cpp
@@ -0,0 +1,153 @@
+/*
+* 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 "HostConnection.h"
+#include "TcpStream.h"
+#include "QemuPipeStream.h"
+#include "ThreadInfo.h"
+#include <cutils/log.h>
+#include "GLEncoder.h"
+#include "GL2Encoder.h"
+
+#define STREAM_BUFFER_SIZE  4*1024*1024
+#define STREAM_PORT_NUM     22468
+
+/* Set to 1 to use a QEMU pipe, or 0 for a TCP connection */
+#define  USE_QEMU_PIPE  1
+
+HostConnection::HostConnection() :
+    m_stream(NULL),
+    m_glEnc(NULL),
+    m_gl2Enc(NULL),
+    m_rcEnc(NULL)
+{
+}
+
+HostConnection::~HostConnection()
+{
+    delete m_stream;
+    delete m_glEnc;
+    delete m_gl2Enc;
+    delete m_rcEnc;
+}
+
+HostConnection *HostConnection::get()
+{
+    /* TODO: Make this configurable with a system property */
+    const int useQemuPipe = USE_QEMU_PIPE;
+
+    // Get thread info
+    EGLThreadInfo *tinfo = getEGLThreadInfo();
+    if (!tinfo) {
+        return NULL;
+    }
+
+    if (tinfo->hostConn == NULL) {
+        HostConnection *con = new HostConnection();
+        if (NULL == con) {
+            return NULL;
+        }
+
+        if (useQemuPipe) {
+            QemuPipeStream *stream = new QemuPipeStream(STREAM_BUFFER_SIZE);
+            if (!stream) {
+                ALOGE("Failed to create QemuPipeStream for host connection!!!\n");
+                delete con;
+                return NULL;
+            }
+            if (stream->connect() < 0) {
+                ALOGE("Failed to connect to host (QemuPipeStream)!!!\n");
+                delete stream;
+                delete con;
+                return NULL;
+            }
+            con->m_stream = stream;
+        }
+        else /* !useQemuPipe */
+        {
+            TcpStream *stream = new TcpStream(STREAM_BUFFER_SIZE);
+            if (!stream) {
+                ALOGE("Failed to create TcpStream for host connection!!!\n");
+                delete con;
+                return NULL;
+            }
+
+            if (stream->connect("10.0.2.2", STREAM_PORT_NUM) < 0) {
+                ALOGE("Failed to connect to host (TcpStream)!!!\n");
+                delete stream;
+                delete con;
+                return NULL;
+            }
+            con->m_stream = stream;
+        }
+
+        // send zero 'clientFlags' to the host.
+        unsigned int *pClientFlags =
+                (unsigned int *)con->m_stream->allocBuffer(sizeof(unsigned int));
+        *pClientFlags = 0;
+        con->m_stream->commitBuffer(sizeof(unsigned int));
+
+        ALOGD("HostConnection::get() New Host Connection established %p, tid %d\n", con, gettid());
+        tinfo->hostConn = con;
+    }
+
+    return tinfo->hostConn;
+}
+
+GLEncoder *HostConnection::glEncoder()
+{
+    if (!m_glEnc) {
+        m_glEnc = new GLEncoder(m_stream);
+        DBG("HostConnection::glEncoder new encoder %p, tid %d", m_glEnc, gettid());
+        m_glEnc->setContextAccessor(s_getGLContext);
+    }
+    return m_glEnc;
+}
+
+GL2Encoder *HostConnection::gl2Encoder()
+{
+    if (!m_gl2Enc) {
+        m_gl2Enc = new GL2Encoder(m_stream);
+        DBG("HostConnection::gl2Encoder new encoder %p, tid %d", m_gl2Enc, gettid());
+        m_gl2Enc->setContextAccessor(s_getGL2Context);
+    }
+    return m_gl2Enc;
+}
+
+renderControl_encoder_context_t *HostConnection::rcEncoder()
+{
+    if (!m_rcEnc) {
+        m_rcEnc = new renderControl_encoder_context_t(m_stream);
+    }
+    return m_rcEnc;
+}
+
+gl_client_context_t *HostConnection::s_getGLContext()
+{
+    EGLThreadInfo *ti = getEGLThreadInfo();
+    if (ti->hostConn) {
+        return ti->hostConn->m_glEnc;
+    }
+    return NULL;
+}
+
+gl2_client_context_t *HostConnection::s_getGL2Context()
+{
+    EGLThreadInfo *ti = getEGLThreadInfo();
+    if (ti->hostConn) {
+        return ti->hostConn->m_gl2Enc;
+    }
+    return NULL;
+}
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.h b/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.h
new file mode 100644
index 0000000..e7a5ac4
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/HostConnection.h
@@ -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.
+*/
+#ifndef __COMMON_HOST_CONNECTION_H
+#define __COMMON_HOST_CONNECTION_H
+
+#include "IOStream.h"
+#include "renderControl_enc.h"
+
+class GLEncoder;
+class gl_client_context_t;
+class GL2Encoder;
+class gl2_client_context_t;
+
+class HostConnection
+{
+public:
+    static HostConnection *get();
+    ~HostConnection();
+
+    GLEncoder *glEncoder();
+    GL2Encoder *gl2Encoder();
+    renderControl_encoder_context_t *rcEncoder();
+
+    void flush() {
+        if (m_stream) {
+            m_stream->flush();
+        }
+    }
+
+private:
+    HostConnection();
+    static gl_client_context_t  *s_getGLContext();
+    static gl2_client_context_t *s_getGL2Context();
+
+private:
+    IOStream *m_stream;
+    GLEncoder   *m_glEnc;
+    GL2Encoder  *m_gl2Enc;
+    renderControl_encoder_context_t *m_rcEnc;
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp b/tools/emulator/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp
new file mode 100644
index 0000000..50c3d8b
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp
@@ -0,0 +1,190 @@
+/*
+* 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 "QemuPipeStream.h"
+#include <hardware/qemu_pipe.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+QemuPipeStream::QemuPipeStream(size_t bufSize) :
+    IOStream(bufSize),
+    m_sock(-1),
+    m_bufsize(bufSize),
+    m_buf(NULL)
+{
+}
+
+QemuPipeStream::QemuPipeStream(int sock, size_t bufSize) :
+    IOStream(bufSize),
+    m_sock(sock),
+    m_bufsize(bufSize),
+    m_buf(NULL)
+{
+}
+
+QemuPipeStream::~QemuPipeStream()
+{
+    if (m_sock >= 0) {
+        ::close(m_sock);
+    }
+    if (m_buf != NULL) {
+        free(m_buf);
+    }
+}
+
+
+int QemuPipeStream::connect(void)
+{
+    m_sock = qemu_pipe_open("opengles");
+    if (!valid()) return -1;
+    return 0;
+}
+
+void *QemuPipeStream::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 QemuPipeStream::commitBuffer(size_t size)
+{
+    return writeFully(m_buf, size);
+}
+
+int QemuPipeStream::writeFully(const void *buf, size_t len)
+{
+    //DBG(">> QemuPipeStream::writeFully %d\n", len);
+    if (!valid()) return -1;
+
+    size_t res = len;
+    int retval = 0;
+
+    while (res > 0) {
+        ssize_t stat = ::write(m_sock, (const char *)(buf) + (len - res), res);
+        if (stat > 0) {
+            res -= stat;
+            continue;
+        }
+        if (stat == 0) { /* EOF */
+            ERR("QemuPipeStream::writeFully failed: premature EOF\n");
+            retval = -1;
+            break;
+        }
+        if (errno == EINTR) {
+            continue;
+        }
+        retval =  stat;
+        ERR("QemuPipeStream::writeFully failed: %s\n", strerror(errno));
+        break;
+    }
+    //DBG("<< QemuPipeStream::writeFully %d\n", len );
+    return retval;
+}
+
+const unsigned char *QemuPipeStream::readFully(void *buf, size_t len)
+{
+    //DBG(">> QemuPipeStream::readFully %d\n", len);
+    if (!valid()) return NULL;
+    if (!buf) {
+        if (len>0) ERR("QemuPipeStream::readFully failed, buf=NULL, len %d", len);
+        return NULL;  // do not allow NULL buf in that implementation
+    }
+    size_t res = len;
+    while (res > 0) {
+        ssize_t stat = ::read(m_sock, (char *)(buf) + len - res, len);
+        if (stat == 0) {
+            // client shutdown;
+            return NULL;
+        } else if (stat < 0) {
+            if (errno == EINTR) {
+                continue;
+            } else {
+                ERR("QemuPipeStream::readFully failed (buf %p): %s\n",
+                    buf, strerror(errno));
+                return NULL;
+            }
+        } else {
+            res -= stat;
+        }
+    }
+    //DBG("<< QemuPipeStream::readFully %d\n", len);
+    return (const unsigned char *)buf;
+}
+
+const unsigned char *QemuPipeStream::read( void *buf, size_t *inout_len)
+{
+    //DBG(">> QemuPipeStream::read %d\n", *inout_len);
+    if (!valid()) return NULL;
+    if (!buf) {
+      ERR("QemuPipeStream::read failed, buf=NULL");
+      return NULL;  // do not allow NULL buf in that implementation
+    }
+
+    int n = recv(buf, *inout_len);
+
+    if (n > 0) {
+        *inout_len = n;
+        return (const unsigned char *)buf;
+    }
+
+    //DBG("<< QemuPipeStream::read %d\n", *inout_len);
+    return NULL;
+}
+
+int QemuPipeStream::recv(void *buf, size_t len)
+{
+    if (!valid()) return int(ERR_INVALID_SOCKET);
+    char* p = (char *)buf;
+    int ret = 0;
+    while(len > 0) {
+        int res = ::read(m_sock, p, len);
+        if (res > 0) {
+            p += res;
+            ret += res;
+            len -= res;
+            continue;
+        }
+        if (res == 0) { /* EOF */
+             break;
+        }
+        if (errno == EINTR)
+            continue;
+
+        /* A real error */
+        if (ret == 0)
+            ret = -1;
+        break;
+    }
+    return ret;
+}
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/QemuPipeStream.h b/tools/emulator/opengl/system/OpenglSystemCommon/QemuPipeStream.h
new file mode 100644
index 0000000..57ee399
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/QemuPipeStream.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 __QEMU_PIPE_STREAM_H
+#define __QEMU_PIPE_STREAM_H
+
+/* This file implements an IOStream that uses a QEMU fast-pipe
+ * to communicate with the emulator's 'opengles' service. See
+ * <hardware/qemu_pipe.h> for more details.
+ */
+#include <stdlib.h>
+#include "IOStream.h"
+
+class QemuPipeStream : public IOStream {
+public:
+    typedef enum { ERR_INVALID_SOCKET = -1000 } QemuPipeStreamError;
+
+    explicit QemuPipeStream(size_t bufsize = 10000);
+    ~QemuPipeStream();
+    int connect(void);
+
+    virtual void *allocBuffer(size_t minSize);
+    virtual int commitBuffer(size_t size);
+    virtual const unsigned char *readFully( void *buf, size_t len);
+    virtual const unsigned char *read( void *buf, size_t *inout_len);
+
+    bool valid() { return m_sock >= 0; }
+    int recv(void *buf, size_t len);
+
+    virtual int writeFully(const void *buf, size_t len);
+
+private:
+    int m_sock;
+    size_t m_bufsize;
+    unsigned char *m_buf;
+    QemuPipeStream(int sock, size_t bufSize);
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/ThreadInfo.cpp b/tools/emulator/opengl/system/OpenglSystemCommon/ThreadInfo.cpp
new file mode 100644
index 0000000..75da8f2
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/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->hostConn;
+        delete ti;
+    }
+}
+
+EGLThreadInfo *slow_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/system/OpenglSystemCommon/ThreadInfo.h b/tools/emulator/opengl/system/OpenglSystemCommon/ThreadInfo.h
new file mode 100644
index 0000000..0328733
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/ThreadInfo.h
@@ -0,0 +1,59 @@
+/*
+* 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 "HostConnection.h"
+#include <pthread.h>
+#ifdef HAVE_ANDROID_OS
+#include <bionic_tls.h>
+#endif
+
+struct EGLContext_t;
+
+struct EGLThreadInfo
+{
+    EGLThreadInfo() : currentContext(NULL), hostConn(NULL), eglError(EGL_SUCCESS) {}
+
+    EGLContext_t *currentContext;
+    HostConnection *hostConn;
+    int           eglError;
+};
+
+
+EGLThreadInfo *slow_getEGLThreadInfo();
+
+#ifdef HAVE_ANDROID_OS
+    // We have a dedicated TLS slot in bionic
+    inline EGLThreadInfo* getEGLThreadInfo() {
+        EGLThreadInfo *tInfo =
+             (EGLThreadInfo *)(((unsigned *)__get_tls())[TLS_SLOT_OPENGL]);
+        if (!tInfo) {
+            tInfo = slow_getEGLThreadInfo();
+            ((uint32_t *)__get_tls())[TLS_SLOT_OPENGL] = (uint32_t)tInfo;
+        }
+        return tInfo;
+    }
+#else
+    inline EGLThreadInfo* getEGLThreadInfo() {
+        return slow_getEGLThreadInfo();
+    }
+#endif
+
+
+
+
+#endif // of _THREAD_INFO_H
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h b/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h
new file mode 100644
index 0000000..e879409
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h
@@ -0,0 +1,106 @@
+/*
+* Copyright 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 __GRALLOC_CB_H__
+#define __GRALLOC_CB_H__
+
+#include <hardware/hardware.h>
+#include <hardware/gralloc.h>
+#include <cutils/native_handle.h>
+
+#define BUFFER_HANDLE_MAGIC ((int)0xabfabfab)
+#define CB_HANDLE_NUM_INTS(nfds) (int)((sizeof(cb_handle_t) - (nfds)*sizeof(int)) / sizeof(int))
+
+//
+// Our buffer handle structure
+//
+struct cb_handle_t : public native_handle {
+
+    cb_handle_t(int p_fd, int p_ashmemSize, int p_usage,
+                int p_width, int p_height,
+                int p_glFormat, int p_glType) :
+        fd(p_fd),
+        magic(BUFFER_HANDLE_MAGIC),
+        usage(p_usage),
+        width(p_width),
+        height(p_height),
+        glFormat(p_glFormat),
+        glType(p_glType),
+        ashmemSize(p_ashmemSize),
+        ashmemBase(NULL),
+        ashmemBasePid(0),
+        mappedPid(0),
+        lockedLeft(0),
+        lockedTop(0),
+        lockedWidth(0),
+        lockedHeight(0),
+        hostHandle(0)
+    {
+        version = sizeof(native_handle);
+        numFds = 0;
+        numInts = CB_HANDLE_NUM_INTS(numFds);
+    }
+
+    ~cb_handle_t() {
+        magic = 0;
+    }
+
+    void setFd(int p_fd) {
+        if (p_fd >= 0) {
+            numFds = 1;
+        }
+        else {
+            numFds = 0;
+        }
+        fd = p_fd;
+        numInts = CB_HANDLE_NUM_INTS(numFds);
+    }
+
+    static bool validate(cb_handle_t * hnd) {
+        return (hnd && 
+                hnd->version == sizeof(native_handle) &&
+                hnd->magic == BUFFER_HANDLE_MAGIC &&
+                hnd->numInts == CB_HANDLE_NUM_INTS(hnd->numFds));
+    }
+
+    bool canBePosted() {
+        return (0 != (usage & GRALLOC_USAGE_HW_FB));
+    }
+
+    // file-descriptors
+    int fd;  // ashmem fd (-1 of ashmem region did not allocated, i.e. no SW access needed)
+
+    // ints
+    int magic;              // magic number in order to validate a pointer to be a cb_handle_t
+    int usage;              // usage bits the buffer was created with
+    int width;              // buffer width
+    int height;             // buffer height
+    int glFormat;           // OpenGL format enum used for host h/w color buffer
+    int glType;             // OpenGL type enum used when uploading to host
+    int ashmemSize;         // ashmem region size for the buffer (0 unless is HW_FB buffer or
+                            //                                    s/w access is needed)
+    int ashmemBase;         // CPU address of the mapped ashmem region
+    int ashmemBasePid;      // process id which mapped the ashmem region
+    int mappedPid;          // process id which succeeded gralloc_register call
+    int lockedLeft;         // region of buffer locked for s/w write
+    int lockedTop;
+    int lockedWidth;
+    int lockedHeight;
+    uint32_t hostHandle;
+};
+
+
+#endif //__GRALLOC_CB_H__
diff --git a/tools/emulator/opengl/system/egl/Android.mk b/tools/emulator/opengl/system/egl/Android.mk
new file mode 100644
index 0000000..cf55b48
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/Android.mk
@@ -0,0 +1,42 @@
+ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER))
+
+LOCAL_PATH := $(call my-dir)
+
+$(call emugl-begin-shared-library,libEGL_emulation)
+$(call emugl-import,libOpenglSystemCommon)
+$(call emugl-set-shared-library-subpath,egl)
+
+LOCAL_CFLAGS += -DLOG_TAG=\"EGL_emulation\" -DEGL_EGLEXT_PROTOTYPES -DWITH_GLES2
+
+LOCAL_SRC_FILES := \
+    eglDisplay.cpp \
+    egl.cpp \
+    ClientAPIExts.cpp
+
+LOCAL_SHARED_LIBRARIES += libdl
+
+# Used to access the Bionic private OpenGL TLS slot
+LOCAL_C_INCLUDES += bionic/libc/private
+
+$(call emugl-end-module)
+
+#### 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 full_mips sdk sdk_x86 sdk_mips google_sdk google_sdk_x86 google_sdk_mips,$(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 full_x86 full_mips sdk sdk_x86 sdk_mips google_sdk google_sdk_x86 google_sdk_mips')
+
+endif # BUILD_EMULATOR_OPENGL_DRIVER != false
diff --git a/tools/emulator/opengl/system/egl/ClientAPIExts.cpp b/tools/emulator/opengl/system/egl/ClientAPIExts.cpp
new file mode 100644
index 0000000..5e81afe
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/ClientAPIExts.cpp
@@ -0,0 +1,157 @@
+/*
+* 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 "ClientAPIExts.h"
+#include "ThreadInfo.h"
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+#include "eglContext.h"
+
+namespace ClientAPIExts
+{
+
+//
+// define function pointer type for each extention function
+// typename has the form __egl_{funcname}_t
+//
+#define FUNC_TYPE(fname) __egl_ ## fname ## _t
+#define API_ENTRY(fname,params,args) \
+    typedef void (GL_APIENTRY *FUNC_TYPE(fname)) params;
+
+#define API_ENTRY_RET(rtype,fname,params,args) \
+    typedef rtype (GL_APIENTRY *FUNC_TYPE(fname)) params;
+
+#include "ClientAPIExts.in"
+#undef API_ENTRY
+#undef API_ENTRY_RET
+
+/////
+// Define static table to store the function value for each
+// client API. functions pointers will get initialized through
+// ClientAPIExts::initClientFuncs function after each client API has been
+// loaded.
+/////
+#define API_ENTRY(fname,params,args) \
+    FUNC_TYPE(fname) fname;
+
+#define API_ENTRY_RET(rtype,fname,params,args) \
+    API_ENTRY(fname,params,args)
+
+static struct _ext_table
+{
+#include "ClientAPIExts.in"
+} s_client_extensions[2];
+
+#undef API_ENTRY
+#undef API_ENTRY_RET
+
+//
+// This function initialized each entry in the s_client_extensions
+// struct at the givven index using the givven client interface
+//
+void initClientFuncs(const EGLClient_glesInterface *iface, int idx)
+{
+#define API_ENTRY(fname,params,args) \
+    s_client_extensions[idx].fname = \
+          (FUNC_TYPE(fname))iface->getProcAddress(#fname);
+
+#define API_ENTRY_RET(rtype,fname,params,args) \
+    API_ENTRY(fname,params,args)
+
+    //
+    // reset all func pointers to NULL
+    //
+    memset(&s_client_extensions[idx], 0, sizeof(struct _ext_table));
+
+    //
+    // And now query the GLES library for each proc address
+    //
+#include "ClientAPIExts.in"
+#undef API_ENTRY
+#undef API_ENTRY_RET
+}
+
+//
+// Define implementation for each extension function which checks
+// the current context version and calls to the correct client API
+// function.
+//
+#define API_ENTRY(fname,params,args) \
+    static void _egl_ ## fname params \
+    { \
+        EGLThreadInfo* thread  = getEGLThreadInfo(); \
+        if (!thread->currentContext) { \
+            return; \
+        } \
+        int idx = (int)thread->currentContext->version - 1; \
+        if (!s_client_extensions[idx].fname) { \
+            return; \
+        } \
+        (*s_client_extensions[idx].fname) args; \
+    }
+
+#define API_ENTRY_RET(rtype,fname,params,args) \
+    static rtype _egl_ ## fname params \
+    { \
+        EGLThreadInfo* thread  = getEGLThreadInfo(); \
+        if (!thread->currentContext) { \
+            return (rtype)0; \
+        } \
+        int idx = (int)thread->currentContext->version - 1; \
+        if (!s_client_extensions[idx].fname) { \
+            return (rtype)0; \
+        } \
+        return (*s_client_extensions[idx].fname) args; \
+    }
+
+#include "ClientAPIExts.in"
+#undef API_ENTRY
+#undef API_ENTRY_RET
+
+//
+// Define a table to map function names to the local _egl_ version of
+// the extension function, to be used in eglGetProcAddress.
+//
+#define API_ENTRY(fname,params,args) \
+    { #fname, (void*)_egl_ ## fname},
+#define API_ENTRY_RET(rtype,fname,params,args) \
+    API_ENTRY(fname,params,args)
+
+static const struct _client_ext_funcs {
+    const char *fname;
+    void* proc;
+} s_client_ext_funcs[] = {
+#include "ClientAPIExts.in"
+};
+static const int numExtFuncs = sizeof(s_client_ext_funcs) / 
+                               sizeof(s_client_ext_funcs[0]);
+
+#undef API_ENTRY
+#undef API_ENTRY_RET
+
+//
+// returns the __egl_ version of the givven extension function name.
+//
+void* getProcAddress(const char *fname)
+{
+    for (int i=0; i<numExtFuncs; i++) {
+        if (!strcmp(fname, s_client_ext_funcs[i].fname)) {
+            return s_client_ext_funcs[i].proc;
+        }
+    }
+    return NULL;
+}
+
+} // of namespace ClientAPIExts
diff --git a/tools/emulator/opengl/system/egl/ClientAPIExts.h b/tools/emulator/opengl/system/egl/ClientAPIExts.h
new file mode 100644
index 0000000..eee9172
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/ClientAPIExts.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 _CLIENT_APIS_EXTS_H
+#define _CLIENT_APIS_EXTS_H
+
+#include "EGLClientIface.h"
+
+namespace ClientAPIExts
+{
+
+void initClientFuncs(const EGLClient_glesInterface *iface, int idx);
+void* getProcAddress(const char *fname);
+
+} // of namespace ClientAPIExts
+
+#endif
diff --git a/tools/emulator/opengl/system/egl/ClientAPIExts.in b/tools/emulator/opengl/system/egl/ClientAPIExts.in
new file mode 100644
index 0000000..5850701
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/ClientAPIExts.in
@@ -0,0 +1,201 @@
+//
+// Each extension function should have one of the following
+// macro definitions:
+//    API_ENTRY(funcname, paramlist, arglist)
+//  -or- (if the function has a return value)
+//    API_ENTRY_RET(return_type,funcname, paramlist, arglist)
+//
+API_ENTRY(glEGLImageTargetTexture2DOES,
+          (GLenum target, GLeglImageOES image),
+          (target, image))
+
+API_ENTRY(glEGLImageTargetRenderbufferStorageOES,
+          (GLenum target, GLeglImageOES image),
+          (target, image))
+
+API_ENTRY(glBlendEquationSeparateOES,
+          (GLenum modeRGB, GLenum modeAlpha),
+          (modeRGB, modeAlpha))
+
+API_ENTRY(glBlendFuncSeparateOES,
+          (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha),
+          (srcRGB, dstRGB, srcAlpha, dstAlpha))
+
+API_ENTRY(glBlendEquationOES,
+          (GLenum mode),
+          (mode))
+
+API_ENTRY(glCurrentPaletteMatrixOES,
+          (GLuint matrixpaletteindex),
+          (matrixpaletteindex))
+
+API_ENTRY(glLoadPaletteFromModelViewMatrixOES,
+          (void),
+          ())
+
+API_ENTRY(glMatrixIndexPointerOES,
+          (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer),
+          (size, type, stride, pointer))
+
+API_ENTRY(glWeightPointerOES,
+          (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer),
+          (size, type, stride, pointer))
+
+API_ENTRY(glDepthRangefOES,
+          (GLclampf zNear, GLclampf zFar),
+          (zNear, zFar))
+
+API_ENTRY(glFrustumfOES,
+          (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar),
+          (left, right, bottom, top, zNear, zFar))
+
+API_ENTRY(glOrthofOES,
+          (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar),
+          (left, right, bottom, top, zNear, zFar))
+
+API_ENTRY(glClipPlanefOES,
+          (GLenum plane, const GLfloat *equation),
+          (plane, equation))
+
+API_ENTRY(glGetClipPlanefOES,
+          (GLenum pname, GLfloat * eqn),
+          (pname, eqn))
+
+API_ENTRY(glClearDepthfOES,
+          (GLclampf depth),
+          (depth))
+
+API_ENTRY(glPointSizePointerOES,
+          (GLenum type, GLsizei stride, const GLvoid *pointer),
+          (type, stride, pointer))
+
+API_ENTRY(glTexGenfOES,
+          (GLenum coord, GLenum pname, GLfloat param),
+          (coord, pname, param))
+
+API_ENTRY(glTexGenfvOES,
+          (GLenum coord, GLenum pname, const GLfloat *params),
+          (coord, pname, params))
+
+API_ENTRY(glTexGeniOES,
+          (GLenum coord, GLenum pname, GLint param),
+          (coord, pname, param))
+
+API_ENTRY(glTexGenivOES,
+          (GLenum coord, GLenum pname, const GLint *params),
+          (coord, pname, params))
+
+API_ENTRY(glTexGenxOES,
+          (GLenum coord, GLenum pname, GLfixed param),
+          (coord, pname, param))
+
+API_ENTRY(glTexGenxvOES,
+          (GLenum coord, GLenum pname, const GLfixed *params),
+          (coord, pname, params))
+
+API_ENTRY(glGetTexGenfvOES,
+          (GLenum coord, GLenum pname, GLfloat *params),
+          (coord, pname, params))
+
+API_ENTRY(glGetTexGenivOES,
+          (GLenum coord, GLenum pname, GLint *params),
+          (coord, pname, params))
+
+API_ENTRY(glGetTexGenxvOES,
+          (GLenum coord, GLenum pname, GLfixed *params),
+          (coord, pname, params))
+
+API_ENTRY_RET(GLboolean,
+              glIsRenderbufferOES,
+              (GLuint renderbuffer),
+              (renderbuffer))
+
+API_ENTRY(glBindRenderbufferOES,
+          (GLenum target, GLuint renderbuffer),
+          (target, renderbuffer))
+
+API_ENTRY(glDeleteRenderbuffersOES,
+          (GLsizei n, const GLuint* renderbuffers),
+          (n, renderbuffers))
+
+API_ENTRY(glGenRenderbuffersOES,
+          (GLsizei n, GLuint* renderbuffers),
+          (n, renderbuffers))
+
+API_ENTRY(glRenderbufferStorageOES,
+          (GLenum target, GLenum internalformat, GLsizei width, GLsizei height),
+          (target, internalformat, width, height))
+
+API_ENTRY(glGetRenderbufferParameterivOES,
+          (GLenum target, GLenum pname, GLint* params),
+          (target, pname, params))
+
+API_ENTRY_RET(GLboolean,
+              glIsFramebufferOES,
+              (GLuint framebuffer),
+              (framebuffer))
+
+API_ENTRY(glBindFramebufferOES,
+          (GLenum target, GLuint framebuffer),
+          (target, framebuffer))
+
+API_ENTRY(glDeleteFramebuffersOES,
+          (GLsizei n, const GLuint* framebuffers),
+          (n, framebuffers))
+
+API_ENTRY(glGenFramebuffersOES,
+          (GLsizei n, GLuint* framebuffers),
+          (n, framebuffers))
+
+API_ENTRY_RET(GLenum,
+              glCheckFramebufferStatusOES,
+              (GLenum target),
+              (target))
+
+API_ENTRY(glFramebufferTexture2DOES,
+          (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level),
+          (target, attachment, textarget, texture, level))
+
+API_ENTRY(glFramebufferRenderbufferOES,
+          (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer),
+          (target, attachment, renderbuffertarget, renderbuffer))
+
+API_ENTRY(glGetFramebufferAttachmentParameterivOES,
+          (GLenum target, GLenum attachment, GLenum pname, GLint* params),
+          (target, attachment, pname, params))
+
+API_ENTRY(glGenerateMipmapOES,
+          (GLenum target),
+          (target))
+
+API_ENTRY(glDrawTexsOES,
+          (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height),
+          (x, y, z, width, height))
+
+API_ENTRY(glDrawTexiOES,
+          (GLint x, GLint y, GLint z, GLint width, GLint height),
+          (x, y, z, width, height))
+
+API_ENTRY(glDrawTexfOES,
+          (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height),
+          (x, y, z, width, height))
+
+API_ENTRY(glDrawTexxOES,
+          (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height),
+          (x, y, z, width, height))
+
+API_ENTRY(glDrawTexsvOES,
+          (const GLshort *coords),
+          (coords))
+
+API_ENTRY(glDrawTexivOES,
+          (const GLint *coords),
+          (coords))
+
+API_ENTRY(glDrawTexfvOES,
+          (const GLfloat *coords),
+          (coords))
+
+API_ENTRY(glDrawTexxvOES,
+          (const GLfixed *coords),
+          (coords))
diff --git a/tools/emulator/opengl/system/egl/egl.cfg b/tools/emulator/opengl/system/egl/egl.cfg
new file mode 100644
index 0000000..9d3f2dc
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/egl.cfg
@@ -0,0 +1 @@
+0 0 emulation
diff --git a/tools/emulator/opengl/system/egl/egl.cpp b/tools/emulator/opengl/system/egl/egl.cpp
new file mode 100644
index 0000000..ee195ac
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/egl.cpp
@@ -0,0 +1,1254 @@
+/*
+* 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 "HostConnection.h"
+#include "ThreadInfo.h"
+#include "eglDisplay.h"
+#include "egl_ftable.h"
+#include <cutils/log.h>
+#include "gralloc_cb.h"
+#include "GLClientState.h"
+#include "GLSharedGroup.h"
+#include "eglContext.h"
+#include "ClientAPIExts.h"
+
+#include "GLEncoder.h"
+#ifdef WITH_GLES2
+#include "GL2Encoder.h"
+#endif
+
+#include <system/window.h>
+
+template<typename T>
+static T setErrorFunc(GLint error, T returnValue) {
+    getEGLThreadInfo()->eglError = error;
+    return returnValue;
+}
+
+const char *  eglStrError(EGLint err)
+{
+    switch (err){
+        case EGL_SUCCESS:           return "EGL_SUCCESS";
+        case EGL_NOT_INITIALIZED:   return "EGL_NOT_INITIALIZED";
+        case EGL_BAD_ACCESS:        return "EGL_BAD_ACCESS";
+        case EGL_BAD_ALLOC:         return "EGL_BAD_ALLOC";
+        case EGL_BAD_ATTRIBUTE:     return "EGL_BAD_ATTRIBUTE";
+        case EGL_BAD_CONFIG:        return "EGL_BAD_CONFIG";
+        case EGL_BAD_CONTEXT:       return "EGL_BAD_CONTEXT";
+        case EGL_BAD_CURRENT_SURFACE: return "EGL_BAD_CURRENT_SURFACE";
+        case EGL_BAD_DISPLAY:       return "EGL_BAD_DISPLAY";
+        case EGL_BAD_MATCH:         return "EGL_BAD_MATCH";
+        case EGL_BAD_NATIVE_PIXMAP: return "EGL_BAD_NATIVE_PIXMAP";
+        case EGL_BAD_NATIVE_WINDOW: return "EGL_BAD_NATIVE_WINDOW";
+        case EGL_BAD_PARAMETER:     return "EGL_BAD_PARAMETER";
+        case EGL_BAD_SURFACE:       return "EGL_BAD_SURFACE";
+        case EGL_CONTEXT_LOST:      return "EGL_CONTEXT_LOST";
+        default: return "UNKNOWN";
+    }
+}
+
+#define LOG_EGL_ERRORS 1
+
+#ifdef LOG_EGL_ERRORS
+
+#define setErrorReturn(error, retVal)     \
+    {                                                \
+        ALOGE("tid %d: %s(%d): error 0x%x (%s)", gettid(), __FUNCTION__, __LINE__, error, eglStrError(error));     \
+        return setErrorFunc(error, retVal);            \
+    }
+
+#define RETURN_ERROR(ret,err)           \
+    ALOGE("tid %d: %s(%d): error 0x%x (%s)", gettid(), __FUNCTION__, __LINE__, err, eglStrError(err));    \
+    getEGLThreadInfo()->eglError = err;    \
+    return ret;
+
+#else //!LOG_EGL_ERRORS
+
+#define setErrorReturn(error, retVal) return setErrorFunc(error, retVal);
+
+#define RETURN_ERROR(ret,err)           \
+    getEGLThreadInfo()->eglError = err; \
+    return ret;
+
+#endif //LOG_EGL_ERRORS
+
+#define VALIDATE_CONFIG(cfg,ret) \
+    if(((int)cfg<0)||((int)cfg>s_display.getNumConfigs())) { \
+        RETURN_ERROR(ret,EGL_BAD_CONFIG); \
+    }
+
+#define VALIDATE_DISPLAY(dpy,ret) \
+    if ((dpy) != (EGLDisplay)&s_display) { \
+        RETURN_ERROR(ret, EGL_BAD_DISPLAY);    \
+    }
+
+#define VALIDATE_DISPLAY_INIT(dpy,ret) \
+    VALIDATE_DISPLAY(dpy, ret)    \
+    if (!s_display.initialized()) {        \
+        RETURN_ERROR(ret, EGL_NOT_INITIALIZED);    \
+    }
+
+#define DEFINE_HOST_CONNECTION \
+    HostConnection *hostCon = HostConnection::get(); \
+    renderControl_encoder_context_t *rcEnc = (hostCon ? hostCon->rcEncoder() : NULL)
+
+#define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \
+    HostConnection *hostCon = HostConnection::get(); \
+    if (!hostCon) { \
+        ALOGE("egl: Failed to get host connection\n"); \
+        return ret; \
+    } \
+    renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
+    if (!rcEnc) { \
+        ALOGE("egl: Failed to get renderControl encoder context\n"); \
+        return ret; \
+    }
+
+#define VALIDATE_CONTEXT_RETURN(context,ret)        \
+    if (!context) {                                    \
+        RETURN_ERROR(ret,EGL_BAD_CONTEXT);    \
+    }
+
+#define VALIDATE_SURFACE_RETURN(surface, ret)    \
+    if (surface != EGL_NO_SURFACE) {    \
+        egl_surface_t* s( static_cast<egl_surface_t*>(surface) );    \
+        if (s->dpy != (EGLDisplay)&s_display)    \
+            setErrorReturn(EGL_BAD_DISPLAY, EGL_FALSE);    \
+    }
+
+
+EGLContext_t::EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* shareCtx) :
+    dpy(dpy),
+    config(config),
+    read(EGL_NO_SURFACE),
+    draw(EGL_NO_SURFACE),
+    shareCtx(shareCtx),
+    rcContext(0),
+    versionString(NULL),
+    vendorString(NULL),
+    rendererString(NULL),
+    extensionString(NULL)
+{
+    flags = 0;
+    version = 1;
+    clientState = new GLClientState();
+    if (shareCtx)
+        sharedGroup = shareCtx->getSharedGroup();
+    else
+        sharedGroup = GLSharedGroupPtr(new GLSharedGroup());
+};
+
+EGLContext_t::~EGLContext_t()
+{
+    delete clientState;
+    delete [] versionString;
+    delete [] vendorString;
+    delete [] rendererString;
+    delete [] extensionString;
+}
+
+// ----------------------------------------------------------------------------
+//egl_surface_t
+
+//we don't need to handle depth since it's handled when window created on the host
+
+struct egl_surface_t {
+
+    EGLDisplay          dpy;
+    EGLConfig           config;
+
+
+    egl_surface_t(EGLDisplay dpy, EGLConfig config, EGLint surfaceType);
+    virtual     ~egl_surface_t();
+
+    virtual     void        setSwapInterval(int interval) = 0;
+    virtual     EGLBoolean  swapBuffers() = 0;
+
+    EGLint      getSwapBehavior() const;
+    uint32_t    getRcSurface()   { return rcSurface; }
+    EGLint      getSurfaceType() { return surfaceType; }
+
+    EGLint      getWidth(){ return width; }
+    EGLint      getHeight(){ return height; }
+    void        setTextureFormat(EGLint _texFormat) { texFormat = _texFormat; }
+    EGLint      getTextureFormat() { return texFormat; }
+    void        setTextureTarget(EGLint _texTarget) { texTarget = _texTarget; }
+    EGLint      getTextureTarget() { return texTarget; }
+
+private:
+    //
+    //Surface attributes
+    //
+    EGLint      width;
+    EGLint      height;
+    EGLint      texFormat;
+    EGLint      texTarget;
+
+protected:
+    void        setWidth(EGLint w)  { width = w;  }
+    void        setHeight(EGLint h) { height = h; }
+
+    EGLint      surfaceType;
+    uint32_t    rcSurface; //handle to surface created via remote control
+};
+
+egl_surface_t::egl_surface_t(EGLDisplay dpy, EGLConfig config, EGLint surfaceType)
+    : dpy(dpy), config(config), surfaceType(surfaceType), rcSurface(0)
+{
+    width = 0;
+    height = 0;
+    texFormat = EGL_NO_TEXTURE;
+    texTarget = EGL_NO_TEXTURE;
+}
+
+EGLint egl_surface_t::getSwapBehavior() const {
+    return EGL_BUFFER_PRESERVED;
+}
+
+egl_surface_t::~egl_surface_t()
+{
+}
+
+// ----------------------------------------------------------------------------
+// egl_window_surface_t
+
+struct egl_window_surface_t : public egl_surface_t {
+    static egl_window_surface_t* create(
+            EGLDisplay dpy, EGLConfig config, EGLint surfType,
+            ANativeWindow* window);
+
+    virtual ~egl_window_surface_t();
+
+    virtual void       setSwapInterval(int interval);
+    virtual EGLBoolean swapBuffers();
+
+private:
+    egl_window_surface_t(
+            EGLDisplay dpy, EGLConfig config, EGLint surfType,
+            ANativeWindow* window);
+    EGLBoolean init();
+
+    ANativeWindow*              nativeWindow;
+    android_native_buffer_t*    buffer;
+};
+
+egl_window_surface_t::egl_window_surface_t (
+        EGLDisplay dpy, EGLConfig config, EGLint surfType,
+        ANativeWindow* window)
+:   egl_surface_t(dpy, config, surfType),
+    nativeWindow(window),
+    buffer(NULL)
+{
+    // keep a reference on the window
+    nativeWindow->common.incRef(&nativeWindow->common);
+    EGLint w,h;
+    nativeWindow->query(nativeWindow, NATIVE_WINDOW_WIDTH, &w);
+    setWidth(w);
+    nativeWindow->query(nativeWindow, NATIVE_WINDOW_HEIGHT, &h);
+    setHeight(h);
+}
+
+EGLBoolean egl_window_surface_t::init()
+{
+    if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) != NO_ERROR) {
+        setErrorReturn(EGL_BAD_ALLOC, EGL_FALSE);
+    }
+    nativeWindow->lockBuffer(nativeWindow, buffer);
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uint32_t)config,
+            getWidth(), getHeight());
+    if (!rcSurface) {
+        ALOGE("rcCreateWindowSurface returned 0");
+        return EGL_FALSE;
+    }
+    rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface,
+            ((cb_handle_t*)(buffer->handle))->hostHandle);
+
+    return EGL_TRUE;
+}
+
+egl_window_surface_t* egl_window_surface_t::create(
+        EGLDisplay dpy, EGLConfig config, EGLint surfType,
+        ANativeWindow* window)
+{
+    egl_window_surface_t* wnd = new egl_window_surface_t(
+            dpy, config, surfType, window);
+    if (wnd && !wnd->init()) {
+        delete wnd;
+        wnd = NULL;
+    }
+    return wnd;
+}
+
+egl_window_surface_t::~egl_window_surface_t() {
+    DEFINE_HOST_CONNECTION;
+    if (rcSurface && rcEnc) {
+        rcEnc->rcDestroyWindowSurface(rcEnc, rcSurface);
+    }
+    if (buffer) {
+        nativeWindow->cancelBuffer(nativeWindow, buffer);
+    }
+    nativeWindow->common.decRef(&nativeWindow->common);
+}
+
+void egl_window_surface_t::setSwapInterval(int interval)
+{
+    nativeWindow->setSwapInterval(nativeWindow, interval);
+}
+
+EGLBoolean egl_window_surface_t::swapBuffers()
+{
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+
+    rcEnc->rcFlushWindowColorBuffer(rcEnc, rcSurface);
+
+    nativeWindow->queueBuffer(nativeWindow, buffer);
+    if (nativeWindow->dequeueBuffer(nativeWindow, &buffer)) {
+        buffer = NULL;
+        setErrorReturn(EGL_BAD_ALLOC, EGL_FALSE);
+    }
+    nativeWindow->lockBuffer(nativeWindow, buffer);
+
+    rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface,
+            ((cb_handle_t *)(buffer->handle))->hostHandle);
+
+    return EGL_TRUE;
+}
+
+// ----------------------------------------------------------------------------
+//egl_pbuffer_surface_t
+
+struct egl_pbuffer_surface_t : public egl_surface_t {
+    static egl_pbuffer_surface_t* create(EGLDisplay dpy, EGLConfig config,
+            EGLint surfType, int32_t w, int32_t h, GLenum pixelFormat);
+
+    virtual ~egl_pbuffer_surface_t();
+
+    virtual void       setSwapInterval(int interval) {}
+    virtual EGLBoolean swapBuffers() { return EGL_TRUE; }
+
+    uint32_t getRcColorBuffer() { return rcColorBuffer; }
+
+private:
+    egl_pbuffer_surface_t(EGLDisplay dpy, EGLConfig config, EGLint surfType,
+            int32_t w, int32_t h);
+    EGLBoolean init(GLenum format);
+
+    uint32_t rcColorBuffer;
+};
+
+egl_pbuffer_surface_t::egl_pbuffer_surface_t(EGLDisplay dpy, EGLConfig config,
+        EGLint surfType, int32_t w, int32_t h)
+:   egl_surface_t(dpy, config, surfType),
+    rcColorBuffer(0)
+{
+    setWidth(w);
+    setHeight(h);
+}
+
+egl_pbuffer_surface_t::~egl_pbuffer_surface_t()
+{
+    DEFINE_HOST_CONNECTION;
+    if (rcEnc) {
+        if (rcColorBuffer) rcEnc->rcCloseColorBuffer(rcEnc, rcColorBuffer);
+        if (rcSurface)     rcEnc->rcDestroyWindowSurface(rcEnc, rcSurface);
+    }
+}
+
+EGLBoolean egl_pbuffer_surface_t::init(GLenum pixelFormat)
+{
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+
+    rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uint32_t)config,
+            getWidth(), getHeight());
+    if (!rcSurface) {
+        ALOGE("rcCreateWindowSurface returned 0");
+        return EGL_FALSE;
+    }
+
+    rcColorBuffer = rcEnc->rcCreateColorBuffer(rcEnc, getWidth(), getHeight(),
+            pixelFormat);
+    if (!rcColorBuffer) {
+        ALOGE("rcCreateColorBuffer returned 0");
+        return EGL_FALSE;
+    }
+
+    rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, rcColorBuffer);
+
+    return EGL_TRUE;
+}
+
+egl_pbuffer_surface_t* egl_pbuffer_surface_t::create(EGLDisplay dpy,
+        EGLConfig config, EGLint surfType, int32_t w, int32_t h,
+        GLenum pixelFormat)
+{
+    egl_pbuffer_surface_t* pb = new egl_pbuffer_surface_t(dpy, config, surfType,
+            w, h);
+    if (pb && !pb->init(pixelFormat)) {
+        delete pb;
+        pb = NULL;
+    }
+    return pb;
+}
+
+static const char *getGLString(int glEnum)
+{
+    EGLThreadInfo *tInfo = getEGLThreadInfo();
+    if (!tInfo || !tInfo->currentContext) {
+        return NULL;
+    }
+
+    const char** strPtr = NULL;
+
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+
+    switch(glEnum) {
+        case GL_VERSION:
+            strPtr = &tInfo->currentContext->versionString;
+            break;
+        case GL_VENDOR:
+            strPtr = &tInfo->currentContext->vendorString;
+            break;
+        case GL_RENDERER:
+            strPtr = &tInfo->currentContext->rendererString;
+            break;
+        case GL_EXTENSIONS:
+            strPtr = &tInfo->currentContext->extensionString;
+            break;
+    }
+
+    if (!strPtr) {
+        return NULL;
+    }
+
+    if (*strPtr != NULL) {
+        //
+        // string is already cached
+        //
+        return *strPtr;
+    }
+
+    //
+    // first query of that string - need to query host
+    //
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(NULL);
+    char *hostStr = NULL;
+    int n = rcEnc->rcGetGLString(rcEnc, glEnum, NULL, 0);
+    if (n < 0) {
+        hostStr = new char[-n+1];
+        n = rcEnc->rcGetGLString(rcEnc, glEnum, hostStr, -n);
+        if (n <= 0) {
+            delete [] hostStr;
+            hostStr = NULL;
+        }
+    }
+
+    //
+    // keep the string in the context and return its value
+    //
+    *strPtr = hostStr;
+    return hostStr;
+}
+
+// ----------------------------------------------------------------------------
+
+// The one and only supported display object.
+static eglDisplay s_display;
+
+static EGLClient_eglInterface s_eglIface = {
+    getThreadInfo: getEGLThreadInfo,
+    getGLString: getGLString
+};
+
+#define DBG_FUNC DBG("%s\n", __FUNCTION__)
+EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
+{
+    //
+    // we support only EGL_DEFAULT_DISPLAY.
+    //
+    if (display_id != EGL_DEFAULT_DISPLAY) {
+        return EGL_NO_DISPLAY;
+    }
+
+    return (EGLDisplay)&s_display;
+}
+
+EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+    VALIDATE_DISPLAY(dpy,EGL_FALSE);
+
+    if (!s_display.initialize(&s_eglIface)) {
+        return EGL_FALSE;
+    }
+    if (major!=NULL)
+        *major = s_display.getVersionMajor();
+    if (minor!=NULL)
+        *minor = s_display.getVersionMinor();
+    return EGL_TRUE;
+}
+
+EGLBoolean eglTerminate(EGLDisplay dpy)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+
+    s_display.terminate();
+    return EGL_TRUE;
+}
+
+EGLint eglGetError()
+{
+    EGLint error = getEGLThreadInfo()->eglError;
+    getEGLThreadInfo()->eglError = EGL_SUCCESS;
+    return error;
+}
+
+__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;
+        }
+    }
+
+    //
+    // Make sure display is initialized before searching in client APIs
+    //
+    if (!s_display.initialized()) {
+        if (!s_display.initialize(&s_eglIface)) {
+            return NULL;
+        }
+    }
+
+    // look in gles client api's extensions table
+    return (__eglMustCastToProperFunctionPointerType)ClientAPIExts::getProcAddress(procname);
+
+    // Fail - function not found.
+    return NULL;
+}
+
+const char* eglQueryString(EGLDisplay dpy, EGLint name)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+
+    return s_display.queryString(name);
+}
+
+EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+
+    if(!num_config) {
+        RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER);
+    }
+
+    GLint numConfigs = s_display.getNumConfigs();
+    if (!configs) {
+        *num_config = numConfigs;
+        return EGL_TRUE;
+    }
+
+    int i=0;
+    for (i=0 ; i<numConfigs && i<config_size ; i++) {
+        *configs++ = (EGLConfig)i;
+    }
+    *num_config = i;
+    return EGL_TRUE;
+}
+
+EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+
+    int attribs_size = 0;
+    if (attrib_list) {
+        const EGLint * attrib_p = attrib_list;
+        while (attrib_p[0] != EGL_NONE) {
+            attribs_size += 2;
+            attrib_p += 2;
+        }
+        attribs_size++; //for the terminating EGL_NONE
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    *num_config = rcEnc->rcChooseConfig(rcEnc, (EGLint*)attrib_list, attribs_size * sizeof(EGLint), (uint32_t*)configs, config_size);
+
+    return EGL_TRUE;
+}
+
+EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+    VALIDATE_CONFIG(config, EGL_FALSE);
+
+    if (s_display.getConfigAttrib(config, attribute, value))
+    {
+        return EGL_TRUE;
+    }
+    else
+    {
+        RETURN_ERROR(EGL_FALSE, EGL_BAD_ATTRIBUTE);
+    }
+}
+
+EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+    VALIDATE_CONFIG(config, EGL_FALSE);
+    if (win == 0) {
+        setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE);
+    }
+
+    EGLint surfaceType;
+    if (s_display.getConfigAttrib(config, EGL_SURFACE_TYPE, &surfaceType) == EGL_FALSE)    return EGL_FALSE;
+
+    if (!(surfaceType & EGL_WINDOW_BIT)) {
+        setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE);
+    }
+
+    if (static_cast<ANativeWindow*>(win)->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
+        setErrorReturn(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+    }
+
+    egl_surface_t* surface = egl_window_surface_t::create(
+            &s_display, config, surfaceType, static_cast<ANativeWindow*>(win));
+    if (!surface) {
+        setErrorReturn(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+    }
+
+    return surface;
+}
+
+EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+    VALIDATE_CONFIG(config, EGL_FALSE);
+
+    EGLint surfaceType;
+    if (s_display.getConfigAttrib(config, EGL_SURFACE_TYPE, &surfaceType) == EGL_FALSE)    return EGL_FALSE;
+
+    if (!(surfaceType & EGL_PBUFFER_BIT)) {
+        setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE);
+    }
+
+    int32_t w = 0;
+    int32_t h = 0;
+    EGLint texFormat = EGL_NO_TEXTURE;
+    EGLint texTarget = EGL_NO_TEXTURE;
+    while (attrib_list[0]) {
+        switch (attrib_list[0]) {
+            case EGL_WIDTH:
+                w = attrib_list[1];
+                break;
+            case EGL_HEIGHT:
+                h = attrib_list[1];
+                break;
+            case EGL_TEXTURE_FORMAT:
+                texFormat = attrib_list[1];
+                break;
+            case EGL_TEXTURE_TARGET:
+                texTarget = attrib_list[1];
+                break;
+            default:
+                break;
+        };
+        attrib_list+=2;
+    }
+    if (((texFormat == EGL_NO_TEXTURE)&&(texTarget != EGL_NO_TEXTURE)) ||
+        ((texFormat != EGL_NO_TEXTURE)&&(texTarget == EGL_NO_TEXTURE))) {
+        setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE);
+    }
+    // TODO: check EGL_TEXTURE_FORMAT - need to support eglBindTexImage
+
+    GLenum pixelFormat;
+    if (s_display.getConfigGLPixelFormat(config, &pixelFormat) == EGL_FALSE)
+        setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE);
+
+    egl_surface_t* surface = egl_pbuffer_surface_t::create(dpy, config,
+            surfaceType, w, h, pixelFormat);
+    if (!surface) {
+        setErrorReturn(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+    }
+
+    //setup attributes
+    surface->setTextureFormat(texFormat);
+    surface->setTextureTarget(texTarget);
+
+    return surface;
+}
+
+EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
+{
+    //XXX: Pixmap not supported. The host cannot render to a pixmap resource
+    //     located on host. In order to support Pixmaps we should either punt
+    //     to s/w rendering -or- let the host render to a buffer that will be
+    //     copied back to guest at some sync point. None of those methods not
+    //     implemented and pixmaps are not used with OpenGL anyway ...
+    return EGL_NO_SURFACE;
+}
+
+EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface eglSurface)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(eglSurface, EGL_FALSE);
+
+    egl_surface_t* surface(static_cast<egl_surface_t*>(eglSurface));
+    delete surface;
+
+    return EGL_TRUE;
+}
+
+EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface eglSurface, EGLint attribute, EGLint *value)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(eglSurface, EGL_FALSE);
+
+    egl_surface_t* surface( static_cast<egl_surface_t*>(eglSurface) );
+    EGLBoolean ret = EGL_TRUE;
+    switch (attribute) {
+        case EGL_CONFIG_ID:
+            ret = s_display.getConfigAttrib(surface->config, EGL_CONFIG_ID, value);
+            break;
+        case EGL_WIDTH:
+            *value = surface->getWidth();
+            break;
+        case EGL_HEIGHT:
+            *value = surface->getHeight();
+            break;
+        case EGL_TEXTURE_FORMAT:
+            *value = surface->getTextureFormat();
+            break;
+        case EGL_TEXTURE_TARGET:
+            *value = surface->getTextureTarget();
+            break;
+        case EGL_SWAP_BEHAVIOR:
+            *value = surface->getSwapBehavior();
+            break;
+        case EGL_LARGEST_PBUFFER:
+            // not modified for a window or pixmap surface
+            // and we ignore it when creating a PBuffer surface (default is EGL_FALSE)
+            if (surface->getSurfaceType() & EGL_PBUFFER_BIT) *value = EGL_FALSE;
+            break;
+        //TODO: complete other attributes
+        default:
+            ALOGE("eglQuerySurface %x  EGL_BAD_ATTRIBUTE", attribute);
+            ret = setErrorFunc(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+            break;
+    }
+
+    return ret;
+}
+
+EGLBoolean eglBindAPI(EGLenum api)
+{
+    if (api != EGL_OPENGL_ES_API)
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+    return EGL_TRUE;
+}
+
+EGLenum eglQueryAPI()
+{
+    return EGL_OPENGL_ES_API;
+}
+
+EGLBoolean eglWaitClient()
+{
+    return eglWaitGL();
+}
+
+EGLBoolean eglReleaseThread()
+{
+    EGLThreadInfo *tInfo = getEGLThreadInfo();
+    if (tInfo && tInfo->currentContext) {
+        return eglMakeCurrent(&s_display, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
+    }
+    return EGL_TRUE;
+}
+
+EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+{
+    //TODO
+    ALOGW("%s not implemented", __FUNCTION__);
+    return 0;
+}
+
+EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+{
+    //TODO
+    ALOGW("%s not implemented", __FUNCTION__);
+    return 0;
+}
+
+EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface eglSurface, EGLint buffer)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(eglSurface, EGL_FALSE);
+    if (eglSurface == EGL_NO_SURFACE) {
+        setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE);
+    }
+
+    if (buffer != EGL_BACK_BUFFER) {
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+    }
+
+    egl_surface_t* surface( static_cast<egl_surface_t*>(eglSurface) );
+
+    if (surface->getTextureFormat() == EGL_NO_TEXTURE) {
+        setErrorReturn(EGL_BAD_MATCH, EGL_FALSE);
+    }
+
+    if (!(surface->getSurfaceType() & EGL_PBUFFER_BIT)) {
+        setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE);
+    }
+
+    //It's now safe to cast to pbuffer surface
+    egl_pbuffer_surface_t* pbSurface = (egl_pbuffer_surface_t*)surface;
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    rcEnc->rcBindTexture(rcEnc, pbSurface->getRcColorBuffer());
+
+    return GL_TRUE;
+}
+
+EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+    //TODO
+    ALOGW("%s not implemented", __FUNCTION__);
+    return 0;
+}
+
+EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+
+    EGLContext_t* ctx = getEGLThreadInfo()->currentContext;
+    if (!ctx) {
+        setErrorReturn(EGL_BAD_CONTEXT, EGL_FALSE);
+    }
+    if (!ctx->draw) {
+        setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE);
+    }
+    egl_surface_t* draw(static_cast<egl_surface_t*>(ctx->draw));
+    draw->setSwapInterval(interval);
+
+    rcEnc->rcFBSetSwapInterval(rcEnc, interval); //TODO: implement on the host
+
+    return EGL_TRUE;
+}
+
+EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_NO_CONTEXT);
+    VALIDATE_CONFIG(config, EGL_NO_CONTEXT);
+
+    EGLint version = 1; //default
+    while (attrib_list && attrib_list[0]) {
+        if (attrib_list[0] == EGL_CONTEXT_CLIENT_VERSION) version = attrib_list[1];
+        attrib_list+=2;
+    }
+
+    uint32_t rcShareCtx = 0;
+    EGLContext_t * shareCtx = NULL;
+    if (share_context) {
+        shareCtx = static_cast<EGLContext_t*>(share_context);
+        rcShareCtx = shareCtx->rcContext;
+        if (shareCtx->dpy != dpy)
+            setErrorReturn(EGL_BAD_MATCH, EGL_NO_CONTEXT);
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_NO_CONTEXT);
+    uint32_t rcContext = rcEnc->rcCreateContext(rcEnc, (uint32_t)config, rcShareCtx, version);
+    if (!rcContext) {
+        ALOGE("rcCreateContext returned 0");
+        setErrorReturn(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
+    }
+
+    EGLContext_t * context = new EGLContext_t(dpy, config, shareCtx);
+    if (!context)
+        setErrorReturn(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
+
+    context->version = version;
+    context->rcContext = rcContext;
+
+
+    return context;
+}
+
+EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_CONTEXT_RETURN(ctx, EGL_FALSE);
+
+    EGLContext_t * context = static_cast<EGLContext_t*>(ctx);
+
+    if (getEGLThreadInfo()->currentContext == context)
+    {
+        eglMakeCurrent(dpy, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
+    }
+
+    if (context->rcContext) {
+        DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+        rcEnc->rcDestroyContext(rcEnc, context->rcContext);
+        context->rcContext = 0;
+    }
+
+    delete context;
+    return EGL_TRUE;
+}
+
+EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(draw, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(read, EGL_FALSE);
+
+    if ((read == EGL_NO_SURFACE && draw == EGL_NO_SURFACE) && (ctx != EGL_NO_CONTEXT))
+        setErrorReturn(EGL_BAD_MATCH, EGL_FALSE);
+    if ((read != EGL_NO_SURFACE || draw != EGL_NO_SURFACE) && (ctx == EGL_NO_CONTEXT))
+        setErrorReturn(EGL_BAD_MATCH, EGL_FALSE);
+
+    EGLContext_t * context = static_cast<EGLContext_t*>(ctx);
+    uint32_t ctxHandle = (context) ? context->rcContext : 0;
+    egl_surface_t * drawSurf = static_cast<egl_surface_t *>(draw);
+    uint32_t drawHandle = (drawSurf) ? drawSurf->getRcSurface() : 0;
+    egl_surface_t * readSurf = static_cast<egl_surface_t *>(read);
+    uint32_t readHandle = (readSurf) ? readSurf->getRcSurface() : 0;
+
+    //
+    // Nothing to do if no binding change has made
+    //
+    EGLThreadInfo *tInfo = getEGLThreadInfo();
+    if (tInfo->currentContext == context &&
+        (context == NULL ||
+        (context && context->draw == draw && context->read == read))) {
+        return EGL_TRUE;
+    }
+
+    if (context && (context->flags & EGLContext_t::IS_CURRENT) && (context != tInfo->currentContext)) {
+        //context is current to another thread
+        setErrorReturn(EGL_BAD_ACCESS, EGL_FALSE);
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    if (rcEnc->rcMakeCurrent(rcEnc, ctxHandle, drawHandle, readHandle) == EGL_FALSE) {
+        ALOGE("rcMakeCurrent returned EGL_FALSE");
+        setErrorReturn(EGL_BAD_CONTEXT, EGL_FALSE);
+    }
+
+    //Now make the local bind
+    if (context) {
+        context->draw = draw;
+        context->read = read;
+        context->flags |= EGLContext_t::IS_CURRENT;
+        //set the client state
+        if (context->version == 2) {
+            hostCon->gl2Encoder()->setClientState(context->getClientState());
+            hostCon->gl2Encoder()->setSharedGroup(context->getSharedGroup());
+        }
+        else {
+            hostCon->glEncoder()->setClientState(context->getClientState());
+            hostCon->glEncoder()->setSharedGroup(context->getSharedGroup());
+        }
+    } 
+    else {
+        //release ClientState & SharedGroup
+        if (tInfo->currentContext->version == 2) {
+            hostCon->gl2Encoder()->setClientState(NULL);
+            hostCon->gl2Encoder()->setSharedGroup(GLSharedGroupPtr(NULL));
+        }
+        else {
+            hostCon->glEncoder()->setClientState(NULL);
+            hostCon->glEncoder()->setSharedGroup(GLSharedGroupPtr(NULL));
+        }
+
+    }
+
+    if (tInfo->currentContext)
+        tInfo->currentContext->flags &= ~EGLContext_t::IS_CURRENT;
+
+    //Now make current
+    tInfo->currentContext = context;
+
+    //Check maybe we need to init the encoder, if it's first eglMakeCurrent
+    if (tInfo->currentContext) {
+        if (tInfo->currentContext->version == 2) {
+            if (!hostCon->gl2Encoder()->isInitialized()) {
+                s_display.gles2_iface()->init();
+                hostCon->gl2Encoder()->setInitialized();
+                ClientAPIExts::initClientFuncs(s_display.gles2_iface(), 1);
+            }
+        }
+        else {
+            if (!hostCon->glEncoder()->isInitialized()) {
+                s_display.gles_iface()->init();
+                hostCon->glEncoder()->setInitialized();
+                ClientAPIExts::initClientFuncs(s_display.gles_iface(), 0);
+            }
+        }
+    }
+
+    return EGL_TRUE;
+}
+
+EGLContext eglGetCurrentContext()
+{
+    return getEGLThreadInfo()->currentContext;
+}
+
+EGLSurface eglGetCurrentSurface(EGLint readdraw)
+{
+    EGLContext_t * context = getEGLThreadInfo()->currentContext;
+    if (!context)
+        return EGL_NO_SURFACE; //not an error
+
+    switch (readdraw) {
+        case EGL_READ:
+            return context->read;
+        case EGL_DRAW:
+            return context->draw;
+        default:
+            setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
+    }
+}
+
+EGLDisplay eglGetCurrentDisplay()
+{
+    EGLContext_t * context = getEGLThreadInfo()->currentContext;
+    if (!context)
+        return EGL_NO_DISPLAY; //not an error
+
+    return context->dpy;
+}
+
+EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_CONTEXT_RETURN(ctx, EGL_FALSE);
+
+    EGLContext_t * context = static_cast<EGLContext_t*>(ctx);
+
+    EGLBoolean ret = EGL_TRUE;
+    switch (attribute) {
+        case EGL_CONFIG_ID:
+            ret = s_display.getConfigAttrib(context->config, EGL_CONFIG_ID, value);
+            break;
+        case EGL_CONTEXT_CLIENT_TYPE:
+            *value = EGL_OPENGL_ES_API;
+            break;
+        case EGL_CONTEXT_CLIENT_VERSION:
+            *value = context->version;
+            break;
+        case EGL_RENDER_BUFFER:
+            if (!context->draw)
+                *value = EGL_NONE;
+            else
+                *value = EGL_BACK_BUFFER; //single buffer not supported
+            break;
+        default:
+            ALOGE("eglQueryContext %x  EGL_BAD_ATTRIBUTE", attribute);
+            setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+            break;
+    }
+
+    return ret;
+}
+
+EGLBoolean eglWaitGL()
+{
+    EGLThreadInfo *tInfo = getEGLThreadInfo();
+    if (!tInfo || !tInfo->currentContext) {
+        return EGL_FALSE;
+    }
+
+    if (tInfo->currentContext->version == 2) {
+        s_display.gles2_iface()->finish();
+    }
+    else {
+        s_display.gles_iface()->finish();
+    }
+
+    return EGL_TRUE;
+}
+
+EGLBoolean eglWaitNative(EGLint engine)
+{
+    return EGL_TRUE;
+}
+
+EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface eglSurface)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    if (eglSurface == EGL_NO_SURFACE)
+        setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE);
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+
+    egl_surface_t* d = static_cast<egl_surface_t*>(eglSurface);
+    if (d->dpy != dpy)
+        setErrorReturn(EGL_BAD_DISPLAY, EGL_FALSE);
+
+    // post the surface
+    d->swapBuffers();
+
+    hostCon->flush();
+    return EGL_TRUE;
+}
+
+EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+{
+    //TODO :later
+    return 0;
+}
+
+EGLBoolean eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
+{
+    //TODO later
+    return 0;
+}
+
+EGLBoolean eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
+{
+    //TODO later
+    return 0;
+}
+
+EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_NO_IMAGE_KHR);
+    if (ctx != EGL_NO_CONTEXT) {
+        setErrorReturn(EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
+    }
+    if (target != EGL_NATIVE_BUFFER_ANDROID) {
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+    }
+
+    android_native_buffer_t* native_buffer = (android_native_buffer_t*)buffer;
+
+    if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+
+    if (native_buffer->common.version != sizeof(android_native_buffer_t))
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+
+    switch (native_buffer->format) {
+        case HAL_PIXEL_FORMAT_RGBA_8888:
+        case HAL_PIXEL_FORMAT_RGBX_8888:
+        case HAL_PIXEL_FORMAT_RGB_888:
+        case HAL_PIXEL_FORMAT_RGB_565:
+        case HAL_PIXEL_FORMAT_BGRA_8888:
+        case HAL_PIXEL_FORMAT_RGBA_5551:
+        case HAL_PIXEL_FORMAT_RGBA_4444:
+            break;
+        default:
+            setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+    }
+
+    native_buffer->common.incRef(&native_buffer->common);
+    return (EGLImageKHR)native_buffer;
+}
+
+EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    android_native_buffer_t* native_buffer = (android_native_buffer_t*)img;
+
+    if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+
+    if (native_buffer->common.version != sizeof(android_native_buffer_t))
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+
+    native_buffer->common.decRef(&native_buffer->common);
+
+    return EGL_TRUE;
+}
+
+#define FENCE_SYNC_HANDLE (EGLSyncKHR)0xFE4CE
+
+EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type,
+        const EGLint *attrib_list)
+{
+    // TODO: This implementation could be faster. We should require the host EGL
+    // to support KHR_fence_sync, or at least pipe the fence command to the host
+    // and wait for it (probably involving a glFinish on the host) in
+    // eglClientWaitSyncKHR.
+
+    VALIDATE_DISPLAY(dpy, EGL_NO_SYNC_KHR);
+
+    if (type != EGL_SYNC_FENCE_KHR ||
+            (attrib_list != NULL && attrib_list[0] != EGL_NONE)) {
+        setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_NO_SYNC_KHR);
+    }
+
+    EGLThreadInfo *tInfo = getEGLThreadInfo();
+    if (!tInfo || !tInfo->currentContext) {
+        setErrorReturn(EGL_BAD_MATCH, EGL_NO_SYNC_KHR);
+    }
+
+    if (tInfo->currentContext->version == 2) {
+        s_display.gles2_iface()->finish();
+    } else {
+        s_display.gles_iface()->finish();
+    }
+
+    return FENCE_SYNC_HANDLE;
+}
+
+EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
+{
+    if (sync != FENCE_SYNC_HANDLE) {
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+    }
+
+    return EGL_TRUE;
+}
+
+EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags,
+        EGLTimeKHR timeout)
+{
+    if (sync != FENCE_SYNC_HANDLE) {
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+    }
+
+    return EGL_CONDITION_SATISFIED_KHR;
+}
+
+EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync,
+        EGLint attribute, EGLint *value)
+{
+    if (sync != FENCE_SYNC_HANDLE) {
+        setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE);
+    }
+
+    switch (attribute) {
+    case EGL_SYNC_TYPE_KHR:
+        *value = EGL_SYNC_FENCE_KHR;
+        return EGL_TRUE;
+    case EGL_SYNC_STATUS_KHR:
+        *value = EGL_SIGNALED_KHR;
+        return EGL_TRUE;
+    case EGL_SYNC_CONDITION_KHR:
+        *value = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR;
+        return EGL_TRUE;
+    default:
+        setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+    }
+}
diff --git a/tools/emulator/opengl/system/egl/eglContext.h b/tools/emulator/opengl/system/egl/eglContext.h
new file mode 100644
index 0000000..2ca6d0c
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/eglContext.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 _EGL_CONTEXT_H
+#define _EGL_CONTEXT_H
+
+#include "GLClientState.h"
+#include "GLSharedGroup.h"
+
+struct EGLContext_t {
+
+    enum {
+        IS_CURRENT      =   0x00010000,
+        NEVER_CURRENT   =   0x00020000
+    };
+
+    EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* shareCtx);
+    ~EGLContext_t();
+    uint32_t            flags;
+    EGLDisplay          dpy;
+    EGLConfig           config;
+    EGLSurface          read;
+    EGLSurface          draw;
+    EGLContext_t    *   shareCtx;
+    EGLint                version;
+    uint32_t             rcContext;
+    const char*         versionString;
+    const char*         vendorString;
+    const char*         rendererString;
+    const char*         extensionString;
+
+    GLClientState * getClientState(){ return clientState; }
+    GLSharedGroupPtr getSharedGroup(){ return sharedGroup; }
+private:
+    GLClientState    *    clientState;
+    GLSharedGroupPtr      sharedGroup;
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/egl/eglDisplay.cpp b/tools/emulator/opengl/system/egl/eglDisplay.cpp
new file mode 100644
index 0000000..bcb0d4b
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/eglDisplay.cpp
@@ -0,0 +1,497 @@
+/*
+* 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 "eglDisplay.h"
+#include "HostConnection.h"
+#include <dlfcn.h>
+
+static const int systemEGLVersionMajor = 1;
+static const int systemEGLVersionMinor = 4;
+static const char systemEGLVendor[] = "Google Android emulator";
+
+// list of extensions supported by this EGL implementation
+//  NOTE that each extension name should be suffixed with space
+static const char systemStaticEGLExtensions[] =
+            "EGL_ANDROID_image_native_buffer "
+            "EGL_KHR_fence_sync ";
+
+// list of extensions supported by this EGL implementation only if supported
+// on the host implementation.
+//  NOTE that each extension name should be suffixed with space
+static const char systemDynamicEGLExtensions[] =
+            "EGL_KHR_image_base "
+            "EGL_KHR_gl_texture_2d_image ";
+
+
+static void *s_gles_lib = NULL;
+static void *s_gles2_lib = NULL;
+
+// The following function will be called when we (libEGL)
+// gets unloaded
+// At this point we want to unload the gles libraries we
+// might have loaded during initialization
+static void __attribute__ ((destructor)) do_on_unload(void)
+{
+    if (s_gles_lib) {
+        dlclose(s_gles_lib);
+    }
+
+    if (s_gles2_lib) {
+        dlclose(s_gles2_lib);
+    }
+}
+
+eglDisplay::eglDisplay() :
+    m_initialized(false),
+    m_major(0),
+    m_minor(0),
+    m_hostRendererVersion(0),
+    m_numConfigs(0),
+    m_numConfigAttribs(0),
+    m_attribs(DefaultKeyedVector<EGLint, EGLint>(ATTRIBUTE_NONE)),
+    m_configs(NULL),
+    m_gles_iface(NULL),
+    m_gles2_iface(NULL),
+    m_versionString(NULL),
+    m_vendorString(NULL),
+    m_extensionString(NULL)
+{
+    pthread_mutex_init(&m_lock, NULL);
+}
+
+eglDisplay::~eglDisplay()
+{
+    pthread_mutex_destroy(&m_lock);
+}
+
+bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
+{
+    pthread_mutex_lock(&m_lock);
+    if (!m_initialized) {
+
+        //
+        // load GLES client API
+        //
+        m_gles_iface = loadGLESClientAPI("/system/lib/egl/libGLESv1_CM_emulation.so",
+                                         eglIface,
+                                         &s_gles_lib);
+        if (!m_gles_iface) {
+            pthread_mutex_unlock(&m_lock);
+            ALOGE("Failed to load gles1 iface");
+            return false;
+        }
+
+#ifdef WITH_GLES2
+        m_gles2_iface = loadGLESClientAPI("/system/lib/egl/libGLESv2_emulation.so",
+                                          eglIface,
+                                          &s_gles2_lib);
+        // Note that if loading gles2 failed, we can still run with no
+        // GLES2 support, having GLES2 is not mandatory.
+#endif
+
+        //
+        // establish connection with the host
+        //
+        HostConnection *hcon = HostConnection::get();
+        if (!hcon) {
+            pthread_mutex_unlock(&m_lock);
+            ALOGE("Failed to establish connection with the host\n");
+            return false;
+        }
+
+        //
+        // get renderControl encoder instance
+        //
+        renderControl_encoder_context_t *rcEnc = hcon->rcEncoder();
+        if (!rcEnc) {
+            pthread_mutex_unlock(&m_lock);
+            ALOGE("Failed to get renderControl encoder instance");
+            return false;
+        }
+
+        //
+        // Query host reneder and EGL version
+        //
+        m_hostRendererVersion = rcEnc->rcGetRendererVersion(rcEnc);
+        EGLint status = rcEnc->rcGetEGLVersion(rcEnc, &m_major, &m_minor);
+        if (status != EGL_TRUE) {
+            // host EGL initialization failed !!
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        //
+        // Take minimum version beween what we support and what the host support
+        //
+        if (m_major > systemEGLVersionMajor) {
+            m_major = systemEGLVersionMajor;
+            m_minor = systemEGLVersionMinor;
+        }
+        else if (m_major == systemEGLVersionMajor &&
+                 m_minor > systemEGLVersionMinor) {
+            m_minor = systemEGLVersionMinor;
+        }
+
+        //
+        // Query the host for the set of configs
+        //
+        m_numConfigs = rcEnc->rcGetNumConfigs(rcEnc, (uint32_t*)&m_numConfigAttribs);
+        if (m_numConfigs <= 0 || m_numConfigAttribs <= 0) {
+            // just sanity check - should never happen
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        uint32_t nInts = m_numConfigAttribs * (m_numConfigs + 1);
+        EGLint tmp_buf[nInts];
+        m_configs = new EGLint[nInts-m_numConfigAttribs];
+        if (!m_configs) {
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        //EGLint n = rcEnc->rcGetConfigs(rcEnc, nInts*sizeof(EGLint), m_configs);
+        EGLint n = rcEnc->rcGetConfigs(rcEnc, nInts*sizeof(EGLint), (GLuint*)tmp_buf);
+        if (n != m_numConfigs) {
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        //Fill the attributes vector.
+        //The first m_numConfigAttribs values of tmp_buf are the actual attributes enums.
+        for (int i=0; i<m_numConfigAttribs; i++) {
+            m_attribs.add(tmp_buf[i], i);
+        }
+
+        //Copy the actual configs data to m_configs
+        memcpy(m_configs, tmp_buf + m_numConfigAttribs, m_numConfigs*m_numConfigAttribs*sizeof(EGLint));
+
+        m_initialized = true;
+    }
+    pthread_mutex_unlock(&m_lock);
+
+    processConfigs();
+
+    return true;
+}
+
+void eglDisplay::processConfigs()
+{
+    for (int i=0; i<m_numConfigs; i++) {
+        EGLConfig config = (EGLConfig)i;
+        //Setup the EGL_NATIVE_VISUAL_ID attribute
+        PixelFormat format;
+        if (getConfigNativePixelFormat(config, &format)) {
+            setConfigAttrib(config, EGL_NATIVE_VISUAL_ID, format);
+        }
+    }
+}
+
+void eglDisplay::terminate()
+{
+    pthread_mutex_lock(&m_lock);
+    if (m_initialized) {
+        m_initialized = false;
+        delete [] m_configs;
+        m_configs = NULL;
+
+        if (m_versionString) {
+            free(m_versionString);
+            m_versionString = NULL;
+        }
+        if (m_vendorString) {
+            free(m_vendorString);
+            m_vendorString = NULL;
+        }
+        if (m_extensionString) {
+            free(m_extensionString);
+            m_extensionString = NULL;
+        }
+    }
+    pthread_mutex_unlock(&m_lock);
+}
+
+EGLClient_glesInterface *eglDisplay::loadGLESClientAPI(const char *libName,
+                                                       EGLClient_eglInterface *eglIface,
+                                                       void **libHandle)
+{
+    void *lib = dlopen(libName, RTLD_NOW);
+    if (!lib) {
+        ALOGE("Failed to dlopen %s", libName);
+        return NULL;
+    }
+
+    init_emul_gles_t init_gles_func = (init_emul_gles_t)dlsym(lib,"init_emul_gles");
+    if (!init_gles_func) {
+        ALOGE("Failed to find init_emul_gles");
+        dlclose((void*)lib);
+        return NULL;
+    }
+
+    *libHandle = lib;
+    return (*init_gles_func)(eglIface);
+}
+
+static char *queryHostEGLString(EGLint name)
+{
+    HostConnection *hcon = HostConnection::get();
+    if (hcon) {
+        renderControl_encoder_context_t *rcEnc = hcon->rcEncoder();
+        if (rcEnc) {
+            int n = rcEnc->rcQueryEGLString(rcEnc, name, NULL, 0);
+            if (n < 0) {
+                // allocate space for the string with additional
+                // space charachter to be suffixed at the end.
+                char *str = (char *)malloc(-n+2);
+                n = rcEnc->rcQueryEGLString(rcEnc, name, str, -n);
+                if (n > 0) {
+                    // add extra space at end of string which will be
+                    // needed later when filtering the extension list.
+                    strcat(str, " ");
+                    return str;
+                }
+
+                free(str);
+            }
+        }
+    }
+
+    return NULL;
+}
+
+static bool findExtInList(const char* token, int tokenlen, const char* list)
+{
+    const char* p = list;
+    while (*p != '\0') {
+        const char* q = strchr(p, ' ');
+        if (q == NULL) {
+            /* should not happen, list must be space-terminated */
+            break;
+        }
+        if (tokenlen == (q - p) && !memcmp(token, p, tokenlen)) {
+            return true;  /* found it */
+        }
+        p = q+1;
+    }
+    return false;  /* not found */
+}
+
+static char *buildExtensionString()
+{
+    //Query host extension string
+    char *hostExt = queryHostEGLString(EGL_EXTENSIONS);
+    if (!hostExt || (hostExt[1] == '\0')) {
+        // no extensions on host - only static extension list supported
+        return strdup(systemStaticEGLExtensions);
+    }
+
+    //
+    // Filter host extension list to include only extensions
+    // we can support (in the systemDynamicEGLExtensions list)
+    //
+    char *ext = (char *)hostExt;
+    char *c = ext;
+    char *insert = ext;
+    while(*c != '\0') {
+        if (*c == ' ') {
+            int len = c - ext;
+            if (findExtInList(ext, len, systemDynamicEGLExtensions)) {
+                if (ext != insert) {
+                    memcpy(insert, ext, len+1); // including space
+                }
+                insert += (len + 1);
+            }
+            ext = c + 1;
+        }
+        c++;
+    }
+    *insert = '\0';
+
+    int n = strlen(hostExt);
+    if (n > 0) {
+        char *str;
+        asprintf(&str,"%s%s", systemStaticEGLExtensions, hostExt);
+        free((char*)hostExt);
+        return str;
+    }
+    else {
+        free((char*)hostExt);
+        return strdup(systemStaticEGLExtensions);
+    }
+}
+
+const char *eglDisplay::queryString(EGLint name)
+{
+    if (name == EGL_CLIENT_APIS) {
+        return "OpenGL_ES";
+    }
+    else if (name == EGL_VERSION) {
+        pthread_mutex_lock(&m_lock);
+        if (m_versionString) {
+            pthread_mutex_unlock(&m_lock);
+            return m_versionString;
+        }
+
+        // build version string
+        asprintf(&m_versionString, "%d.%d", m_major, m_minor);
+        pthread_mutex_unlock(&m_lock);
+
+        return m_versionString;
+    }
+    else if (name == EGL_VENDOR) {
+        pthread_mutex_lock(&m_lock);
+        if (m_vendorString) {
+            pthread_mutex_unlock(&m_lock);
+            return m_vendorString;
+        }
+
+        // build vendor string
+        const char *hostVendor = queryHostEGLString(EGL_VENDOR);
+
+        if (hostVendor) {
+            asprintf(&m_vendorString, "%s Host: %s",
+                                     systemEGLVendor, hostVendor);
+            free((char*)hostVendor);
+        }
+        else {
+            m_vendorString = (char *)systemEGLVendor;
+        }
+        pthread_mutex_unlock(&m_lock);
+
+        return m_vendorString;
+    }
+    else if (name == EGL_EXTENSIONS) {
+        pthread_mutex_lock(&m_lock);
+        if (m_extensionString) {
+            pthread_mutex_unlock(&m_lock);
+            return m_extensionString;
+        }
+
+        // build extension string
+        m_extensionString = buildExtensionString();
+        pthread_mutex_unlock(&m_lock);
+
+        return m_extensionString;
+    }
+    else {
+        ALOGE("[%s] Unknown name %d\n", __FUNCTION__, name);
+        return NULL;
+    }
+}
+
+/* To get the value of attribute <a> of config <c> use the following formula:
+ * value = *(m_configs + (int)c*m_numConfigAttribs + a);
+ */
+EGLBoolean eglDisplay::getAttribValue(EGLConfig config, EGLint attribIdx, EGLint * value)
+{
+    if (attribIdx == ATTRIBUTE_NONE)
+    {
+        ALOGE("[%s] Bad attribute idx\n", __FUNCTION__);
+        return EGL_FALSE;
+    }
+    *value = *(m_configs + (int)config*m_numConfigAttribs + attribIdx);
+    return EGL_TRUE;
+}
+
+EGLBoolean eglDisplay::getConfigAttrib(EGLConfig config, EGLint attrib, EGLint * value)
+{
+    //Though it seems that valueFor() is thread-safe, we don't take chanses
+    pthread_mutex_lock(&m_lock);
+    EGLBoolean ret = getAttribValue(config, m_attribs.valueFor(attrib), value);
+    pthread_mutex_unlock(&m_lock);
+    return ret;
+}
+
+void eglDisplay::dumpConfig(EGLConfig config)
+{
+    EGLint value = 0;
+    DBG("^^^^^^^^^^ dumpConfig %d ^^^^^^^^^^^^^^^^^^", (int)config);
+    for (int i=0; i<m_numConfigAttribs; i++) {
+        getAttribValue(config, i, &value);
+        DBG("{%d}[%d] %d\n", (int)config, i, value);
+    }
+}
+
+/* To set the value of attribute <a> of config <c> use the following formula:
+ * *(m_configs + (int)c*m_numConfigAttribs + a) = value;
+ */
+EGLBoolean eglDisplay::setAttribValue(EGLConfig config, EGLint attribIdx, EGLint value)
+{
+    if (attribIdx == ATTRIBUTE_NONE)
+    {
+        ALOGE("[%s] Bad attribute idx\n", __FUNCTION__);
+        return EGL_FALSE;
+    }
+    *(m_configs + (int)config*m_numConfigAttribs + attribIdx) = value;
+    return EGL_TRUE;
+}
+
+EGLBoolean eglDisplay::setConfigAttrib(EGLConfig config, EGLint attrib, EGLint value)
+{
+    //Though it seems that valueFor() is thread-safe, we don't take chanses
+    pthread_mutex_lock(&m_lock);
+    EGLBoolean ret = setAttribValue(config, m_attribs.valueFor(attrib), value);
+    pthread_mutex_unlock(&m_lock);
+    return ret;
+}
+
+
+EGLBoolean eglDisplay::getConfigNativePixelFormat(EGLConfig config, PixelFormat * format)
+{
+    EGLint redSize, blueSize, greenSize, alphaSize;
+
+    if ( !(getAttribValue(config, m_attribs.valueFor(EGL_RED_SIZE), &redSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_BLUE_SIZE), &blueSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_GREEN_SIZE), &greenSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_ALPHA_SIZE), &alphaSize)) )
+    {
+        ALOGE("Couldn't find value for one of the pixel format attributes");
+        return EGL_FALSE;
+    }
+
+    //calculate the GL internal format
+    if ((redSize==8)&&(greenSize==8)&&(blueSize==8)&&(alphaSize==8)) *format = PIXEL_FORMAT_RGBA_8888; //XXX: BGR?
+    else if ((redSize==8)&&(greenSize==8)&&(blueSize==8)&&(alphaSize==0)) *format = PIXEL_FORMAT_RGBX_8888; //XXX or PIXEL_FORMAT_RGB_888
+    else if ((redSize==5)&&(greenSize==6)&&(blueSize==5)&&(alphaSize==0)) *format = PIXEL_FORMAT_RGB_565;
+    else if ((redSize==5)&&(greenSize==5)&&(blueSize==5)&&(alphaSize==1)) *format = PIXEL_FORMAT_RGBA_5551;
+    else if ((redSize==4)&&(greenSize==4)&&(blueSize==4)&&(alphaSize==4)) *format = PIXEL_FORMAT_RGBA_4444;
+    else {
+        return EGL_FALSE;
+    }
+    return EGL_TRUE;
+}
+EGLBoolean eglDisplay::getConfigGLPixelFormat(EGLConfig config, GLenum * format)
+{
+    EGLint redSize, blueSize, greenSize, alphaSize;
+
+    if ( !(getAttribValue(config, m_attribs.valueFor(EGL_RED_SIZE), &redSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_BLUE_SIZE), &blueSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_GREEN_SIZE), &greenSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_ALPHA_SIZE), &alphaSize)) )
+    {
+        ALOGE("Couldn't find value for one of the pixel format attributes");
+        return EGL_FALSE;
+    }
+
+    //calculate the GL internal format
+    if ((redSize==8)&&(blueSize==8)&&(blueSize==8)&&(alphaSize==8)) *format = GL_RGBA;
+    else if ((redSize==8)&&(greenSize==8)&&(blueSize==8)&&(alphaSize==0)) *format = GL_RGB;
+    else if ((redSize==5)&&(greenSize==6)&&(blueSize==5)&&(alphaSize==0)) *format = GL_RGB565_OES;
+    else if ((redSize==5)&&(greenSize==5)&&(blueSize==5)&&(alphaSize==1)) *format = GL_RGB5_A1_OES;
+    else if ((redSize==4)&&(greenSize==4)&&(blueSize==4)&&(alphaSize==4)) *format = GL_RGBA4_OES;
+    else return EGL_FALSE;
+
+    return EGL_TRUE;
+}
diff --git a/tools/emulator/opengl/system/egl/eglDisplay.h b/tools/emulator/opengl/system/egl/eglDisplay.h
new file mode 100644
index 0000000..9d979d9
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/eglDisplay.h
@@ -0,0 +1,89 @@
+/*
+* 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 _SYSTEM_EGL_DISPLAY_H
+#define _SYSTEM_EGL_DISPLAY_H
+
+#include <pthread.h>
+#include "glUtils.h"
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include "EGLClientIface.h"
+#include <utils/KeyedVector.h>
+
+#include <ui/PixelFormat.h>
+
+#define ATTRIBUTE_NONE -1
+//FIXME: are we in this namespace?
+using namespace android;
+
+class eglDisplay
+{
+public:
+    eglDisplay();
+    ~eglDisplay();
+
+    bool initialize(EGLClient_eglInterface *eglIface);
+    void terminate();
+
+    int getVersionMajor() const { return m_major; }
+    int getVersionMinor() const { return m_minor; }
+    bool initialized() const { return m_initialized; }
+
+    const char *queryString(EGLint name);
+
+    const EGLClient_glesInterface *gles_iface() const { return m_gles_iface; }
+    const EGLClient_glesInterface *gles2_iface() const { return m_gles2_iface; }
+
+    int     getNumConfigs(){ return m_numConfigs; }
+    EGLBoolean  getConfigAttrib(EGLConfig config, EGLint attrib, EGLint * value);
+    EGLBoolean  setConfigAttrib(EGLConfig config, EGLint attrib, EGLint value);
+    EGLBoolean getConfigGLPixelFormat(EGLConfig config, GLenum * format);
+    EGLBoolean getConfigNativePixelFormat(EGLConfig config, PixelFormat * format);
+
+    void     dumpConfig(EGLConfig config);
+private:
+    EGLClient_glesInterface *loadGLESClientAPI(const char *libName,
+                                               EGLClient_eglInterface *eglIface,
+                                               void **libHandle);
+    EGLBoolean getAttribValue(EGLConfig config, EGLint attribIdxi, EGLint * value);
+    EGLBoolean setAttribValue(EGLConfig config, EGLint attribIdxi, EGLint value);
+    void     processConfigs();
+
+private:
+    pthread_mutex_t m_lock;
+    bool m_initialized;
+    int  m_major;
+    int  m_minor;
+    int  m_hostRendererVersion;
+    int  m_numConfigs;
+    int  m_numConfigAttribs;
+
+    /* This is the mapping between an attribute name to it's index in any given config */
+    DefaultKeyedVector<EGLint, EGLint>    m_attribs;
+    /* This is an array of all config's attributes values stored in the following sequencial fasion (read: v[c,a] = the value of attribute <a> of config <c>)
+     * v[0,0],..,v[0,m_numConfigAttribs-1],
+     *...
+     * v[m_numConfigs-1,0],..,v[m_numConfigs-1,m_numConfigAttribs-1]
+     */
+    EGLint *m_configs;
+    EGLClient_glesInterface *m_gles_iface;
+    EGLClient_glesInterface *m_gles2_iface;
+    char *m_versionString;
+    char *m_vendorString;
+    char *m_extensionString;
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/egl/egl_ftable.h b/tools/emulator/opengl/system/egl/egl_ftable.h
new file mode 100644
index 0000000..16d130c
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/egl_ftable.h
@@ -0,0 +1,64 @@
+/*
+* 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 const 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},
+    {"eglGetSyncAttribKHR", (void *)eglGetSyncAttribKHR}
+};
+
+static const int egl_num_funcs = sizeof(egl_funcs_by_name) / sizeof(struct _egl_funcs_by_name);
diff --git a/tools/emulator/opengl/system/gralloc/Android.mk b/tools/emulator/opengl/system/gralloc/Android.mk
new file mode 100644
index 0000000..8705602
--- /dev/null
+++ b/tools/emulator/opengl/system/gralloc/Android.mk
@@ -0,0 +1,19 @@
+ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER))
+
+LOCAL_PATH := $(call my-dir)
+
+$(call emugl-begin-shared-library,gralloc.goldfish)
+$(call emugl-import,libGLESv1_enc lib_renderControl_enc libOpenglSystemCommon)
+$(call emugl-set-shared-library-subpath,hw)
+
+LOCAL_CFLAGS += -DLOG_TAG=\"gralloc_goldfish\"
+
+LOCAL_SRC_FILES := gralloc.cpp
+
+# Need to access the special OPENGL TLS Slot
+LOCAL_C_INCLUDES += bionic/libc/private
+LOCAL_SHARED_LIBRARIES += libdl
+
+$(call emugl-end-module)
+
+endif # BUILD_EMULATOR_OPENGL_DRIVER != false
diff --git a/tools/emulator/opengl/system/gralloc/gralloc.cpp b/tools/emulator/opengl/system/gralloc/gralloc.cpp
new file mode 100644
index 0000000..4334835
--- /dev/null
+++ b/tools/emulator/opengl/system/gralloc/gralloc.cpp
@@ -0,0 +1,847 @@
+/*
+* 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 <string.h>
+#include <pthread.h>
+#ifdef HAVE_ANDROID_OS      // just want PAGE_SIZE define
+# include <asm/page.h>
+#else
+# include <sys/user.h>
+#endif
+#include <cutils/ashmem.h>
+#include <unistd.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <sys/mman.h>
+#include "gralloc_cb.h"
+#include "HostConnection.h"
+#include "glUtils.h"
+#include <cutils/log.h>
+#include <cutils/properties.h>
+
+/* Set to 1 or 2 to enable debug traces */
+#define DEBUG  0
+
+#if DEBUG >= 1
+#  define D(...)   ALOGD(__VA_ARGS__)
+#else
+#  define D(...)   ((void)0)
+#endif
+
+#if DEBUG >= 2
+#  define DD(...)  ALOGD(__VA_ARGS__)
+#else
+#  define DD(...)  ((void)0)
+#endif
+
+#define DBG_FUNC DBG("%s\n", __FUNCTION__)
+//
+// our private gralloc module structure
+//
+struct private_module_t {
+    gralloc_module_t base;
+};
+
+/* If not NULL, this is a pointer to the fallback module.
+ * This really is gralloc.default, which we'll use if we detect
+ * that the emulator we're running in does not support GPU emulation.
+ */
+static gralloc_module_t*  sFallback;
+static pthread_once_t     sFallbackOnce = PTHREAD_ONCE_INIT;
+
+static void fallback_init(void);  // forward
+
+
+typedef struct _alloc_list_node {
+    buffer_handle_t handle;
+    _alloc_list_node *next;
+    _alloc_list_node *prev;
+} AllocListNode;
+
+//
+// Our gralloc device structure (alloc interface)
+//
+struct gralloc_device_t {
+    alloc_device_t  device;
+
+    AllocListNode *allocListHead;    // double linked list of allocated buffers
+    pthread_mutex_t lock;
+};
+
+//
+// Our framebuffer device structure
+//
+struct fb_device_t {
+    framebuffer_device_t  device;
+};
+
+static int map_buffer(cb_handle_t *cb, void **vaddr)
+{
+    if (cb->fd < 0 || cb->ashmemSize <= 0) {
+        return -EINVAL;
+    }
+
+    void *addr = mmap(0, cb->ashmemSize, PROT_READ | PROT_WRITE,
+                      MAP_SHARED, cb->fd, 0);
+    if (addr == MAP_FAILED) {
+        return -errno;
+    }
+
+    cb->ashmemBase = intptr_t(addr);
+    cb->ashmemBasePid = getpid();
+
+    *vaddr = addr;
+    return 0;
+}
+
+#define DEFINE_HOST_CONNECTION \
+    HostConnection *hostCon = HostConnection::get(); \
+    renderControl_encoder_context_t *rcEnc = (hostCon ? hostCon->rcEncoder() : NULL)
+
+#define DEFINE_AND_VALIDATE_HOST_CONNECTION \
+    HostConnection *hostCon = HostConnection::get(); \
+    if (!hostCon) { \
+        ALOGE("gralloc: Failed to get host connection\n"); \
+        return -EIO; \
+    } \
+    renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
+    if (!rcEnc) { \
+        ALOGE("gralloc: Failed to get renderControl encoder context\n"); \
+        return -EIO; \
+    }
+
+
+//
+// gralloc device functions (alloc interface)
+//
+static int gralloc_alloc(alloc_device_t* dev,
+                         int w, int h, int format, int usage,
+                         buffer_handle_t* pHandle, int* pStride)
+{
+    D("gralloc_alloc w=%d h=%d usage=0x%x\n", w, h, usage);
+
+    gralloc_device_t *grdev = (gralloc_device_t *)dev;
+    if (!grdev || !pHandle || !pStride)
+        return -EINVAL;
+
+    //
+    // Validate usage: buffer cannot be written both by s/w and h/w access.
+    //
+    bool sw_write = (0 != (usage & GRALLOC_USAGE_SW_WRITE_MASK));
+    bool hw_write = (usage & GRALLOC_USAGE_HW_RENDER);
+    if (hw_write && sw_write) {
+        return -EINVAL;
+    }
+    bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK));
+
+    int ashmem_size = 0;
+    int stride = w;
+
+    GLenum glFormat = 0;
+    GLenum glType = 0;
+
+    int bpp = 0;
+    int align = 1;
+    switch (format) {
+        case HAL_PIXEL_FORMAT_RGBA_8888:
+        case HAL_PIXEL_FORMAT_RGBX_8888:
+        case HAL_PIXEL_FORMAT_BGRA_8888:
+            bpp = 4;
+            glFormat = GL_RGBA;
+            glType = GL_UNSIGNED_BYTE;
+            break;
+        case HAL_PIXEL_FORMAT_RGB_888:
+            bpp = 3;
+            glFormat = GL_RGB;
+            glType = GL_UNSIGNED_BYTE;
+            break;
+        case HAL_PIXEL_FORMAT_RGB_565:
+            bpp = 2;
+            glFormat = GL_RGB;
+            glType = GL_UNSIGNED_SHORT_5_6_5;
+            break;
+        case HAL_PIXEL_FORMAT_RGBA_5551:
+            bpp = 2;
+            glFormat = GL_RGB5_A1_OES;
+            glType = GL_UNSIGNED_SHORT_5_5_5_1;
+            break;
+        case HAL_PIXEL_FORMAT_RGBA_4444:
+            bpp = 2;
+            glFormat = GL_RGBA4_OES;
+            glType = GL_UNSIGNED_SHORT_4_4_4_4;
+            break;
+        case HAL_PIXEL_FORMAT_RAW_SENSOR:
+            bpp = 2;
+            align = 16*bpp;
+            if (! (sw_read && sw_write) ) {
+                // Raw sensor data cannot be used by HW
+                return -EINVAL;
+            }
+            glFormat = GL_LUMINANCE;
+            glType = GL_UNSIGNED_SHORT;
+            break;
+        default:
+            return -EINVAL;
+    }
+
+    if (usage & GRALLOC_USAGE_HW_FB) {
+        // keep space for postCounter
+        ashmem_size += sizeof(uint32_t);
+    }
+
+    if (sw_read || sw_write) {
+        // keep space for image on guest memory if SW access is needed
+
+        size_t bpr = (w*bpp + (align-1)) & ~(align-1);
+        ashmem_size += (bpr * h);
+        stride = bpr / bpp;
+    }
+
+    D("gralloc_alloc ashmem_size=%d, stride=%d, tid %d\n", ashmem_size, stride,
+            gettid());
+
+    //
+    // Allocate space in ashmem if needed
+    //
+    int fd = -1;
+    if (ashmem_size > 0) {
+        // round to page size;
+        ashmem_size = (ashmem_size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
+
+        fd = ashmem_create_region("gralloc-buffer", ashmem_size);
+        if (fd < 0) {
+            ALOGE("gralloc_alloc failed to create ashmem region: %s\n",
+                    strerror(errno));
+            return -errno;
+        }
+    }
+
+    cb_handle_t *cb = new cb_handle_t(fd, ashmem_size, usage,
+                                      w, h, glFormat, glType);
+
+    if (ashmem_size > 0) {
+        //
+        // map ashmem region if exist
+        //
+        void *vaddr;
+        int err = map_buffer(cb, &vaddr);
+        if (err) {
+            close(fd);
+            delete cb;
+            return err;
+        }
+
+        cb->setFd(fd);
+    }
+
+    //
+    // Allocate ColorBuffer handle on the host (only if h/w access is allowed)
+    //
+    if (usage & GRALLOC_USAGE_HW_MASK) {
+        DEFINE_HOST_CONNECTION;
+        if (hostCon && rcEnc) {
+            cb->hostHandle = rcEnc->rcCreateColorBuffer(rcEnc, w, h, glFormat);
+            D("Created host ColorBuffer 0x%x\n", cb->hostHandle);
+        }
+
+        if (!cb->hostHandle) {
+           // Could not create colorbuffer on host !!!
+           close(fd);
+           delete cb;
+           return -EIO;
+        }
+    }
+
+    //
+    // alloc succeeded - insert the allocated handle to the allocated list
+    //
+    AllocListNode *node = new AllocListNode();
+    pthread_mutex_lock(&grdev->lock);
+    node->handle = cb;
+    node->next =  grdev->allocListHead;
+    node->prev =  NULL;
+    if (grdev->allocListHead) {
+        grdev->allocListHead->prev = node;
+    }
+    grdev->allocListHead = node;
+    pthread_mutex_unlock(&grdev->lock);
+
+    *pHandle = cb;
+    *pStride = stride;
+    return 0;
+}
+
+static int gralloc_free(alloc_device_t* dev,
+                        buffer_handle_t handle)
+{
+    const cb_handle_t *cb = (const cb_handle_t *)handle;
+    if (!cb_handle_t::validate((cb_handle_t*)cb)) {
+        ERR("gralloc_free: invalid handle");
+        return -EINVAL;
+    }
+
+    if (cb->hostHandle != 0) {
+        DEFINE_AND_VALIDATE_HOST_CONNECTION;
+        D("Closing host ColorBuffer 0x%x\n", cb->hostHandle);
+        rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle);
+    }
+
+    //
+    // detach and unmap ashmem area if present
+    //
+    if (cb->fd > 0) {
+        if (cb->ashmemSize > 0 && cb->ashmemBase) {
+            munmap((void *)cb->ashmemBase, cb->ashmemSize);
+        }
+        close(cb->fd);
+    }
+
+    // remove it from the allocated list
+    gralloc_device_t *grdev = (gralloc_device_t *)dev;
+    pthread_mutex_lock(&grdev->lock);
+    AllocListNode *n = grdev->allocListHead;
+    while( n && n->handle != cb ) {
+        n = n->next;
+    }
+    if (n) {
+       // buffer found on list - remove it from list
+       if (n->next) {
+           n->next->prev = n->prev;
+       }
+       if (n->prev) {
+           n->prev->next = n->next;
+       }
+       else {
+           grdev->allocListHead = n->next;
+       }
+
+       delete n;
+    }
+    pthread_mutex_unlock(&grdev->lock);
+
+    delete cb;
+
+    return 0;
+}
+
+static int gralloc_device_close(struct hw_device_t *dev)
+{
+    gralloc_device_t* d = reinterpret_cast<gralloc_device_t*>(dev);
+    if (d) {
+
+        // free still allocated buffers
+        while( d->allocListHead != NULL ) {
+            gralloc_free(&d->device, d->allocListHead->handle);
+        }
+
+        // free device
+        free(d);
+    }
+    return 0;
+}
+
+static int fb_compositionComplete(struct framebuffer_device_t* dev)
+{
+    return 0;
+}
+
+//
+// Framebuffer device functions
+//
+static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
+{
+    fb_device_t *fbdev = (fb_device_t *)dev;
+    cb_handle_t *cb = (cb_handle_t *)buffer;
+
+    if (!fbdev || !cb_handle_t::validate(cb) || !cb->canBePosted()) {
+        return -EINVAL;
+    }
+
+    // Make sure we have host connection
+    DEFINE_AND_VALIDATE_HOST_CONNECTION;
+
+    // increment the post count of the buffer
+    uint32_t *postCountPtr = (uint32_t *)cb->ashmemBase;
+    if (!postCountPtr) {
+        // This should not happen
+        return -EINVAL;
+    }
+    (*postCountPtr)++;
+
+    // send post request to host
+    rcEnc->rcFBPost(rcEnc, cb->hostHandle);
+    hostCon->flush();
+
+    return 0;
+}
+
+static int fb_setUpdateRect(struct framebuffer_device_t* dev,
+        int l, int t, int w, int h)
+{
+    fb_device_t *fbdev = (fb_device_t *)dev;
+
+    if (!fbdev) {
+        return -EINVAL;
+    }
+
+    // Make sure we have host connection
+    DEFINE_AND_VALIDATE_HOST_CONNECTION;
+
+    // send request to host
+    // TODO: XXX - should be implemented
+    //rcEnc->rc_XXX
+
+    return 0;
+}
+
+static int fb_setSwapInterval(struct framebuffer_device_t* dev,
+            int interval)
+{
+    fb_device_t *fbdev = (fb_device_t *)dev;
+
+    if (!fbdev) {
+        return -EINVAL;
+    }
+
+    // Make sure we have host connection
+    DEFINE_AND_VALIDATE_HOST_CONNECTION;
+
+    // send request to host
+    rcEnc->rcFBSetSwapInterval(rcEnc, interval);
+    hostCon->flush();
+
+    return 0;
+}
+
+static int fb_close(struct hw_device_t *dev)
+{
+    fb_device_t *fbdev = (fb_device_t *)dev;
+
+    delete fbdev;
+
+    return 0;
+}
+
+
+//
+// gralloc module functions - refcount + locking interface
+//
+static int gralloc_register_buffer(gralloc_module_t const* module,
+                                   buffer_handle_t handle)
+{
+    pthread_once(&sFallbackOnce, fallback_init);
+    if (sFallback != NULL) {
+        return sFallback->registerBuffer(sFallback, handle);
+    }
+
+    D("gralloc_register_buffer(%p) called", handle);
+
+    private_module_t *gr = (private_module_t *)module;
+    cb_handle_t *cb = (cb_handle_t *)handle;
+    if (!gr || !cb_handle_t::validate(cb)) {
+        ERR("gralloc_register_buffer(%p): invalid buffer", cb);
+        return -EINVAL;
+    }
+
+    if (cb->hostHandle != 0) {
+        DEFINE_AND_VALIDATE_HOST_CONNECTION;
+        D("Opening host ColorBuffer 0x%x\n", cb->hostHandle);
+        rcEnc->rcOpenColorBuffer(rcEnc, cb->hostHandle);
+    }
+
+    //
+    // if the color buffer has ashmem region and it is not mapped in this
+    // process map it now.
+    //
+    if (cb->ashmemSize > 0 && cb->mappedPid != getpid()) {
+        void *vaddr;
+        int err = map_buffer(cb, &vaddr);
+        if (err) {
+            ERR("gralloc_register_buffer(%p): map failed: %s", cb, strerror(-err));
+            return -err;
+        }
+        cb->mappedPid = getpid();
+    }
+
+    return 0;
+}
+
+static int gralloc_unregister_buffer(gralloc_module_t const* module,
+                                     buffer_handle_t handle)
+{
+    if (sFallback != NULL) {
+        return sFallback->unregisterBuffer(sFallback, handle);
+    }
+
+    private_module_t *gr = (private_module_t *)module;
+    cb_handle_t *cb = (cb_handle_t *)handle;
+    if (!gr || !cb_handle_t::validate(cb)) {
+        ERR("gralloc_unregister_buffer(%p): invalid buffer", cb);
+        return -EINVAL;
+    }
+
+    if (cb->hostHandle != 0) {
+        DEFINE_AND_VALIDATE_HOST_CONNECTION;
+        D("Closing host ColorBuffer 0x%x\n", cb->hostHandle);
+        rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle);
+    }
+
+    //
+    // unmap ashmem region if it was previously mapped in this process
+    // (through register_buffer)
+    //
+    if (cb->ashmemSize > 0 && cb->mappedPid == getpid()) {
+        void *vaddr;
+        int err = munmap((void *)cb->ashmemBase, cb->ashmemSize);
+        if (err) {
+            ERR("gralloc_unregister_buffer(%p): unmap failed", cb);
+            return -EINVAL;
+        }
+        cb->ashmemBase = NULL;
+        cb->mappedPid = 0;
+    }
+
+    D("gralloc_unregister_buffer(%p) done\n", cb);
+
+    return 0;
+}
+
+static int gralloc_lock(gralloc_module_t const* module,
+                        buffer_handle_t handle, int usage,
+                        int l, int t, int w, int h,
+                        void** vaddr)
+{
+    if (sFallback != NULL) {
+        return sFallback->lock(sFallback, handle, usage, l, t, w, h, vaddr);
+    }
+
+    private_module_t *gr = (private_module_t *)module;
+    cb_handle_t *cb = (cb_handle_t *)handle;
+    if (!gr || !cb_handle_t::validate(cb)) {
+        ALOGE("gralloc_lock bad handle\n");
+        return -EINVAL;
+    }
+
+    // Validate usage,
+    //   1. cannot be locked for hw access
+    //   2. lock for either sw read or write.
+    //   3. locked sw access must match usage during alloc time.
+    bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK));
+    bool sw_write = (0 != (usage & GRALLOC_USAGE_SW_WRITE_MASK));
+    bool hw_read = (usage & GRALLOC_USAGE_HW_TEXTURE);
+    bool hw_write = (usage & GRALLOC_USAGE_HW_RENDER);
+    bool sw_read_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_READ_MASK));
+    bool sw_write_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_WRITE_MASK));
+
+    if ( (hw_read || hw_write) ||
+         (!sw_read && !sw_write) ||
+         (sw_read && !sw_read_allowed) ||
+         (sw_write && !sw_write_allowed) ) {
+        ALOGE("gralloc_lock usage mismatch usage=0x%x cb->usage=0x%x\n", usage, cb->usage);
+        return -EINVAL;
+    }
+
+    EGLint postCount = 0;
+    void *cpu_addr = NULL;
+
+    //
+    // make sure ashmem area is mapped if needed
+    //
+    if (cb->canBePosted() || sw_read || sw_write) {
+        if (cb->ashmemBasePid != getpid() || !cb->ashmemBase) {
+            return -EACCES;
+        }
+
+        if (cb->canBePosted()) {
+            postCount = *((int *)cb->ashmemBase);
+            cpu_addr = (void *)(cb->ashmemBase + sizeof(int));
+        }
+        else {
+            cpu_addr = (void *)(cb->ashmemBase);
+        }
+    }
+
+    if (cb->hostHandle) {
+        // Make sure we have host connection
+        DEFINE_AND_VALIDATE_HOST_CONNECTION;
+
+        //
+        // flush color buffer write cache on host and get its sync status.
+        //
+        int hostSyncStatus = rcEnc->rcColorBufferCacheFlush(rcEnc, cb->hostHandle,
+                                                            postCount,
+                                                            sw_read);
+        if (hostSyncStatus < 0) {
+            // host failed the color buffer sync - probably since it was already
+            // locked for write access. fail the lock.
+            ALOGE("gralloc_lock cacheFlush failed postCount=%d sw_read=%d\n",
+                 postCount, sw_read);
+            return -EBUSY;
+        }
+
+    }
+
+    //
+    // is virtual address required ?
+    //
+    if (sw_read || sw_write) {
+        *vaddr = cpu_addr;
+    }
+
+    if (sw_write) {
+        //
+        // Keep locked region if locked for s/w write access.
+        //
+        cb->lockedLeft = l;
+        cb->lockedTop = t;
+        cb->lockedWidth = w;
+        cb->lockedHeight = h;
+    }
+
+    return 0;
+}
+
+static int gralloc_unlock(gralloc_module_t const* module,
+                          buffer_handle_t handle)
+{
+    if (sFallback != NULL) {
+        return sFallback->unlock(sFallback, handle);
+    }
+
+    private_module_t *gr = (private_module_t *)module;
+    cb_handle_t *cb = (cb_handle_t *)handle;
+    if (!gr || !cb_handle_t::validate(cb)) {
+        return -EINVAL;
+    }
+
+    //
+    // if buffer was locked for s/w write, we need to update the host with
+    // the updated data
+    //
+    if (cb->lockedWidth > 0 && cb->lockedHeight > 0 && cb->hostHandle) {
+
+        // Make sure we have host connection
+        DEFINE_AND_VALIDATE_HOST_CONNECTION;
+
+        void *cpu_addr;
+        if (cb->canBePosted()) {
+            cpu_addr = (void *)(cb->ashmemBase + sizeof(int));
+        }
+        else {
+            cpu_addr = (void *)(cb->ashmemBase);
+        }
+
+        if (cb->lockedWidth < cb->width || cb->lockedHeight < cb->height) {
+            int bpp = glUtilsPixelBitSize(cb->glFormat, cb->glType) >> 3;
+            char *tmpBuf = new char[cb->lockedWidth * cb->lockedHeight * bpp];
+
+            int dst_line_len = cb->lockedWidth * bpp;
+            int src_line_len = cb->width * bpp;
+            char *src = (char *)cpu_addr + cb->lockedTop*src_line_len + cb->lockedLeft*bpp;
+            char *dst = tmpBuf;
+            for (int y=0; y<cb->lockedHeight; y++) {
+                memcpy(dst, src, dst_line_len);
+                src += src_line_len;
+                dst += dst_line_len;
+            }
+
+            rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle,
+                                       cb->lockedLeft, cb->lockedTop,
+                                       cb->lockedWidth, cb->lockedHeight,
+                                       cb->glFormat, cb->glType,
+                                       tmpBuf);
+
+            delete [] tmpBuf;
+        }
+        else {
+            rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle, 0, 0,
+                                       cb->width, cb->height,
+                                       cb->glFormat, cb->glType,
+                                       cpu_addr);
+        }
+    }
+
+    cb->lockedWidth = cb->lockedHeight = 0;
+    return 0;
+}
+
+
+static int gralloc_device_open(const hw_module_t* module,
+                               const char* name,
+                               hw_device_t** device)
+{
+    int status = -EINVAL;
+
+    D("gralloc_device_open %s\n", name);
+
+    pthread_once( &sFallbackOnce, fallback_init );
+    if (sFallback != NULL) {
+        return sFallback->common.methods->open(&sFallback->common, name, device);
+    }
+
+    if (!strcmp(name, GRALLOC_HARDWARE_GPU0)) {
+
+        // Create host connection and keep it in the TLS.
+        // return error if connection with host can not be established
+        HostConnection *hostCon = HostConnection::get();
+        if (!hostCon) {
+            ALOGE("gralloc: failed to get host connection while opening %s\n", name);
+            return -EIO;
+        }
+
+        //
+        // Allocate memory for the gralloc device (alloc interface)
+        //
+        gralloc_device_t *dev;
+        dev = (gralloc_device_t*)malloc(sizeof(gralloc_device_t));
+        if (NULL == dev) {
+            return -ENOMEM;
+        }
+
+        // Initialize our device structure
+        //
+        dev->device.common.tag = HARDWARE_DEVICE_TAG;
+        dev->device.common.version = 0;
+        dev->device.common.module = const_cast<hw_module_t*>(module);
+        dev->device.common.close = gralloc_device_close;
+
+        dev->device.alloc   = gralloc_alloc;
+        dev->device.free    = gralloc_free;
+        dev->allocListHead  = NULL;
+        pthread_mutex_init(&dev->lock, NULL);
+
+        *device = &dev->device.common;
+        status = 0;
+    }
+    else if (!strcmp(name, GRALLOC_HARDWARE_FB0)) {
+
+        // return error if connection with host can not be established
+        DEFINE_AND_VALIDATE_HOST_CONNECTION;
+
+        //
+        // Query the host for Framebuffer attributes
+        //
+        D("gralloc: query Frabuffer attribs\n");
+        EGLint width = rcEnc->rcGetFBParam(rcEnc, FB_WIDTH);
+        D("gralloc: width=%d\n", width);
+        EGLint height = rcEnc->rcGetFBParam(rcEnc, FB_HEIGHT);
+        D("gralloc: height=%d\n", height);
+        EGLint xdpi = rcEnc->rcGetFBParam(rcEnc, FB_XDPI);
+        D("gralloc: xdpi=%d\n", xdpi);
+        EGLint ydpi = rcEnc->rcGetFBParam(rcEnc, FB_YDPI);
+        D("gralloc: ydpi=%d\n", ydpi);
+        EGLint fps = rcEnc->rcGetFBParam(rcEnc, FB_FPS);
+        D("gralloc: fps=%d\n", fps);
+        EGLint min_si = rcEnc->rcGetFBParam(rcEnc, FB_MIN_SWAP_INTERVAL);
+        D("gralloc: min_swap=%d\n", min_si);
+        EGLint max_si = rcEnc->rcGetFBParam(rcEnc, FB_MAX_SWAP_INTERVAL);
+        D("gralloc: max_swap=%d\n", max_si);
+
+        //
+        // Allocate memory for the framebuffer device
+        //
+        fb_device_t *dev;
+        dev = (fb_device_t*)malloc(sizeof(fb_device_t));
+        if (NULL == dev) {
+            return -ENOMEM;
+        }
+        memset(dev, 0, sizeof(fb_device_t));
+
+        // Initialize our device structure
+        //
+        dev->device.common.tag = HARDWARE_DEVICE_TAG;
+        dev->device.common.version = 0;
+        dev->device.common.module = const_cast<hw_module_t*>(module);
+        dev->device.common.close = fb_close;
+        dev->device.setSwapInterval = fb_setSwapInterval;
+        dev->device.post            = fb_post;
+        dev->device.setUpdateRect   = 0; //fb_setUpdateRect;
+        dev->device.compositionComplete = fb_compositionComplete; //XXX: this is a dummy
+
+        const_cast<uint32_t&>(dev->device.flags) = 0;
+        const_cast<uint32_t&>(dev->device.width) = width;
+        const_cast<uint32_t&>(dev->device.height) = height;
+        const_cast<int&>(dev->device.stride) = width;
+        const_cast<int&>(dev->device.format) = HAL_PIXEL_FORMAT_RGBA_8888;
+        const_cast<float&>(dev->device.xdpi) = xdpi;
+        const_cast<float&>(dev->device.ydpi) = ydpi;
+        const_cast<float&>(dev->device.fps) = fps;
+        const_cast<int&>(dev->device.minSwapInterval) = min_si;
+        const_cast<int&>(dev->device.maxSwapInterval) = max_si;
+        *device = &dev->device.common;
+
+        status = 0;
+    }
+
+    return status;
+}
+
+//
+// define the HMI symbol - our module interface
+//
+static struct hw_module_methods_t gralloc_module_methods = {
+        open: gralloc_device_open
+};
+
+struct private_module_t HAL_MODULE_INFO_SYM = {
+    base: {
+        common: {
+            tag: HARDWARE_MODULE_TAG,
+            version_major: 1,
+            version_minor: 0,
+            id: GRALLOC_HARDWARE_MODULE_ID,
+            name: "Graphics Memory Allocator Module",
+            author: "The Android Open Source Project",
+            methods: &gralloc_module_methods,
+            dso: NULL,
+            reserved: {0, }
+        },
+        registerBuffer: gralloc_register_buffer,
+        unregisterBuffer: gralloc_unregister_buffer,
+        lock: gralloc_lock,
+        unlock: gralloc_unlock,
+        perform: NULL,
+        reserved_proc : {NULL, }
+    }
+};
+
+/* This function is called once to detect whether the emulator supports
+ * GPU emulation (this is done by looking at the qemu.gles kernel
+ * parameter, which must be > 0 if this is the case).
+ *
+ * If not, then load gralloc.default instead as a fallback.
+ */
+static void
+fallback_init(void)
+{
+    char  prop[PROPERTY_VALUE_MAX];
+    void* module;
+
+    property_get("ro.kernel.qemu.gles", prop, "0");
+    if (atoi(prop) > 0) {
+        return;
+    }
+    ALOGD("Emulator without GPU emulation detected.");
+    module = dlopen("/system/lib/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL);
+    if (module != NULL) {
+        sFallback = reinterpret_cast<gralloc_module_t*>(dlsym(module, HAL_MODULE_INFO_SYM_AS_STR));
+        if (sFallback == NULL) {
+            dlclose(module);
+        }
+    }
+    if (sFallback == NULL) {
+        ALOGE("Could not find software fallback module!?");
+    }
+}
diff --git a/tools/emulator/opengl/system/renderControl_enc/Android.mk b/tools/emulator/opengl/system/renderControl_enc/Android.mk
new file mode 100644
index 0000000..5792440
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+
+$(call emugl-begin-shared-library,lib_renderControl_enc)
+
+LOCAL_SRC_FILES := \
+    renderControl_client_context.cpp \
+    renderControl_enc.cpp \
+    renderControl_entry.cpp
+
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+$(call emugl-import,libOpenglCodecCommon)
+$(call emugl-end-module)
diff --git a/tools/emulator/opengl/system/renderControl_enc/README b/tools/emulator/opengl/system/renderControl_enc/README
new file mode 100644
index 0000000..2ee1a57
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/README
@@ -0,0 +1,136 @@
+The renderControl.in file in this directory defines an API which is decoded
+on the android guest into a stream and get decoded and executed on the host.
+It is used in order to query the host renderer as well as send the host renderer
+control commands.
+
+The following describes each of the entries defined by this renderControl API.
+
+
+GLint rcGetRendererVersion();
+       This function queries the host renderer version number.
+
+EGLint rcGetEGLVersion(EGLint* major, EGLint* minor);
+       This function queries the host renderer for the EGL version
+       it supports. returns EGL_FALSE on failure.
+
+EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize);
+       This function queries the host for EGL string (.i.e EGL_EXTENSIONS).
+       if buffer is NULL or the bufferSize is not big enough the return value
+       is the negative number of bytes required to store the string value
+       otherwise the string value is copied to buffer and its size is
+       returned.
+
+EGLint rcGetNumConfigs(uint32_t* numAttribs);
+       queries the host for the number of supported EGL configs.
+       The function returns the number of supported configs and returns in
+       numAttribs the number of attributes available for each config.
+
+EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer);
+       This function queries the host for the all set of supported configs
+       with their attribute values.
+       bufSize is the size of buffer, the size should be at least equal to
+       (numConfigs + 1) * numAttribs * sizeof(GLuint)
+       where numConfigs and numAttribs are the values returned in 
+       rcGetNumConfigs. if bufSize is not big enough then the negative number
+       of required bytes is returned otherwise the function returns the number
+       of configs and buffer is filled as follows: The first 'numAttribs'
+       integer values are filled with the EGL enumerant describing a config
+       attribute, next for each config there are 'numAttribs' integer values
+       holding the attribute values for that config, the values are specified
+       in the same order as the attribute vector.
+
+EGLint rcChooseConfig(EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size)
+       This function triggers an eglChooseConfig on the host, to get a list of 
+       configs matching the given attribs values.
+ 	attribs - a list of attribute names followed by the desired values, terminated by EGL_NONE
+	attribs_size - the size of the list
+	configs - the returned matching configuration names (same names as familiar to the client in rcGetConfigs)
+	configs_size - the size of the configs buffers
+	returns - the actual number of matching configurations (<= configs_size) 
+
+EGLint rcGetFBParam(EGLint param);
+       queries the host for framebuffer parameter, see renderControl_types.h
+       for possible values of 'param'.
+
+uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion);
+       This function creates a rendering context on the host and returns its
+       handle. config is the config index for the context, share is either zero
+       or a handle to a sharing context. glVersion is either 1 or 2 for GLES1
+       or GLES2 context respectively.
+
+
+void rcDestroyContext(uint32_t context);
+       This function destroys a rendering context on the host.
+       context is a handle returned in rcCreateContext.
+
+uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height);
+       This function creates a 'window' surface on the host which can be then
+       bind for rendering through rcMakeCurrent.
+       The function returns a handle to the created window surface.
+
+void rcDestroyWindowSurface(uint32_t windowSurface);
+       This function destoys a window surface.
+
+uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat);
+       This function creates a colorBuffer object on the host which can be then
+       be specified as a render target for a window surface through 
+       rcSetWindowColorBuffer or to be displayed on the framebuffer window
+       through rcFBPost.
+       The function returns a handle to the colorBuffer object, with an initial
+       reference count of 1.
+
+void rcOpenColorBuffer(uint32_t colorbuffer);
+       Adds an additional reference to the colorbuffer, typically from a
+       different Android process than the one which created it.
+
+void rcCloseColorBuffer(uint32_t colorbuffer);
+       Removes a reference to the colorbuffer. When the reference count drops
+       to zero the colorbuffer is automatically destroyed.
+
+void rcFlushWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer);
+       This flushes the current window color buffer
+
+void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer);
+       This set the target color buffer for a windowSurface, when set the
+       previous target colorBuffer gets updated before switching to the new
+       colorBuffer.
+
+EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf);
+       Binds a windowSurface(s) and current rendering context for the 
+       calling thread.
+
+void rcFBPost(uint32_t colorBuffer);
+       This function causes the content of the colorBuffer object to be
+       displayed on the host framebuffer window. The function returns
+       immediatly, the buffer will be displayed at the next swap interval.
+
+void rcFBSetSwapInterval(EGLint interval);
+       Sets the swap interval for the host framebuffer window.
+
+void rcBindTexture(uint32_t colorBuffer);
+       This function instruct the host to bind the content of the specified
+       colorBuffer to the current binded texture object of the calling thread.
+       This function should be used to implement eglBindTexImage.
+
+EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead);
+       This function returns only after all rendering requests for the specified
+       colorBuffer rendering target has been processed and after all 'postCount'
+       posts for the buffer requested previously through rcFBPost has been
+       processed.
+       if 'forRead' is not-zero, the function returns positive value in case
+       there was rendering done to the buffer since the last CacheFlush request
+       with non-zero 'forRead' value, otherwise the function returns zero or
+       negative value on failure.
+
+void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, 
+                       GLint width, GLint height, GLenum format, 
+                       GLenum type, void* pixels);
+       This function queries the host for the pixel content of a colorBuffer's
+       subregion. It act the same as OpenGL glReadPixels however pixels
+       are always packed with alignment of 1.
+
+void rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, 
+                         GLint width, GLint height, GLenum format, 
+                         GLenum type, void* pixels);
+       Updates the content of a subregion of a colorBuffer object.
+       pixels are always unpacked with alignment of 1.
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl.attrib b/tools/emulator/opengl/system/renderControl_enc/renderControl.attrib
new file mode 100644
index 0000000..8b9972f
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl.attrib
@@ -0,0 +1,41 @@
+GLOBAL
+	base_opcode 10000
+	encoder_headers <stdint.h> <EGL/egl.h> "glUtils.h"
+
+rcGetEGLVersion
+    dir major out
+    len major sizeof(EGLint)
+    dir minor out
+    len minor sizeof(EGLint)
+
+rcQueryEGLString
+    dir buffer out
+    len buffer bufferSize
+
+rcGetGLString
+    dir buffer out
+    len buffer bufferSize
+
+rcGetNumConfigs
+    dir numAttribs out
+    len numAttribs sizeof(uint32_t)
+
+rcGetConfigs
+    dir buffer out
+    len buffer bufSize
+
+rcChooseConfig
+    dir attribs in
+    len attribs attribs_size
+    dir configs out
+    var_flag configs nullAllowed
+    len configs configs_size*sizeof(uint32_t)
+
+rcReadColorBuffer
+    dir pixels out
+    len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height)
+
+rcUpdateColorBuffer
+    dir pixels in
+    len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height)
+    var_flag pixels isLarge
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl.in b/tools/emulator/opengl/system/renderControl_enc/renderControl.in
new file mode 100644
index 0000000..8281fd9
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl.in
@@ -0,0 +1,25 @@
+GL_ENRTY(GLint, rcGetRendererVersion)
+GL_ENTRY(EGLint, rcGetEGLVersion, EGLint *major, EGLint *minor)
+GL_ENTRY(EGLint, rcQueryEGLString, EGLenum name, void *buffer, EGLint bufferSize)
+GL_ENTRY(EGLint, rcGetGLString, EGLenum name, void *buffer, EGLint bufferSize)
+GL_ENTRY(EGLint, rcGetNumConfigs, uint32_t *numAttribs)
+GL_ENTRY(EGLint, rcGetConfigs, uint32_t bufSize, GLuint *buffer)
+GL_ENTRY(EGLint, rcChooseConfig, EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size)
+GL_ENTRY(EGLint, rcGetFBParam, EGLint param)
+GL_ENTRY(uint32_t, rcCreateContext, uint32_t config, uint32_t share, uint32_t glVersion)
+GL_ENTRY(void, rcDestroyContext, uint32_t context)
+GL_ENTRY(uint32_t, rcCreateWindowSurface, uint32_t config, uint32_t width, uint32_t height)
+GL_ENTRY(void, rcDestroyWindowSurface, uint32_t windowSurface)
+GL_ENTRY(uint32_t, rcCreateColorBuffer, uint32_t width, uint32_t height, GLenum internalFormat)
+GL_ENTRY(void, rcOpenColorBuffer, uint32_t colorbuffer)
+GL_ENTRY(void, rcCloseColorBuffer, uint32_t colorbuffer)
+GL_ENTRY(void, rcSetWindowColorBuffer, uint32_t windowSurface, uint32_t colorBuffer)
+GL_ENTRY(int, rcFlushWindowColorBuffer, uint32_t windowSurface)
+GL_ENTRY(EGLint, rcMakeCurrent, uint32_t context, uint32_t drawSurf, uint32_t readSurf)
+GL_ENTRY(void, rcFBPost, uint32_t colorBuffer)
+GL_ENTRY(void, rcFBSetSwapInterval, EGLint interval)
+GL_ENTRY(void, rcBindTexture, uint32_t colorBuffer)
+GL_ENTRY(void, rcBindRenderbuffer, uint32_t colorBuffer)
+GL_ENTRY(EGLint, rcColorBufferCacheFlush, uint32_t colorbuffer, EGLint postCount,int forRead)
+GL_ENTRY(void, rcReadColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
+GL_ENTRY(int, rcUpdateColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl.types b/tools/emulator/opengl/system/renderControl_enc/renderControl.types
new file mode 100644
index 0000000..a7d96ab
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl.types
@@ -0,0 +1,11 @@
+uint32_t 32 0x%08x false
+EGLint 32 0x%08x false
+GLint 32 0x%08x false
+GLuint 32 0x%08x false
+GLenum 32 0x%08x false
+EGLenum 32 0x%08x false
+uint32_t* 32 0x%08x true
+EGLint* 32 0x%08x true
+GLint* 32 0x%08x true
+GLuint* 32 0x%08x true
+void* 32 0x%08x true
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_client_context.cpp b/tools/emulator/opengl/system/renderControl_enc/renderControl_client_context.cpp
new file mode 100644
index 0000000..9488248
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_client_context.cpp
@@ -0,0 +1,42 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "renderControl_client_context.h"
+
+
+#include <stdio.h>
+
+int renderControl_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+	void *ptr;
+
+	ptr = getProc("rcGetRendererVersion", userData); set_rcGetRendererVersion((rcGetRendererVersion_client_proc_t)ptr);
+	ptr = getProc("rcGetEGLVersion", userData); set_rcGetEGLVersion((rcGetEGLVersion_client_proc_t)ptr);
+	ptr = getProc("rcQueryEGLString", userData); set_rcQueryEGLString((rcQueryEGLString_client_proc_t)ptr);
+	ptr = getProc("rcGetGLString", userData); set_rcGetGLString((rcGetGLString_client_proc_t)ptr);
+	ptr = getProc("rcGetNumConfigs", userData); set_rcGetNumConfigs((rcGetNumConfigs_client_proc_t)ptr);
+	ptr = getProc("rcGetConfigs", userData); set_rcGetConfigs((rcGetConfigs_client_proc_t)ptr);
+	ptr = getProc("rcChooseConfig", userData); set_rcChooseConfig((rcChooseConfig_client_proc_t)ptr);
+	ptr = getProc("rcGetFBParam", userData); set_rcGetFBParam((rcGetFBParam_client_proc_t)ptr);
+	ptr = getProc("rcCreateContext", userData); set_rcCreateContext((rcCreateContext_client_proc_t)ptr);
+	ptr = getProc("rcDestroyContext", userData); set_rcDestroyContext((rcDestroyContext_client_proc_t)ptr);
+	ptr = getProc("rcCreateWindowSurface", userData); set_rcCreateWindowSurface((rcCreateWindowSurface_client_proc_t)ptr);
+	ptr = getProc("rcDestroyWindowSurface", userData); set_rcDestroyWindowSurface((rcDestroyWindowSurface_client_proc_t)ptr);
+	ptr = getProc("rcCreateColorBuffer", userData); set_rcCreateColorBuffer((rcCreateColorBuffer_client_proc_t)ptr);
+	ptr = getProc("rcOpenColorBuffer", userData); set_rcOpenColorBuffer((rcOpenColorBuffer_client_proc_t)ptr);
+	ptr = getProc("rcCloseColorBuffer", userData); set_rcCloseColorBuffer((rcCloseColorBuffer_client_proc_t)ptr);
+	ptr = getProc("rcSetWindowColorBuffer", userData); set_rcSetWindowColorBuffer((rcSetWindowColorBuffer_client_proc_t)ptr);
+	ptr = getProc("rcFlushWindowColorBuffer", userData); set_rcFlushWindowColorBuffer((rcFlushWindowColorBuffer_client_proc_t)ptr);
+	ptr = getProc("rcMakeCurrent", userData); set_rcMakeCurrent((rcMakeCurrent_client_proc_t)ptr);
+	ptr = getProc("rcFBPost", userData); set_rcFBPost((rcFBPost_client_proc_t)ptr);
+	ptr = getProc("rcFBSetSwapInterval", userData); set_rcFBSetSwapInterval((rcFBSetSwapInterval_client_proc_t)ptr);
+	ptr = getProc("rcBindTexture", userData); set_rcBindTexture((rcBindTexture_client_proc_t)ptr);
+	ptr = getProc("rcBindRenderbuffer", userData); set_rcBindRenderbuffer((rcBindRenderbuffer_client_proc_t)ptr);
+	ptr = getProc("rcColorBufferCacheFlush", userData); set_rcColorBufferCacheFlush((rcColorBufferCacheFlush_client_proc_t)ptr);
+	ptr = getProc("rcReadColorBuffer", userData); set_rcReadColorBuffer((rcReadColorBuffer_client_proc_t)ptr);
+	ptr = getProc("rcUpdateColorBuffer", userData); set_rcUpdateColorBuffer((rcUpdateColorBuffer_client_proc_t)ptr);
+	return 0;
+}
+
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_client_context.h b/tools/emulator/opengl/system/renderControl_enc/renderControl_client_context.h
new file mode 100644
index 0000000..ed2b1fb
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_client_context.h
@@ -0,0 +1,71 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __renderControl_client_context_t_h
+#define __renderControl_client_context_t_h
+
+#include "renderControl_client_proc.h"
+
+
+struct renderControl_client_context_t {
+
+	rcGetRendererVersion_client_proc_t rcGetRendererVersion;
+	rcGetEGLVersion_client_proc_t rcGetEGLVersion;
+	rcQueryEGLString_client_proc_t rcQueryEGLString;
+	rcGetGLString_client_proc_t rcGetGLString;
+	rcGetNumConfigs_client_proc_t rcGetNumConfigs;
+	rcGetConfigs_client_proc_t rcGetConfigs;
+	rcChooseConfig_client_proc_t rcChooseConfig;
+	rcGetFBParam_client_proc_t rcGetFBParam;
+	rcCreateContext_client_proc_t rcCreateContext;
+	rcDestroyContext_client_proc_t rcDestroyContext;
+	rcCreateWindowSurface_client_proc_t rcCreateWindowSurface;
+	rcDestroyWindowSurface_client_proc_t rcDestroyWindowSurface;
+	rcCreateColorBuffer_client_proc_t rcCreateColorBuffer;
+	rcOpenColorBuffer_client_proc_t rcOpenColorBuffer;
+	rcCloseColorBuffer_client_proc_t rcCloseColorBuffer;
+	rcSetWindowColorBuffer_client_proc_t rcSetWindowColorBuffer;
+	rcFlushWindowColorBuffer_client_proc_t rcFlushWindowColorBuffer;
+	rcMakeCurrent_client_proc_t rcMakeCurrent;
+	rcFBPost_client_proc_t rcFBPost;
+	rcFBSetSwapInterval_client_proc_t rcFBSetSwapInterval;
+	rcBindTexture_client_proc_t rcBindTexture;
+	rcBindRenderbuffer_client_proc_t rcBindRenderbuffer;
+	rcColorBufferCacheFlush_client_proc_t rcColorBufferCacheFlush;
+	rcReadColorBuffer_client_proc_t rcReadColorBuffer;
+	rcUpdateColorBuffer_client_proc_t rcUpdateColorBuffer;
+	//Accessors 
+	virtual rcGetRendererVersion_client_proc_t set_rcGetRendererVersion(rcGetRendererVersion_client_proc_t f) { rcGetRendererVersion_client_proc_t retval = rcGetRendererVersion; rcGetRendererVersion = f; return retval;}
+	virtual rcGetEGLVersion_client_proc_t set_rcGetEGLVersion(rcGetEGLVersion_client_proc_t f) { rcGetEGLVersion_client_proc_t retval = rcGetEGLVersion; rcGetEGLVersion = f; return retval;}
+	virtual rcQueryEGLString_client_proc_t set_rcQueryEGLString(rcQueryEGLString_client_proc_t f) { rcQueryEGLString_client_proc_t retval = rcQueryEGLString; rcQueryEGLString = f; return retval;}
+	virtual rcGetGLString_client_proc_t set_rcGetGLString(rcGetGLString_client_proc_t f) { rcGetGLString_client_proc_t retval = rcGetGLString; rcGetGLString = f; return retval;}
+	virtual rcGetNumConfigs_client_proc_t set_rcGetNumConfigs(rcGetNumConfigs_client_proc_t f) { rcGetNumConfigs_client_proc_t retval = rcGetNumConfigs; rcGetNumConfigs = f; return retval;}
+	virtual rcGetConfigs_client_proc_t set_rcGetConfigs(rcGetConfigs_client_proc_t f) { rcGetConfigs_client_proc_t retval = rcGetConfigs; rcGetConfigs = f; return retval;}
+	virtual rcChooseConfig_client_proc_t set_rcChooseConfig(rcChooseConfig_client_proc_t f) { rcChooseConfig_client_proc_t retval = rcChooseConfig; rcChooseConfig = f; return retval;}
+	virtual rcGetFBParam_client_proc_t set_rcGetFBParam(rcGetFBParam_client_proc_t f) { rcGetFBParam_client_proc_t retval = rcGetFBParam; rcGetFBParam = f; return retval;}
+	virtual rcCreateContext_client_proc_t set_rcCreateContext(rcCreateContext_client_proc_t f) { rcCreateContext_client_proc_t retval = rcCreateContext; rcCreateContext = f; return retval;}
+	virtual rcDestroyContext_client_proc_t set_rcDestroyContext(rcDestroyContext_client_proc_t f) { rcDestroyContext_client_proc_t retval = rcDestroyContext; rcDestroyContext = f; return retval;}
+	virtual rcCreateWindowSurface_client_proc_t set_rcCreateWindowSurface(rcCreateWindowSurface_client_proc_t f) { rcCreateWindowSurface_client_proc_t retval = rcCreateWindowSurface; rcCreateWindowSurface = f; return retval;}
+	virtual rcDestroyWindowSurface_client_proc_t set_rcDestroyWindowSurface(rcDestroyWindowSurface_client_proc_t f) { rcDestroyWindowSurface_client_proc_t retval = rcDestroyWindowSurface; rcDestroyWindowSurface = f; return retval;}
+	virtual rcCreateColorBuffer_client_proc_t set_rcCreateColorBuffer(rcCreateColorBuffer_client_proc_t f) { rcCreateColorBuffer_client_proc_t retval = rcCreateColorBuffer; rcCreateColorBuffer = f; return retval;}
+	virtual rcOpenColorBuffer_client_proc_t set_rcOpenColorBuffer(rcOpenColorBuffer_client_proc_t f) { rcOpenColorBuffer_client_proc_t retval = rcOpenColorBuffer; rcOpenColorBuffer = f; return retval;}
+	virtual rcCloseColorBuffer_client_proc_t set_rcCloseColorBuffer(rcCloseColorBuffer_client_proc_t f) { rcCloseColorBuffer_client_proc_t retval = rcCloseColorBuffer; rcCloseColorBuffer = f; return retval;}
+	virtual rcSetWindowColorBuffer_client_proc_t set_rcSetWindowColorBuffer(rcSetWindowColorBuffer_client_proc_t f) { rcSetWindowColorBuffer_client_proc_t retval = rcSetWindowColorBuffer; rcSetWindowColorBuffer = f; return retval;}
+	virtual rcFlushWindowColorBuffer_client_proc_t set_rcFlushWindowColorBuffer(rcFlushWindowColorBuffer_client_proc_t f) { rcFlushWindowColorBuffer_client_proc_t retval = rcFlushWindowColorBuffer; rcFlushWindowColorBuffer = f; return retval;}
+	virtual rcMakeCurrent_client_proc_t set_rcMakeCurrent(rcMakeCurrent_client_proc_t f) { rcMakeCurrent_client_proc_t retval = rcMakeCurrent; rcMakeCurrent = f; return retval;}
+	virtual rcFBPost_client_proc_t set_rcFBPost(rcFBPost_client_proc_t f) { rcFBPost_client_proc_t retval = rcFBPost; rcFBPost = f; return retval;}
+	virtual rcFBSetSwapInterval_client_proc_t set_rcFBSetSwapInterval(rcFBSetSwapInterval_client_proc_t f) { rcFBSetSwapInterval_client_proc_t retval = rcFBSetSwapInterval; rcFBSetSwapInterval = f; return retval;}
+	virtual rcBindTexture_client_proc_t set_rcBindTexture(rcBindTexture_client_proc_t f) { rcBindTexture_client_proc_t retval = rcBindTexture; rcBindTexture = f; return retval;}
+	virtual rcBindRenderbuffer_client_proc_t set_rcBindRenderbuffer(rcBindRenderbuffer_client_proc_t f) { rcBindRenderbuffer_client_proc_t retval = rcBindRenderbuffer; rcBindRenderbuffer = f; return retval;}
+	virtual rcColorBufferCacheFlush_client_proc_t set_rcColorBufferCacheFlush(rcColorBufferCacheFlush_client_proc_t f) { rcColorBufferCacheFlush_client_proc_t retval = rcColorBufferCacheFlush; rcColorBufferCacheFlush = f; return retval;}
+	virtual rcReadColorBuffer_client_proc_t set_rcReadColorBuffer(rcReadColorBuffer_client_proc_t f) { rcReadColorBuffer_client_proc_t retval = rcReadColorBuffer; rcReadColorBuffer = f; return retval;}
+	virtual rcUpdateColorBuffer_client_proc_t set_rcUpdateColorBuffer(rcUpdateColorBuffer_client_proc_t f) { rcUpdateColorBuffer_client_proc_t retval = rcUpdateColorBuffer; rcUpdateColorBuffer = f; return retval;}
+	 virtual ~renderControl_client_context_t() {}
+
+	typedef renderControl_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
+	static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
+	int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+	virtual void setError(unsigned int  error){};
+	virtual unsigned int getError(){ return 0; };
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_client_proc.h b/tools/emulator/opengl/system/renderControl_enc/renderControl_client_proc.h
new file mode 100644
index 0000000..3e00290
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_client_proc.h
@@ -0,0 +1,39 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __renderControl_client_proc_t_h
+#define __renderControl_client_proc_t_h
+
+
+
+#include "renderControl_types.h"
+#ifndef renderControl_APIENTRY
+#define renderControl_APIENTRY 
+#endif
+typedef GLint (renderControl_APIENTRY *rcGetRendererVersion_client_proc_t) (void * ctx);
+typedef EGLint (renderControl_APIENTRY *rcGetEGLVersion_client_proc_t) (void * ctx, EGLint*, EGLint*);
+typedef EGLint (renderControl_APIENTRY *rcQueryEGLString_client_proc_t) (void * ctx, EGLenum, void*, EGLint);
+typedef EGLint (renderControl_APIENTRY *rcGetGLString_client_proc_t) (void * ctx, EGLenum, void*, EGLint);
+typedef EGLint (renderControl_APIENTRY *rcGetNumConfigs_client_proc_t) (void * ctx, uint32_t*);
+typedef EGLint (renderControl_APIENTRY *rcGetConfigs_client_proc_t) (void * ctx, uint32_t, GLuint*);
+typedef EGLint (renderControl_APIENTRY *rcChooseConfig_client_proc_t) (void * ctx, EGLint*, uint32_t, uint32_t*, uint32_t);
+typedef EGLint (renderControl_APIENTRY *rcGetFBParam_client_proc_t) (void * ctx, EGLint);
+typedef uint32_t (renderControl_APIENTRY *rcCreateContext_client_proc_t) (void * ctx, uint32_t, uint32_t, uint32_t);
+typedef void (renderControl_APIENTRY *rcDestroyContext_client_proc_t) (void * ctx, uint32_t);
+typedef uint32_t (renderControl_APIENTRY *rcCreateWindowSurface_client_proc_t) (void * ctx, uint32_t, uint32_t, uint32_t);
+typedef void (renderControl_APIENTRY *rcDestroyWindowSurface_client_proc_t) (void * ctx, uint32_t);
+typedef uint32_t (renderControl_APIENTRY *rcCreateColorBuffer_client_proc_t) (void * ctx, uint32_t, uint32_t, GLenum);
+typedef void (renderControl_APIENTRY *rcOpenColorBuffer_client_proc_t) (void * ctx, uint32_t);
+typedef void (renderControl_APIENTRY *rcCloseColorBuffer_client_proc_t) (void * ctx, uint32_t);
+typedef void (renderControl_APIENTRY *rcSetWindowColorBuffer_client_proc_t) (void * ctx, uint32_t, uint32_t);
+typedef int (renderControl_APIENTRY *rcFlushWindowColorBuffer_client_proc_t) (void * ctx, uint32_t);
+typedef EGLint (renderControl_APIENTRY *rcMakeCurrent_client_proc_t) (void * ctx, uint32_t, uint32_t, uint32_t);
+typedef void (renderControl_APIENTRY *rcFBPost_client_proc_t) (void * ctx, uint32_t);
+typedef void (renderControl_APIENTRY *rcFBSetSwapInterval_client_proc_t) (void * ctx, EGLint);
+typedef void (renderControl_APIENTRY *rcBindTexture_client_proc_t) (void * ctx, uint32_t);
+typedef void (renderControl_APIENTRY *rcBindRenderbuffer_client_proc_t) (void * ctx, uint32_t);
+typedef EGLint (renderControl_APIENTRY *rcColorBufferCacheFlush_client_proc_t) (void * ctx, uint32_t, EGLint, int);
+typedef void (renderControl_APIENTRY *rcReadColorBuffer_client_proc_t) (void * ctx, uint32_t, GLint, GLint, GLint, GLint, GLenum, GLenum, void*);
+typedef int (renderControl_APIENTRY *rcUpdateColorBuffer_client_proc_t) (void * ctx, uint32_t, GLint, GLint, GLint, GLint, GLenum, GLenum, void*);
+
+
+#endif
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_enc.cpp b/tools/emulator/opengl/system/renderControl_enc/renderControl_enc.cpp
new file mode 100644
index 0000000..94e256a
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_enc.cpp
@@ -0,0 +1,536 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "renderControl_opcodes.h"
+
+#include "renderControl_enc.h"
+
+
+#include <stdio.h>
+static void enc_unsupported()
+{
+	ALOGE("Function is unsupported\n");
+}
+
+GLint rcGetRendererVersion_enc(void *self )
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcGetRendererVersion;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+
+	GLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+EGLint rcGetEGLVersion_enc(void *self , EGLint* major, EGLint* minor)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_major =  sizeof(EGLint);
+	const unsigned int __size_minor =  sizeof(EGLint);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_major + __size_minor + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcGetEGLVersion;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_major; ptr += 4;
+	*(unsigned int *)(ptr) = __size_minor; ptr += 4;
+	stream->readback(major, __size_major);
+	stream->readback(minor, __size_minor);
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+EGLint rcQueryEGLString_enc(void *self , EGLenum name, void* buffer, EGLint bufferSize)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_buffer =  bufferSize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_buffer + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcQueryEGLString;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &name, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_buffer; ptr += 4;
+		memcpy(ptr, &bufferSize, 4); ptr += 4;
+	stream->readback(buffer, __size_buffer);
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+EGLint rcGetGLString_enc(void *self , EGLenum name, void* buffer, EGLint bufferSize)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_buffer =  bufferSize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_buffer + 4 + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcGetGLString;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &name, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_buffer; ptr += 4;
+		memcpy(ptr, &bufferSize, 4); ptr += 4;
+	stream->readback(buffer, __size_buffer);
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+EGLint rcGetNumConfigs_enc(void *self , uint32_t* numAttribs)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_numAttribs =  sizeof(uint32_t);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_numAttribs + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcGetNumConfigs;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_numAttribs; ptr += 4;
+	stream->readback(numAttribs, __size_numAttribs);
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+EGLint rcGetConfigs_enc(void *self , uint32_t bufSize, GLuint* buffer)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_buffer =  bufSize;
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + __size_buffer + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcGetConfigs;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &bufSize, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_buffer; ptr += 4;
+	stream->readback(buffer, __size_buffer);
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+EGLint rcChooseConfig_enc(void *self , EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_attribs =  attribs_size;
+	const unsigned int __size_configs = ((configs != NULL) ?  configs_size*sizeof(uint32_t) : 0);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + __size_attribs + 4 + __size_configs + 4 + 2*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcChooseConfig;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+	*(unsigned int *)(ptr) = __size_attribs; ptr += 4;
+	memcpy(ptr, attribs, __size_attribs);ptr += __size_attribs;
+		memcpy(ptr, &attribs_size, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_configs; ptr += 4;
+		memcpy(ptr, &configs_size, 4); ptr += 4;
+	if (configs != NULL) stream->readback(configs, __size_configs);
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+EGLint rcGetFBParam_enc(void *self , EGLint param)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcGetFBParam;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &param, 4); ptr += 4;
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+uint32_t rcCreateContext_enc(void *self , uint32_t config, uint32_t share, uint32_t glVersion)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcCreateContext;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &config, 4); ptr += 4;
+		memcpy(ptr, &share, 4); ptr += 4;
+		memcpy(ptr, &glVersion, 4); ptr += 4;
+
+	uint32_t retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void rcDestroyContext_enc(void *self , uint32_t context)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcDestroyContext;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &context, 4); ptr += 4;
+}
+
+uint32_t rcCreateWindowSurface_enc(void *self , uint32_t config, uint32_t width, uint32_t height)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcCreateWindowSurface;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &config, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+
+	uint32_t retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void rcDestroyWindowSurface_enc(void *self , uint32_t windowSurface)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcDestroyWindowSurface;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &windowSurface, 4); ptr += 4;
+}
+
+uint32_t rcCreateColorBuffer_enc(void *self , uint32_t width, uint32_t height, GLenum internalFormat)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcCreateColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &internalFormat, 4); ptr += 4;
+
+	uint32_t retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void rcOpenColorBuffer_enc(void *self , uint32_t colorbuffer)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcOpenColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &colorbuffer, 4); ptr += 4;
+}
+
+void rcCloseColorBuffer_enc(void *self , uint32_t colorbuffer)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcCloseColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &colorbuffer, 4); ptr += 4;
+}
+
+void rcSetWindowColorBuffer_enc(void *self , uint32_t windowSurface, uint32_t colorBuffer)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcSetWindowColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &windowSurface, 4); ptr += 4;
+		memcpy(ptr, &colorBuffer, 4); ptr += 4;
+}
+
+int rcFlushWindowColorBuffer_enc(void *self , uint32_t windowSurface)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcFlushWindowColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &windowSurface, 4); ptr += 4;
+
+	int retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+EGLint rcMakeCurrent_enc(void *self , uint32_t context, uint32_t drawSurf, uint32_t readSurf)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcMakeCurrent;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &context, 4); ptr += 4;
+		memcpy(ptr, &drawSurf, 4); ptr += 4;
+		memcpy(ptr, &readSurf, 4); ptr += 4;
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void rcFBPost_enc(void *self , uint32_t colorBuffer)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcFBPost;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &colorBuffer, 4); ptr += 4;
+}
+
+void rcFBSetSwapInterval_enc(void *self , EGLint interval)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcFBSetSwapInterval;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &interval, 4); ptr += 4;
+}
+
+void rcBindTexture_enc(void *self , uint32_t colorBuffer)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcBindTexture;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &colorBuffer, 4); ptr += 4;
+}
+
+void rcBindRenderbuffer_enc(void *self , uint32_t colorBuffer)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcBindRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &colorBuffer, 4); ptr += 4;
+}
+
+EGLint rcColorBufferCacheFlush_enc(void *self , uint32_t colorbuffer, EGLint postCount, int forRead)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcColorBufferCacheFlush;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &colorbuffer, 4); ptr += 4;
+		memcpy(ptr, &postCount, 4); ptr += 4;
+		memcpy(ptr, &forRead, 4); ptr += 4;
+
+	EGLint retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+void rcReadColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels =  (((glUtilsPixelBitSize(format, type) * width) >> 3) * height);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(packetSize);
+	int tmp = OP_rcReadColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &colorbuffer, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	*(unsigned int *)(ptr) = __size_pixels; ptr += 4;
+	stream->readback(pixels, __size_pixels);
+}
+
+int rcUpdateColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels)
+{
+
+	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+	IOStream *stream = ctx->m_stream;
+
+	const unsigned int __size_pixels =  (((glUtilsPixelBitSize(format, type) * width) >> 3) * height);
+	 unsigned char *ptr;
+	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
+	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
+	int tmp = OP_rcUpdateColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+	memcpy(ptr, &packetSize, 4);  ptr += 4;
+
+		memcpy(ptr, &colorbuffer, 4); ptr += 4;
+		memcpy(ptr, &x, 4); ptr += 4;
+		memcpy(ptr, &y, 4); ptr += 4;
+		memcpy(ptr, &width, 4); ptr += 4;
+		memcpy(ptr, &height, 4); ptr += 4;
+		memcpy(ptr, &format, 4); ptr += 4;
+		memcpy(ptr, &type, 4); ptr += 4;
+	stream->flush();
+	stream->writeFully(&__size_pixels,4);
+	stream->writeFully(pixels, __size_pixels);
+
+	int retval;
+	stream->readback(&retval, 4);
+	return retval;
+}
+
+renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *stream)
+{
+	m_stream = stream;
+
+	set_rcGetRendererVersion(rcGetRendererVersion_enc);
+	set_rcGetEGLVersion(rcGetEGLVersion_enc);
+	set_rcQueryEGLString(rcQueryEGLString_enc);
+	set_rcGetGLString(rcGetGLString_enc);
+	set_rcGetNumConfigs(rcGetNumConfigs_enc);
+	set_rcGetConfigs(rcGetConfigs_enc);
+	set_rcChooseConfig(rcChooseConfig_enc);
+	set_rcGetFBParam(rcGetFBParam_enc);
+	set_rcCreateContext(rcCreateContext_enc);
+	set_rcDestroyContext(rcDestroyContext_enc);
+	set_rcCreateWindowSurface(rcCreateWindowSurface_enc);
+	set_rcDestroyWindowSurface(rcDestroyWindowSurface_enc);
+	set_rcCreateColorBuffer(rcCreateColorBuffer_enc);
+	set_rcOpenColorBuffer(rcOpenColorBuffer_enc);
+	set_rcCloseColorBuffer(rcCloseColorBuffer_enc);
+	set_rcSetWindowColorBuffer(rcSetWindowColorBuffer_enc);
+	set_rcFlushWindowColorBuffer(rcFlushWindowColorBuffer_enc);
+	set_rcMakeCurrent(rcMakeCurrent_enc);
+	set_rcFBPost(rcFBPost_enc);
+	set_rcFBSetSwapInterval(rcFBSetSwapInterval_enc);
+	set_rcBindTexture(rcBindTexture_enc);
+	set_rcBindRenderbuffer(rcBindRenderbuffer_enc);
+	set_rcColorBufferCacheFlush(rcColorBufferCacheFlush_enc);
+	set_rcReadColorBuffer(rcReadColorBuffer_enc);
+	set_rcUpdateColorBuffer(rcUpdateColorBuffer_enc);
+}
+
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_enc.h b/tools/emulator/opengl/system/renderControl_enc/renderControl_enc.h
new file mode 100644
index 0000000..712eeb9
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_enc.h
@@ -0,0 +1,51 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+#ifndef GUARD_renderControl_encoder_context_t
+#define GUARD_renderControl_encoder_context_t
+
+#include "IOStream.h"
+#include "renderControl_client_context.h"
+
+
+#include <stdint.h>
+#include <EGL/egl.h>
+#include "glUtils.h"
+
+struct renderControl_encoder_context_t : public renderControl_client_context_t {
+
+	IOStream *m_stream;
+
+	renderControl_encoder_context_t(IOStream *stream);
+
+
+};
+
+extern "C" {
+	GLint rcGetRendererVersion_enc(void *self );
+	EGLint rcGetEGLVersion_enc(void *self , EGLint* major, EGLint* minor);
+	EGLint rcQueryEGLString_enc(void *self , EGLenum name, void* buffer, EGLint bufferSize);
+	EGLint rcGetGLString_enc(void *self , EGLenum name, void* buffer, EGLint bufferSize);
+	EGLint rcGetNumConfigs_enc(void *self , uint32_t* numAttribs);
+	EGLint rcGetConfigs_enc(void *self , uint32_t bufSize, GLuint* buffer);
+	EGLint rcChooseConfig_enc(void *self , EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size);
+	EGLint rcGetFBParam_enc(void *self , EGLint param);
+	uint32_t rcCreateContext_enc(void *self , uint32_t config, uint32_t share, uint32_t glVersion);
+	void rcDestroyContext_enc(void *self , uint32_t context);
+	uint32_t rcCreateWindowSurface_enc(void *self , uint32_t config, uint32_t width, uint32_t height);
+	void rcDestroyWindowSurface_enc(void *self , uint32_t windowSurface);
+	uint32_t rcCreateColorBuffer_enc(void *self , uint32_t width, uint32_t height, GLenum internalFormat);
+	void rcOpenColorBuffer_enc(void *self , uint32_t colorbuffer);
+	void rcCloseColorBuffer_enc(void *self , uint32_t colorbuffer);
+	void rcSetWindowColorBuffer_enc(void *self , uint32_t windowSurface, uint32_t colorBuffer);
+	int rcFlushWindowColorBuffer_enc(void *self , uint32_t windowSurface);
+	EGLint rcMakeCurrent_enc(void *self , uint32_t context, uint32_t drawSurf, uint32_t readSurf);
+	void rcFBPost_enc(void *self , uint32_t colorBuffer);
+	void rcFBSetSwapInterval_enc(void *self , EGLint interval);
+	void rcBindTexture_enc(void *self , uint32_t colorBuffer);
+	void rcBindRenderbuffer_enc(void *self , uint32_t colorBuffer);
+	EGLint rcColorBufferCacheFlush_enc(void *self , uint32_t colorbuffer, EGLint postCount, int forRead);
+	void rcReadColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels);
+	int rcUpdateColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels);
+};
+#endif
\ No newline at end of file
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_entry.cpp b/tools/emulator/opengl/system/renderControl_enc/renderControl_entry.cpp
new file mode 100644
index 0000000..9a0bba9
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_entry.cpp
@@ -0,0 +1,192 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#include <stdio.h>
+#include <stdlib.h>
+#include "renderControl_client_context.h"
+
+#ifndef GL_TRUE
+extern "C" {
+	GLint rcGetRendererVersion();
+	EGLint rcGetEGLVersion(EGLint* major, EGLint* minor);
+	EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize);
+	EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize);
+	EGLint rcGetNumConfigs(uint32_t* numAttribs);
+	EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer);
+	EGLint rcChooseConfig(EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size);
+	EGLint rcGetFBParam(EGLint param);
+	uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion);
+	void rcDestroyContext(uint32_t context);
+	uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height);
+	void rcDestroyWindowSurface(uint32_t windowSurface);
+	uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat);
+	void rcOpenColorBuffer(uint32_t colorbuffer);
+	void rcCloseColorBuffer(uint32_t colorbuffer);
+	void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer);
+	int rcFlushWindowColorBuffer(uint32_t windowSurface);
+	EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf);
+	void rcFBPost(uint32_t colorBuffer);
+	void rcFBSetSwapInterval(EGLint interval);
+	void rcBindTexture(uint32_t colorBuffer);
+	void rcBindRenderbuffer(uint32_t colorBuffer);
+	EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead);
+	void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels);
+	int rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels);
+};
+
+#endif
+#ifndef GET_CONTEXT
+static renderControl_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
+void renderControl_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
+#define GET_CONTEXT renderControl_client_context_t * ctx = getCurrentContext() 
+#endif
+
+GLint rcGetRendererVersion()
+{
+	GET_CONTEXT; 
+	 return ctx->rcGetRendererVersion(ctx);
+}
+
+EGLint rcGetEGLVersion(EGLint* major, EGLint* minor)
+{
+	GET_CONTEXT; 
+	 return ctx->rcGetEGLVersion(ctx, major, minor);
+}
+
+EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize)
+{
+	GET_CONTEXT; 
+	 return ctx->rcQueryEGLString(ctx, name, buffer, bufferSize);
+}
+
+EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize)
+{
+	GET_CONTEXT; 
+	 return ctx->rcGetGLString(ctx, name, buffer, bufferSize);
+}
+
+EGLint rcGetNumConfigs(uint32_t* numAttribs)
+{
+	GET_CONTEXT; 
+	 return ctx->rcGetNumConfigs(ctx, numAttribs);
+}
+
+EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer)
+{
+	GET_CONTEXT; 
+	 return ctx->rcGetConfigs(ctx, bufSize, buffer);
+}
+
+EGLint rcChooseConfig(EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size)
+{
+	GET_CONTEXT; 
+	 return ctx->rcChooseConfig(ctx, attribs, attribs_size, configs, configs_size);
+}
+
+EGLint rcGetFBParam(EGLint param)
+{
+	GET_CONTEXT; 
+	 return ctx->rcGetFBParam(ctx, param);
+}
+
+uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion)
+{
+	GET_CONTEXT; 
+	 return ctx->rcCreateContext(ctx, config, share, glVersion);
+}
+
+void rcDestroyContext(uint32_t context)
+{
+	GET_CONTEXT; 
+	 ctx->rcDestroyContext(ctx, context);
+}
+
+uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height)
+{
+	GET_CONTEXT; 
+	 return ctx->rcCreateWindowSurface(ctx, config, width, height);
+}
+
+void rcDestroyWindowSurface(uint32_t windowSurface)
+{
+	GET_CONTEXT; 
+	 ctx->rcDestroyWindowSurface(ctx, windowSurface);
+}
+
+uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat)
+{
+	GET_CONTEXT; 
+	 return ctx->rcCreateColorBuffer(ctx, width, height, internalFormat);
+}
+
+void rcOpenColorBuffer(uint32_t colorbuffer)
+{
+	GET_CONTEXT; 
+	 ctx->rcOpenColorBuffer(ctx, colorbuffer);
+}
+
+void rcCloseColorBuffer(uint32_t colorbuffer)
+{
+	GET_CONTEXT; 
+	 ctx->rcCloseColorBuffer(ctx, colorbuffer);
+}
+
+void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer)
+{
+	GET_CONTEXT; 
+	 ctx->rcSetWindowColorBuffer(ctx, windowSurface, colorBuffer);
+}
+
+int rcFlushWindowColorBuffer(uint32_t windowSurface)
+{
+	GET_CONTEXT; 
+	 return ctx->rcFlushWindowColorBuffer(ctx, windowSurface);
+}
+
+EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf)
+{
+	GET_CONTEXT; 
+	 return ctx->rcMakeCurrent(ctx, context, drawSurf, readSurf);
+}
+
+void rcFBPost(uint32_t colorBuffer)
+{
+	GET_CONTEXT; 
+	 ctx->rcFBPost(ctx, colorBuffer);
+}
+
+void rcFBSetSwapInterval(EGLint interval)
+{
+	GET_CONTEXT; 
+	 ctx->rcFBSetSwapInterval(ctx, interval);
+}
+
+void rcBindTexture(uint32_t colorBuffer)
+{
+	GET_CONTEXT; 
+	 ctx->rcBindTexture(ctx, colorBuffer);
+}
+
+void rcBindRenderbuffer(uint32_t colorBuffer)
+{
+	GET_CONTEXT; 
+	 ctx->rcBindRenderbuffer(ctx, colorBuffer);
+}
+
+EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead)
+{
+	GET_CONTEXT; 
+	 return ctx->rcColorBufferCacheFlush(ctx, colorbuffer, postCount, forRead);
+}
+
+void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels)
+{
+	GET_CONTEXT; 
+	 ctx->rcReadColorBuffer(ctx, colorbuffer, x, y, width, height, format, type, pixels);
+}
+
+int rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels)
+{
+	GET_CONTEXT; 
+	 return ctx->rcUpdateColorBuffer(ctx, colorbuffer, x, y, width, height, format, type, pixels);
+}
+
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_ftable.h b/tools/emulator/opengl/system/renderControl_enc/renderControl_ftable.h
new file mode 100644
index 0000000..1e9e2f9
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_ftable.h
@@ -0,0 +1,40 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __renderControl_client_ftable_t_h
+#define __renderControl_client_ftable_t_h
+
+
+static struct _renderControl_funcs_by_name {
+	const char *name;
+	void *proc;
+} renderControl_funcs_by_name[] = {
+	{"rcGetRendererVersion", (void*)rcGetRendererVersion},
+	{"rcGetEGLVersion", (void*)rcGetEGLVersion},
+	{"rcQueryEGLString", (void*)rcQueryEGLString},
+	{"rcGetGLString", (void*)rcGetGLString},
+	{"rcGetNumConfigs", (void*)rcGetNumConfigs},
+	{"rcGetConfigs", (void*)rcGetConfigs},
+	{"rcChooseConfig", (void*)rcChooseConfig},
+	{"rcGetFBParam", (void*)rcGetFBParam},
+	{"rcCreateContext", (void*)rcCreateContext},
+	{"rcDestroyContext", (void*)rcDestroyContext},
+	{"rcCreateWindowSurface", (void*)rcCreateWindowSurface},
+	{"rcDestroyWindowSurface", (void*)rcDestroyWindowSurface},
+	{"rcCreateColorBuffer", (void*)rcCreateColorBuffer},
+	{"rcOpenColorBuffer", (void*)rcOpenColorBuffer},
+	{"rcCloseColorBuffer", (void*)rcCloseColorBuffer},
+	{"rcSetWindowColorBuffer", (void*)rcSetWindowColorBuffer},
+	{"rcFlushWindowColorBuffer", (void*)rcFlushWindowColorBuffer},
+	{"rcMakeCurrent", (void*)rcMakeCurrent},
+	{"rcFBPost", (void*)rcFBPost},
+	{"rcFBSetSwapInterval", (void*)rcFBSetSwapInterval},
+	{"rcBindTexture", (void*)rcBindTexture},
+	{"rcBindRenderbuffer", (void*)rcBindRenderbuffer},
+	{"rcColorBufferCacheFlush", (void*)rcColorBufferCacheFlush},
+	{"rcReadColorBuffer", (void*)rcReadColorBuffer},
+	{"rcUpdateColorBuffer", (void*)rcUpdateColorBuffer},
+};
+static int renderControl_num_funcs = sizeof(renderControl_funcs_by_name) / sizeof(struct _renderControl_funcs_by_name);
+
+
+#endif
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_opcodes.h b/tools/emulator/opengl/system/renderControl_enc/renderControl_opcodes.h
new file mode 100644
index 0000000..b44f5d0
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_opcodes.h
@@ -0,0 +1,34 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __GUARD_renderControl_opcodes_h_
+#define __GUARD_renderControl_opcodes_h_
+
+#define OP_rcGetRendererVersion 					10000
+#define OP_rcGetEGLVersion 					10001
+#define OP_rcQueryEGLString 					10002
+#define OP_rcGetGLString 					10003
+#define OP_rcGetNumConfigs 					10004
+#define OP_rcGetConfigs 					10005
+#define OP_rcChooseConfig 					10006
+#define OP_rcGetFBParam 					10007
+#define OP_rcCreateContext 					10008
+#define OP_rcDestroyContext 					10009
+#define OP_rcCreateWindowSurface 					10010
+#define OP_rcDestroyWindowSurface 					10011
+#define OP_rcCreateColorBuffer 					10012
+#define OP_rcOpenColorBuffer 					10013
+#define OP_rcCloseColorBuffer 					10014
+#define OP_rcSetWindowColorBuffer 					10015
+#define OP_rcFlushWindowColorBuffer 					10016
+#define OP_rcMakeCurrent 					10017
+#define OP_rcFBPost 					10018
+#define OP_rcFBSetSwapInterval 					10019
+#define OP_rcBindTexture 					10020
+#define OP_rcBindRenderbuffer 					10021
+#define OP_rcColorBufferCacheFlush 					10022
+#define OP_rcReadColorBuffer 					10023
+#define OP_rcUpdateColorBuffer 					10024
+#define OP_last 					10025
+
+
+#endif
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl_types.h b/tools/emulator/opengl/system/renderControl_enc/renderControl_types.h
new file mode 100644
index 0000000..da215bb
--- /dev/null
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl_types.h
@@ -0,0 +1,28 @@
+/*
+* Copyright 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>
+#include <EGL/egl.h>
+#include "glUtils.h"
+
+// values for 'param' argument of rcGetFBParam
+#define FB_WIDTH    1
+#define FB_HEIGHT   2
+#define FB_XDPI     3
+#define FB_YDPI     4
+#define FB_FPS      5
+#define FB_MIN_SWAP_INTERVAL 6
+#define FB_MAX_SWAP_INTERVAL 7
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..f5254b7
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
@@ -0,0 +1,80 @@
+LOCAL_PATH := $(call my-dir)
+
+#### libGLESv1_CM_emul.so
+$(call emugl-begin-shared-library,libGLESv1_CM_emul)
+$(call emugl-import,libGLESv1_enc)
+$(call emugl-gen-wrapper,$(EMUGL_PATH)/system/GLESv1_enc,gl)
+$(call emugl-set-shared-library-subpath,egl)
+
+LOCAL_SRC_FILES += glesv1_emul_ifc.cpp
+
+$(call emugl-end-module)
+
+emulatorOpengl := $(LOCAL_PATH)/../..
+logTag := -DLOG_TAG=\"eglWrapper\"
+EMUGEN = $(BUILD_OUT_EXECUTABLES)/emugen
+## comment for no debug
+#debugFlags = -g -O0
+
+#### libGLESv2_CM_emul.so
+$(call emugl-begin-shared-library, libGLESv2_emul)
+$(call emugl-import,libGLESv2_enc)
+$(call emugl-gen-wrapper,$(EMUGL_PATH)/system/GLESv2_enc,gl2)
+LOCAL_SRC_FILES += glesv2_emul_ifc.cpp
+$(call emugl-set-shared-library-subpath,egl)
+$(call emugl-end-module)
+
+##### libEGL_emul.so ###########
+
+# THE FOLLOWING DOESN'T WORK YET
+#
+$(call emugl-begin-shared-library,libEGL_emul)
+$(call emugl-import,libut_rendercontrol_enc libGLESv1_CM_emul libGLESv2_emul libOpenglSystemCommon)
+
+$(call emugl-set-shared-library-subpath,egl)
+LOCAL_CFLAGS += $(logTag)
+
+LOCAL_SRC_FILES :=  \
+        egl.cpp \
+        egl_dispatch.cpp \
+        ServerConnection.cpp \
+        ThreadInfo.cpp
+
+$(call emugl-end-module)
+
+#### 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 full_mips sdk sdk_x86 sdk_mips,$(TARGET_PRODUCT)))
+ifeq (,$(BUILD_EMULATOR_OPENGL_DRIVER))
+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 # building 'real' driver BUILD_EMULATOR_OPENGL_DRIVER
+endif # TARGET_PRODUCT in 'full sdk full_x86 sdk_x86 full_mips sdk_mips'
+
+#### 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/ApiInitializer.h b/tools/emulator/opengl/tests/gles_android_wrapper/ApiInitializer.h
new file mode 100644
index 0000000..793c735
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ApiInitializer.h
@@ -0,0 +1,42 @@
+/*
+* Copyright 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 _API_INITIALIZER_H_
+#define _API_INITIALIZER_H_
+#include <stdlib.h>
+#include <dlfcn.h>
+
+class ApiInitializer {
+public:
+    ApiInitializer(void *dso) :
+        m_dso(dso) {
+    }
+    static void *s_getProc(const char *name, void *userData) {
+        ApiInitializer *self = (ApiInitializer *)userData;
+        return self->getProc(name);
+    }
+private:
+    void *m_dso;
+    void *getProc(const char *name) {
+        void *symbol = NULL;
+        if (m_dso) {
+            symbol = dlsym(m_dso, name);
+        }
+        return symbol;
+    }
+};
+
+#endif
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/CleanSpec.mk b/tools/emulator/opengl/tests/gles_android_wrapper/CleanSpec.mk
new file mode 100644
index 0000000..f56383a
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/CleanSpec.mk
@@ -0,0 +1,50 @@
+# Copyright (C) 2007 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list.  These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+#     $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+#     $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list.  E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/SHARED_LIBRARIES/libGLES_emul_intermediates)
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..ff4e390
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.cpp
@@ -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.
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include "ServerConnection.h"
+#include "TcpStream.h"
+#include "QemuPipeStream.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;
+}
+
+gl2_client_context_t *ServerConnection::s_getGl2Context()
+{
+    EGLThreadInfo *ti = getEGLThreadInfo();
+    if (ti->serverConn) {
+        return ti->serverConn->m_gl2Enc;
+    }
+    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)
+{
+    /* XXX: Make configurable through system property */
+    int useQemuPipe = 1;
+
+    if (m_stream != NULL) delete(m_stream);
+
+    if (useQemuPipe) {
+        QemuPipeStream*  pipeStream = new QemuPipeStream(bufsize);
+
+        if (pipeStream->connect() < 0) {
+            ALOGE("couldn't connect to host server\n");
+            delete pipeStream;
+            return -1;
+        }
+        m_stream = pipeStream;
+    }
+    else /* !useQemuPipe */
+    {
+        TcpStream*  tcpStream = new TcpStream(bufsize);
+
+        char *s = getenv(ENV_RGL_SERVER);
+        char *hostname;
+        if (s == NULL) {
+            hostname = strdup(defaultServer);
+        } else {
+            hostname = strdup(s);
+        }
+
+        if (tcpStream->connect(hostname, CODEC_SERVER_PORT) < 0) {
+            ALOGE("couldn't connect to %s\n", hostname);
+            free(hostname);
+            delete tcpStream;
+            return -1;
+        }
+        LOGI("connecting to server %s\n", hostname);
+        free(hostname);
+
+        m_stream = tcpStream;
+    }
+
+    m_glEnc = new GLEncoder(m_stream);
+    m_glEnc->setContextAccessor(s_getGlContext);
+
+    m_gl2Enc = new GL2Encoder(m_stream);
+    m_gl2Enc->setContextAccessor(s_getGl2Context);
+
+    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..84f40d8
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ServerConnection.h
@@ -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.
+*/
+#ifndef _SERVER_CONNECTION_H
+#define _SERVER_CONNECTION_H
+
+#include "GLEncoder.h"
+#include "GL2Encoder.h"
+#include "IOStream.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();
+    static gl2_client_context_t *s_getGl2Context();
+    GLEncoder *glEncoder() { return m_glEnc; }
+    GL2Encoder *gl2Encoder() { return m_gl2Enc; }
+    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();
+    IOStream *m_stream;
+    GLEncoder *m_glEnc;
+    GL2Encoder *m_gl2Enc;
+    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..f748a39
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/ThreadInfo.h
@@ -0,0 +1,49 @@
+/*
+* 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, int _version) {
+        aglContext = p_aglContext;
+        clientState = NULL;
+        version = _version;
+    }
+
+    ~EGLWrapperContext() {
+        delete clientState;
+    }
+
+    EGLContext aglContext;
+    GLClientState *clientState;
+    int version;
+};
+
+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..1e2e456
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp
@@ -0,0 +1,663 @@
+/*
+* 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>
+#include "gl_wrapper_context.h"
+#include "gl2_wrapper_context.h"
+
+#define GLES_EMUL_TARGETS_FILE "/system/etc/gles_emul.cfg"
+// implementation libraries;
+#define GLESv1_enc_LIB "/system/lib/libGLESv1_enc.so"
+#define GLESv2_enc_LIB "/system/lib/libGLESv2_enc.so"
+#define GLES_android_LIB "/system/lib/egl/libGLES_android.so"
+// driver libraries;
+#define GLESv1_DRIVER "/system/lib/egl/libGLESv1_CM_emul.so"
+#define GLESv2_DRIVER "/system/lib/egl/libGLESv2_emul.so"
+
+
+static struct egl_dispatch *s_dispatch = NULL;
+pthread_once_t dispatchTablesInitialized = PTHREAD_ONCE_INIT;
+
+static bool s_needEncode = false;
+
+static gl_wrapper_context_t *g_gl_dispatch = NULL;
+static gl2_wrapper_context_t *g_gl2_dispatch = NULL;
+
+template <class T>
+int initApi(const char *driverLibName, const char *implLibName, T **dispatchTable, T *(*accessor)())
+{
+    void *driverLib = dlopen(driverLibName, RTLD_NOW | RTLD_LOCAL);
+    if (driverLib == NULL) {
+        ALOGE("failed to load %s : %s\n", driverLibName, dlerror());
+        return -1;
+    }
+
+    typedef T *(*createFcn_t)(void *, T *(*accessor)());
+    createFcn_t createFcn;
+    createFcn = (createFcn_t) dlsym(driverLib, "createFromLib");
+    if (createFcn == NULL) {
+        ALOGE("failed to load createFromLib constructor function\n");
+        return -1;
+    }
+
+    void *implLib = dlopen(implLibName, RTLD_NOW | RTLD_LOCAL);
+    if (implLib == NULL) {
+        ALOGE("couldn't open %s", implLibName);
+        return -2;
+    }
+    *dispatchTable = createFcn(implLib, accessor);
+    if (*dispatchTable == NULL) {
+        return -3;
+    }
+
+    // XXX - we do close the impl library since it doesn't have data, as far as we concern.
+    dlclose(implLib);
+
+    // XXX - we do not dlclose the driver library, so its not initialized when
+    // later loaded by android - is this required?
+    ALOGD("loading %s into %s complete\n", implLibName, driverLibName);
+    return 0;
+
+}
+
+static gl_wrapper_context_t *getGLContext()
+{
+    return g_gl_dispatch;
+}
+
+static gl2_wrapper_context_t *getGL2Context()
+{
+    return g_gl2_dispatch;
+}
+
+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) {
+                ALOGE("couldn't open /proc/self/cmdline\n");
+                return NULL;
+            }
+
+            char line[1000];
+            if (fgets(line, sizeof(line), fp) == NULL) {
+                ALOGE("couldn't read the self cmdline from \n");
+                fclose(fp);
+                return NULL;
+            }
+            fclose(fp);
+
+            if (line[0] == '\0') {
+                ALOGE("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);
+        }
+    }
+
+    return procname;
+}
+
+
+
+bool isNeedEncode()
+{
+    const char *procname = getProcName();
+    if (procname == NULL) return false;
+    ALOGD("isNeedEncode? for %s\n", procname);
+    // check on our whitelist
+    FILE *fp = fopen(GLES_EMUL_TARGETS_FILE, "rt");
+    if (fp == NULL) {
+        ALOGE("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;
+                ALOGD("should use encoder for %s\n", procname);
+                break;
+            }
+        }
+    }
+    fclose(fp);
+    return found;
+}
+
+void initDispatchTables()
+{
+    //
+    // Load our back-end implementation of EGL/GLES
+    //
+    ALOGD("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) {
+        // initialize a connection to the server, and the GLESv1/v2 encoders;
+        ServerConnection * connection = ServerConnection::s_getServerConnection();
+        if (connection == NULL) {
+            ALOGE("couldn't create server connection\n");
+            s_needEncode = false;
+        }
+    }
+
+    // init dispatch tabels for GLESv1 & GLESv2
+    if (s_needEncode) {
+        // XXX - we do not check the retrun value because there isn't much we can do here on failure.
+
+        if (initApi<gl_wrapper_context_t>(GLESv1_DRIVER, GLESv1_enc_LIB, &g_gl_dispatch, getGLContext) < 0) {
+            // fallback to android on faluire
+            s_needEncode = false;
+        } else {
+            initApi<gl2_wrapper_context_t>(GLESv2_DRIVER, GLESv2_enc_LIB, &g_gl2_dispatch, getGL2Context);
+        }
+    }
+
+    if (!s_needEncode) {
+        ALOGD("Initializing native opengl for %s\n", getProcName());
+        initApi<gl_wrapper_context_t>(GLESv1_DRIVER, GLES_android_LIB, &g_gl_dispatch, getGLContext);
+        // try to initialize gl2 from GLES, though its probably going to fail
+        initApi<gl2_wrapper_context_t>(GLESv2_DRIVER, GLES_android_LIB, &g_gl2_dispatch, getGL2Context);
+    }
+}
+
+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;
+        }
+    }
+
+    // we do not support eglGetProcAddress for GLESv1 & GLESv2. The loader
+    // should be able to find this function through dynamic loading.
+    return NULL;
+}
+
+////////////////  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);
+}
+
+static EGLint * filter_es2_bit(const EGLint *attrib_list, bool *isES2)
+{
+    if (attrib_list == NULL) {
+        if (isES2 != NULL) *isES2 = false;
+        return NULL;
+    }
+
+    EGLint *attribs = NULL;
+    int nAttribs = 0;
+    while(attrib_list[nAttribs] != EGL_NONE) nAttribs++;
+    nAttribs++;
+
+    attribs = new EGLint[nAttribs];
+    memcpy(attribs, attrib_list, nAttribs * sizeof(EGLint));
+    if (isES2 != NULL) *isES2 = false;
+
+    // scan the attribute list for ES2 request and replace with ES1.
+    for (int i = 0; i < nAttribs; i++) {
+        if (attribs[i] == EGL_RENDERABLE_TYPE) {
+            if (attribs[i + 1] & EGL_OPENGL_ES2_BIT) {
+                attribs[i + 1] &= ~EGL_OPENGL_ES2_BIT;
+                attribs[i + 1] |= EGL_OPENGL_ES_BIT;
+                ALOGD("removing ES2 bit 0x%x\n", attribs[i + 1]);
+                if (isES2 != NULL) *isES2 = true;
+            }
+        }
+    }
+    return attribs;
+}
+
+EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+    EGLBoolean res;
+    if (s_needEncode) {
+        EGLint *attribs = filter_es2_bit(attrib_list, NULL);
+        res =  getDispatch()->eglChooseConfig(dpy,
+                                              attribs,
+                                              configs,
+                                              config_size,
+                                              num_config);
+        ALOGD("eglChooseConfig: %d configs found\n", *num_config);
+        if (*num_config == 0 && attribs != NULL) {
+            ALOGD("requested attributes:\n");
+            for (int i = 0; attribs[i] != EGL_NONE; i++) {
+                ALOGD("%d: 0x%x\n", i, attribs[i]);
+            }
+        }
+
+        delete attribs;
+    } else {
+        res = getDispatch()->eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
+    }
+    return res;
+}
+
+EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+{
+    if (s_needEncode && attribute == EGL_RENDERABLE_TYPE) {
+        *value = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT;
+        return EGL_TRUE;
+    } else {
+        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)
+{
+    EGLBoolean res = getDispatch()->eglQuerySurface(dpy, surface, attribute, value);
+    if (res && attribute == EGL_RENDERABLE_TYPE) {
+        *value |= EGL_OPENGL_ES2_BIT;
+    }
+    return res;
+}
+
+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;
+
+    // check if are ES2, and convert it to ES1.
+    int nAttribs = 0;
+    if (attrib_list != NULL) {
+        while(attrib_list[nAttribs] != EGL_NONE) {
+            nAttribs++;
+        }
+        nAttribs++;
+    }
+
+    EGLint *attrib = NULL;
+    if (nAttribs > 0) {
+        attrib = new EGLint[nAttribs];
+        memcpy(attrib, attrib_list, nAttribs * sizeof(EGLint));
+    }
+
+    int  version  = 1;
+    for (int i = 0; i < nAttribs; i++) {
+        if (attrib[i] == EGL_CONTEXT_CLIENT_VERSION &&
+            attrib[i + 1] == 2) {
+            version = 2;
+            attrib[i + 1] = 1; // replace to version 1
+        }
+    }
+
+    EGLContext ctx =  getDispatch()->eglCreateContext(dpy, config, share, attrib);
+    delete attrib;
+    EGLWrapperContext *wctx = new EGLWrapperContext(ctx, version);
+    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), wctx->version);
+        }
+    }
+    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();
+            ServerConnection *server;
+            if (s_needEncode && (server = ServerConnection::s_getServerConnection())) {
+                server->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 ) {
+        // NOTE - we do get a pointer to the server connection, (rather then using ti->serverConn)
+        // for cases that this is the first egl call of the current thread.
+
+        ServerConnection *server;
+        if (s_needEncode && (server = ServerConnection::s_getServerConnection())) {
+            server->utEnc()->makeCurrentContext(server->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));
+            server->glEncoder()->setClientState( wctx ? wctx->clientState : NULL );
+            server->gl2Encoder()->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) {
+        if (attribute == EGL_CONTEXT_CLIENT_VERSION) {
+            *value = wctx->version;
+            return EGL_TRUE;
+        } else {
+            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();
+        server->gl2Encoder()->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..c0949c8
--- /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) {
+        ALOGE("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);
+}
+
+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);
+}
+
+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);
+}
+
+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, exponent);
+}
+
+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);
+}
+
+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..a837807
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/gles_emul.cfg
@@ -0,0 +1,7 @@
+angeles
+my-tritex
+org.zeroxlab.benchmark
+com.cooliris.media
+com.polarbit.waveblazerlite
+test-opengl-gl2_basic
+com.trendy.ddapp
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..afd94b9
--- /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/gles_android_wrapper/glesv1_emul_ifc.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp
new file mode 100644
index 0000000..26c98a8
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp
@@ -0,0 +1,39 @@
+/*
+* Copyright 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 <stdlib.h>
+#include "ApiInitializer.h"
+#include <dlfcn.h>
+#include "gl_wrapper_context.h"
+
+extern "C" {
+    gl_wrapper_context_t *createFromLib(void *solib, gl_wrapper_context_t *(*accessor)());
+}
+
+gl_wrapper_context_t * createFromLib(void *solib, gl_wrapper_context_t *(accessor)())
+{
+    gl_wrapper_context_t *ctx = new gl_wrapper_context_t;
+    if (ctx == NULL) {
+        return NULL;
+    }
+    ApiInitializer *initializer = new ApiInitializer(solib);
+    ctx->initDispatchByName(ApiInitializer::s_getProc, initializer);
+    gl_wrapper_context_t::setContextAccessor(accessor);
+    delete initializer;
+    return ctx;
+}
+
+
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp
new file mode 100644
index 0000000..4ae13dd
--- /dev/null
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp
@@ -0,0 +1,40 @@
+/*
+* Copyright 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 <stdlib.h>
+#include "ApiInitializer.h"
+#include <dlfcn.h>
+#include "gl2_wrapper_context.h"
+
+extern "C" {
+    gl2_wrapper_context_t *createFromLib(void *solib, gl2_wrapper_context_t *(*accessor)());
+}
+
+gl2_wrapper_context_t * createFromLib(void *solib, gl2_wrapper_context_t *(*accessor)())
+{
+    gl2_wrapper_context_t *ctx = new gl2_wrapper_context_t;
+    if (ctx == NULL) {
+        return NULL;
+    }
+    ApiInitializer *initializer = new ApiInitializer(solib);
+    ctx->initDispatchByName(ApiInitializer::s_getProc, initializer);
+    gl2_wrapper_context_t::setContextAccessor(accessor);
+    delete initializer;
+    return ctx;
+}
+
+
+
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..ae234b2
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_rendercontrol_enc/Android.mk
@@ -0,0 +1,8 @@
+LOCAL_PATH := $(call my-dir)
+
+$(call emugl-begin-shared-library,libut_rendercontrol_enc)
+$(call emugl-import,libOpenglCodecCommon)
+$(call emugl-gen-encoder,$(LOCAL_PATH),ut_rendercontrol)
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+$(call emugl-end-module)
+
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..0d5942f
--- /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, int version)
+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..9d945ab
--- /dev/null
+++ b/tools/emulator/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.types
@@ -0,0 +1,2 @@
+uint32_t 32 0x%08x false
+
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/jdwpspy/Main.cpp b/tools/jdwpspy/Main.cpp
index 0f68d52..b53f99b 100644
--- a/tools/jdwpspy/Main.cpp
+++ b/tools/jdwpspy/Main.cpp
@@ -7,6 +7,7 @@
 #include "Common.h"
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <string.h>
 #include <assert.h>
 #include <ctype.h>
@@ -35,7 +36,7 @@
 {
     const unsigned char* addr = reinterpret_cast<const unsigned char*>(vaddr);
     char out[77];       /* exact fit */
-    unsigned int offset;    /* offset to show while printing */
+    uintptr_t offset;   /* offset to show while printing */
     char* hex;
     char* asc;
     int gap;
@@ -43,7 +44,7 @@
     if (mode == kHexDumpLocal)
         offset = 0;
     else
-        offset = (int) addr;
+        offset = (uintptr_t) addr;
 
     memset(out, ' ', sizeof(out)-1);
     out[8] = ':';