Bug 487949 - Land HTML5 parser on trunk preffed off r=mrbkap, sr=jonas default tip
authorHenri Sivonen <hsivonen@iki.fi>
Sun, 28 Jun 2009 20:19:05 +0300
changeset 29794 168dd0eb728303a5da0dfdda9d447fcb8dd6fb42
parent 29733 d33c8caa18a116cb5113b3cafb237396ddf540ae (current diff)
parent 29793 4851a9d9a60c864915ddf0f21a73f8c8a197dd6d (diff)
push id106
push userhsivonen@iki.fi
push dateSun, 28 Jun 2009 17:44:42 +0000
reviewersmrbkap, jonas
bugs487949
milestone1.9.2a1pre
Bug 487949 - Land HTML5 parser on trunk preffed off r=mrbkap, sr=jonas
layout/build/Makefile.in
layout/generic/nsObjectFrame.cpp
modules/plugin/base/public/nsIWindowlessPlugInstPeer.idl
--- a/allmakefiles.sh
+++ b/allmakefiles.sh
@@ -53,32 +53,42 @@ if [ "$srcdir" = "" ]; then
 fi
 
 #
 # Common makefiles used by everyone
 #
 add_makefiles "
 Makefile
 build/Makefile
+build/pgo/Makefile
+build/pgo/blueprint/Makefile
+build/pgo/js-input/Makefile
 build/unix/Makefile
+build/win32/Makefile
 config/Makefile
 config/autoconf.mk
 config/mkdepend/Makefile
+config/nspr/Makefile
 config/doxygen.cfg
 config/tests/src-simple/Makefile
 probes/Makefile
 extensions/Makefile
-build/wince/tools/Makefile
-build/wince/shunt/Makefile
-build/wince/shunt/include/windows.h
-build/wince/shunt/include/ymath.h
-build/wince/shunt/include/stdlib.h
-build/wince/shunt/include/sys/Makefile
 "
 
+if [ "$WINCE" ]; then
+  add_makefiles "
+    build/wince/tools/Makefile
+    build/wince/shunt/Makefile
+    build/wince/shunt/include/windows.h
+    build/wince/shunt/include/ymath.h
+    build/wince/shunt/include/stdlib.h
+    build/wince/shunt/include/sys/Makefile
+  "
+fi
+
 if [ "$MOZ_MEMORY" ]; then
   add_makefiles "
     memory/jemalloc/Makefile
   "
 fi
 
 #
 # Application-specific makefiles
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -540,17 +540,17 @@
              context="toolbar-context-menu"
              defaultset="personal-bookmarks"
              toolbarname="&personalbarCmd.label;" accesskey="&personalbarCmd.accesskey;"
              customizable="true"/>
   </toolbox>
 
   <hbox flex="1" id="browser">
     <vbox id="sidebar-box" hidden="true" class="chromeclass-extrachrome">
-      <sidebarheader align="center">
+      <sidebarheader id="sidebar-header" align="center">
         <label id="sidebar-title" persist="value" flex="1" crop="end" control="sidebar"/>
         <image id="sidebar-throbber"/>
         <toolbarbutton class="tabs-closebutton" tooltiptext="&sidebarCloseButton.tooltip;" oncommand="toggleSidebar();"/>
       </sidebarheader>
       <browser id="sidebar" flex="1" autoscroll="false" disablehistory="true"
                 style="min-width: 14em; width: 18em; max-width: 36em;"/>
     </vbox>
 
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -541,21 +541,24 @@ PlacesController.prototype = {
    */
   _shouldShowMenuItem: function PC__shouldShowMenuItem(aMenuItem, aMetaData) {
     var selectiontype = aMenuItem.getAttribute("selectiontype");
     if (selectiontype == "multiple" && aMetaData.length == 1)
       return false;
     if (selectiontype == "single" && aMetaData.length != 1)
       return false;
 
-    var forceHideRules = aMenuItem.getAttribute("forcehideselection").split("|");
-    for (var i = 0; i < aMetaData.length; ++i) {
-      for (var j=0; j < forceHideRules.length; ++j) {
-        if (forceHideRules[j] in aMetaData[i])
-          return false;
+    var forceHideAttr = aMenuItem.getAttribute("forcehideselection");
+    if (forceHideAttr) {
+      var forceHideRules = forceHideAttr.split("|");
+      for (var i = 0; i < aMetaData.length; ++i) {
+        for (var j=0; j < forceHideRules.length; ++j) {
+          if (forceHideRules[j] in aMetaData[i])
+            return false;
+        }
       }
     }
 
     var selectionAttr = aMenuItem.getAttribute("selection");
     if (selectionAttr) {
       if (selectionAttr == "any")
         return true;
 
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -2761,17 +2761,17 @@ SessionStoreService.prototype = {
     let maxWindowsUndo = this._prefBranch.getIntPref("sessionstore.max_windows_undo");
     if (this._closedWindows.length <= maxWindowsUndo)
       return;
     let spliceTo = maxWindowsUndo;
 #ifndef XP_MACOSX
     let normalWindowIndex = 0;
     // try to find a non-popup window in this._closedWindows
     while (normalWindowIndex < this._closedWindows.length &&
-           this._closedWindows[normalWindowIndex].isPopup)
+           !!this._closedWindows[normalWindowIndex].isPopup)
       normalWindowIndex++;
     if (normalWindowIndex >= maxWindowsUndo)
       spliceTo = normalWindowIndex + 1;
 #endif
     this._closedWindows.splice(spliceTo);
   },
 
 /* ........ Storage API .............. */
--- a/browser/components/sessionstore/test/browser/browser_394759.js
+++ b/browser/components/sessionstore/test/browser/browser_394759.js
@@ -108,34 +108,34 @@ function test() {
           }, false);
         });
       }, true);
     }, false);
   }
   
   function test_behavior (callback) {
     // helper function that does the actual testing
-    function openWindowRec(windowsToOpen, expectedResults) {
+    function openWindowRec(windowsToOpen, expectedResults, recCallback) {
       // do actual checking
       if (!windowsToOpen.length) {
         let closedWindowData = JSON.parse(ss.getClosedWindowData());
         let numPopups = closedWindowData.filter(function(el, i, arr) {
           return el.isPopup;
         }).length;
         let numNormal = ss.getClosedWindowCount() - numPopups;
         // #ifdef doesn't work in browser-chrome tests, so do a simple regex on platform
         let oResults = navigator.platform.match(/Mac/) ? expectedResults.mac
                                                        : expectedResults.other;
         is(numPopups, oResults.popup,
            "There were " + oResults.popup + " popup windows to repoen");
         is(numNormal, oResults.normal,
            "There were " + oResults.normal + " normal windows to repoen");
 
         // cleanup & return
-        executeSoon(callback);
+        executeSoon(recCallback);
         return;
       }
       // hack to force window to be considered a popup (toolbar=no didn't work)
       let winData = windowsToOpen.shift();
       let settings = "chrome,dialog=no," +
                      (winData.isPopup ? "all=no" : "all");
       let url = "http://window" + windowsToOpen.length + ".example.com";
       let window = openDialog(location, "_blank", settings, url);
@@ -144,17 +144,17 @@ function test() {
           // the window _should_ have state with a tab of url, but it doesn't
           // always happend before window.close(). addTab ensure we don't treat
           // this window as a stateless window
           window.gBrowser.addTab();
           window.gBrowser.removeEventListener("load", arguments.callee, true);
           executeSoon(function() {
             window.close();
             executeSoon(function() {
-              openWindowRec(windowsToOpen, expectedResults);
+              openWindowRec(windowsToOpen, expectedResults, recCallback);
             });
           });
         }, true);
       }, true);
     }
 
     let windowsToOpen = [{isPopup: false},
                          {isPopup: false},
--- a/browser/installer/removed-files.in
+++ b/browser/installer/removed-files.in
@@ -636,14 +636,12 @@ libjemalloc.so
 #ifdef MOZ_MEMORY
 Microsoft.VC80.CRT.manifest
 msvcm80.dll
 msvcp80.dll
 msvcr80.dll
 #else
 mozcrt19.dll
 #endif
-xpicleanup.exe
-#else
-xpicleanup
 #endif
+xpicleanup@BIN_SUFFIX@
 chrome.manifest
 install.rdf
--- a/browser/locales/Makefile.in
+++ b/browser/locales/Makefile.in
@@ -59,18 +59,16 @@ ifdef LOCALE_MERGEDIR
 vpath book%.inc $(LOCALE_MERGEDIR)/browser/profile
 endif
 vpath book%.inc $(LOCALE_SRCDIR)/profile
 ifdef LOCALE_MERGEDIR
 vpath book%.inc @srcdir@/en-US/profile
 endif
 
 
-run_for_effects_too := if ! test -d $(DIST)/branding; then $(NSINSTALL) -D $(DIST)/branding; fi)
-
 ifdef MOZ_BRANDING_DIRECTORY
 SUBMAKEFILES += \
 	$(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/Makefile \
 	$(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales/Makefile \
 	$(NULL)
 endif
 
 # This makefile uses variable overrides from the libs-% target to
@@ -99,16 +97,21 @@ endif
 
 PREF_JS_EXPORTS = $(firstword $(wildcard $(LOCALE_SRCDIR)/firefox-l10n.js) \
                        $(srcdir)/en-US/firefox-l10n.js )
 
 include $(topsrcdir)/config/rules.mk
 
 include $(topsrcdir)/toolkit/locales/l10n.mk
 
+$(STAGEDIST): $(DIST)/branding
+
+$(DIST)/branding:
+	$(NSINSTALL) -D $@
+
 libs::
 	@if test -f "$(LOCALE_SRCDIR)/existing-profile-defaults.js"; then \
 	  $(PERL) $(topsrcdir)/config/preprocessor.pl $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
 	    $(LOCALE_SRCDIR)/existing-profile-defaults.js > $(FINAL_TARGET)/defaults/existing-profile-defaults.js; \
 	fi
 install::
 	@if test -f "$(LOCALE_SRCDIR)/existing-profile-defaults.js"; then \
 	  $(PERL) $(topsrcdir)/config/preprocessor.pl $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
--- a/browser/makefiles.sh
+++ b/browser/makefiles.sh
@@ -34,40 +34,83 @@
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
 add_makefiles "
 browser/Makefile
 browser/app/Makefile
 browser/app/profile/extensions/Makefile
+browser/app/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/Makefile
 browser/base/Makefile
 browser/components/Makefile
 browser/components/build/Makefile
+browser/components/certerror/Makefile
 browser/components/dirprovider/Makefile
+browser/components/feeds/Makefile
+browser/components/feeds/public/Makefile
+browser/components/feeds/src/Makefile
+browser/components/microsummaries/Makefile
+browser/components/microsummaries/public/Makefile
+browser/components/microsummaries/src/Makefile
 browser/components/migration/Makefile
 browser/components/migration/public/Makefile
 browser/components/migration/src/Makefile
 browser/components/places/Makefile
+browser/components/places/public/Makefile
+browser/components/places/src/Makefile
 browser/components/preferences/Makefile
+browser/components/privatebrowsing/Makefile
+browser/components/privatebrowsing/src/Makefile
+browser/components/safebrowsing/Makefile
+browser/components/safebrowsing/src/Makefile
 browser/components/search/Makefile
+browser/components/sessionstore/Makefile
+browser/components/sessionstore/src/Makefile
 browser/components/sidebar/Makefile
 browser/components/sidebar/src/Makefile
 browser/components/shell/Makefile
 browser/components/shell/public/Makefile
 browser/components/shell/src/Makefile
+browser/fuel/Makefile
+browser/fuel/public/Makefile
+browser/fuel/src/Makefile
 browser/installer/Makefile
 browser/installer/windows/Makefile
 browser/locales/Makefile
 browser/themes/Makefile
 browser/themes/pinstripe/browser/Makefile
+browser/themes/pinstripe/communicator/Makefile
 browser/themes/pinstripe/Makefile
 browser/themes/winstripe/browser/Makefile
+browser/themes/winstripe/communicator/Makefile
 browser/themes/winstripe/Makefile
 "
 
 if test -n "$MOZ_BRANDING_DIRECTORY"; then
   add_makefiles "
     $MOZ_BRANDING_DIRECTORY/Makefile
     $MOZ_BRANDING_DIRECTORY/content/Makefile
     $MOZ_BRANDING_DIRECTORY/locales/Makefile
   "
 fi
+
+if [ "$ENABLE_TESTS" ]; then
+  add_makefiles "
+    browser/base/content/test/Makefile
+    browser/components/certerror/test/Makefile
+    browser/components/preferences/tests/Makefile
+    browser/components/search/test/Makefile
+    browser/components/sessionstore/test/Makefile
+    browser/components/sessionstore/test/browser/Makefile
+    browser/components/shell/test/Makefile
+    browser/components/feeds/test/Makefile
+    browser/components/feeds/test/chrome/Makefile
+    browser/components/places/tests/Makefile
+    browser/components/places/tests/chrome/Makefile
+    browser/components/places/tests/browser/Makefile
+    browser/components/places/tests/perf/Makefile
+    browser/components/privatebrowsing/test/Makefile
+    browser/components/privatebrowsing/test/browser/Makefile
+    browser/components/safebrowsing/content/test/Makefile
+    browser/fuel/test/Makefile
+  "
+fi
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -232,16 +232,17 @@ MOZ_TREE_CAIRO = @MOZ_TREE_CAIRO@
 
 MOZ_UPDATE_XTERM = @MOZ_UPDATE_XTERM@
 MOZ_MATHML = @MOZ_MATHML@
 MOZ_PERMISSIONS = @MOZ_PERMISSIONS@
 MOZ_XTF = @MOZ_XTF@
 MOZ_NO_INSPECTOR_APIS = @MOZ_NO_INSPECTOR_APIS@
 MOZ_SVG = @MOZ_SVG@
 MOZ_ENABLE_CANVAS = @MOZ_ENABLE_CANVAS@
+MOZ_ENABLE_CANVAS3D = @MOZ_ENABLE_CANVAS3D@
 MOZ_CAIRO_CFLAGS = @MOZ_CAIRO_CFLAGS@
 MOZ_SMIL = @MOZ_SMIL@
 MOZ_XSLT_STANDALONE = @MOZ_XSLT_STANDALONE@
 
 MOZ_PREF_EXTENSIONS = @MOZ_PREF_EXTENSIONS@
 
 MOZ_CAIRO_LIBS = @MOZ_CAIRO_LIBS@
 
@@ -541,19 +542,16 @@ GLIB_CFLAGS	= @GLIB_CFLAGS@
 GLIB_LIBS	= @GLIB_LIBS@
 GLIB_GMODULE_LIBS	= @GLIB_GMODULE_LIBS@
 LIBIDL_CFLAGS = @LIBIDL_CFLAGS@
 LIBIDL_LIBS = @LIBIDL_LIBS@
 STATIC_LIBIDL = @STATIC_LIBIDL@
 
 MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
 
-# Used for LD_LIBRARY_PATH
-LIBS_PATH       = @LIBS_PATH@
-
 MOZ_AUTO_DEPS	= @MOZ_AUTO_DEPS@
 COMPILER_DEPEND = @COMPILER_DEPEND@
 MDDEPDIR        := @MDDEPDIR@
 
 MOZ_DEMANGLE_SYMBOLS = @MOZ_DEMANGLE_SYMBOLS@
 
 # XXX - these need to be cleaned up and have real checks added -cls
 CM_BLDTYPE=dbg
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -941,22 +941,16 @@ endif # WINNT_
 endif # MOZ_PROFILE_GENERATE || MOZ_PROFILE_USE
 endif # NO_PROFILE_GUIDED_OPTIMIZE
 
 ##############################################
 
 checkout:
 	$(MAKE) -C $(topsrcdir) -f client.mk checkout
 
-run_viewer: $(FINAL_TARGET)/viewer
-	cd $(FINAL_TARGET); \
-	MOZILLA_FIVE_HOME=`pwd` \
-	LD_LIBRARY_PATH=".:$(LIBS_PATH):$$LD_LIBRARY_PATH" \
-	viewer
-
 clean clobber realclean clobber_all:: $(SUBMAKEFILES)
 	-rm -f $(ALL_TRASH)
 	-rm -rf $(ALL_TRASH_DIRS)
 	$(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
 
 distclean:: $(SUBMAKEFILES)
 	$(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
 	-rm -rf $(ALL_TRASH_DIRS) 
@@ -2101,17 +2095,17 @@ endif
 # hundreds of built-in suffix rules for stuff we don't need.
 #
 .SUFFIXES:
 
 #
 # Fake targets.  Always run these rules, even if a file/directory with that
 # name already exists.
 #
-.PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_viewer run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE
+.PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE
 
 # Used as a dependency to force targets to rebuild
 FORCE:
 
 # Delete target if error occurs when building target
 .DELETE_ON_ERROR:
 
 # Properly set LIBPATTERNS for the platform
--- a/configure.in
+++ b/configure.in
@@ -4486,16 +4486,17 @@ dnl ====================================
 MOZ_ARG_HEADER(Application)
 
 BUILD_STATIC_LIBS=
 ENABLE_TESTS=1
 MOZ_ACTIVEX_SCRIPTING_SUPPORT=
 MOZ_BRANDING_DIRECTORY=
 MOZ_DBGRINFO_MODULES=
 MOZ_ENABLE_CANVAS=1
+MOZ_ENABLE_CANVAS3D=
 MOZ_FEEDS=1
 MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp xbm icon"
 MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
 MOZ_JAVAXPCOM=
 MOZ_JSDEBUGGER=1
 MOZ_JSLOADER=1
 MOZ_MATHML=1
 MOZ_MORK=1
@@ -5910,16 +5911,25 @@ MOZ_ARG_DISABLE_BOOL(canvas,
 [  --disable-canvas          Disable html:canvas feature],
     MOZ_ENABLE_CANVAS=,
     MOZ_ENABLE_CANVAS=1 )
 if test -n "$MOZ_ENABLE_CANVAS"; then
     AC_DEFINE(MOZ_ENABLE_CANVAS)
 fi
 AC_SUBST(MOZ_ENABLE_CANVAS)
 
+MOZ_ARG_ENABLE_BOOL(canvas3d,
+[  --enable-canvas3d        Enable canvas 3D context],
+    MOZ_ENABLE_CANVAS3D=1,
+    MOZ_ENABLE_CANVAS3D= )
+if test -n "$MOZ_ENABLE_CANVAS3D"; then
+    AC_DEFINE(MOZ_ENABLE_CANVAS3D)
+fi
+AC_SUBST(MOZ_ENABLE_CANVAS3D)
+
 dnl ========================================================
 dnl SVG
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(svg,
 [  --disable-svg            Disable SVG support],
     MOZ_SVG=,
     MOZ_SVG=1 )
 if test -n "$MOZ_SVG"; then
@@ -8320,26 +8330,16 @@ if test "$ACCESSIBILITY" -a "$MOZ_ENABLE
     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
 fi
 
-# Used for LD_LIBRARY_PATH of run_viewer target
-LIBS_PATH=
-for lib_arg in $NSPR_LIBS $TK_LIBS; do
-  case $lib_arg in
-    -L* ) LIBS_PATH="${LIBS_PATH:+$LIBS_PATH:}"`expr $lib_arg : "-L\(.*\)"` ;;
-      * ) ;;
-  esac
-done
-AC_SUBST(LIBS_PATH)
-
 dnl ========================================================
 dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
 dnl ========================================================
 case "$host_os" in
 mingw*)
     WIN_TOP_SRC=`cd $srcdir; pwd -W`
     ;;
 cygwin*|msvc*|mks*)
--- a/content/canvas/public/Makefile.in
+++ b/content/canvas/public/Makefile.in
@@ -44,9 +44,13 @@ include $(DEPTH)/config/autoconf.mk
 
 MODULE		= content
 
 EXPORTS		= \
 		nsICanvasRenderingContextInternal.h \
 		nsICanvasElement.h \
 		$(NULL)
 
+XPIDLSRCS	= \
+		nsICanvasGLPrivate.idl \
+		$(NULL)
+
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/content/canvas/public/nsICanvasGLPrivate.idl
@@ -0,0 +1,53 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is canvas 3D.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Vladimir Vukicevic <vladimir@pobox.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsISupports.idl"
+
+/* These are private interface that's used to identify
+ * specific concrete classes so we know what we can cast.
+ */
+
+[scriptable, uuid(eba2aa03-ae19-46e2-bad7-6b966037e22c)]
+interface nsICanvasGLBuffer : nsISupports
+{
+};
+
+[scriptable, uuid(27310aab-1988-43e8-882e-6293c8c9df60)]
+interface nsICanvasGLTexture : nsISupports
+{
+};
--- a/content/canvas/src/Makefile.in
+++ b/content/canvas/src/Makefile.in
@@ -69,16 +69,46 @@ REQUIRES	= \
 		$(NULL)
 
 
 CPPSRCS	= \
 	CanvasUtils.cpp \
 	nsCanvasRenderingContext2D.cpp \
 	$(NULL)
 
+# Canvas 3D Pieces
+
+ifdef MOZ_ENABLE_CANVAS3D
+
+CPPSRCS += \
+	nsCanvasRenderingContextGL.cpp \
+	nsCanvasRenderingContextGLWeb20.cpp \
+	glwrap.cpp \
+	nsGLPbuffer.cpp \
+	nsGLPbufferOSMesa.cpp \
+	$(NULL)
+
+ifdef MOZ_X11
+EXTRA_DSO_LIBS += X11
+CPPSRCS += nsGLPbufferGLX.cpp
+DEFINES += -DUSE_GLX
+endif
+
+ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
+CPPSRCS += nsGLPbufferWGL.cpp
+DEFINES += -DUSE_WGL
+endif
+
+ifneq (,$(filter $(MOZ_WIDGET_TOOLKIT),mac cocoa))
+CPPSRCS += nsGLPbufferCGL.cpp
+DEFINES += -DUSE_CGL
+endif
+
+endif
+
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS	+= $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
 
 INCLUDES	+= \
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/NativeJSContext.h
@@ -0,0 +1,390 @@
+#ifndef _NATIVEJSCONTEXT_H_
+#define _NATIVEJSCONTEXT_H_
+
+class JSObjectHelper;
+
+class NativeJSContext {
+public:
+    NativeJSContext() {
+        error = gXPConnect->GetCurrentNativeCallContext(&ncc);
+        if (NS_FAILED(error))
+            return;
+
+        if (!ncc) {
+            error = NS_ERROR_FAILURE;
+            return;
+        }
+
+        ctx = nsnull;
+
+        error = ncc->GetJSContext(&ctx);
+        if (NS_FAILED(error))
+            return;
+
+        JS_BeginRequest(ctx);
+
+        ncc->GetArgc(&argc);
+        ncc->GetArgvPtr(&argv);
+    }
+
+    ~NativeJSContext() {
+        JS_EndRequest(ctx);
+    }
+
+    PRBool CheckArray (JSObject *obj, jsuint *sz) {
+        if (obj &&
+            ::JS_IsArrayObject(ctx, obj) &&
+            ::JS_GetArrayLength(ctx, obj, sz))
+            return PR_TRUE;
+        return PR_FALSE;
+    }
+
+    PRBool CheckArray (jsval val, jsuint *sz) {
+        if (!JSVAL_IS_NULL(val) &&
+            JSVAL_IS_OBJECT(val) &&
+            ::JS_IsArrayObject(ctx, JSVAL_TO_OBJECT(val)) &&
+            ::JS_GetArrayLength(ctx, JSVAL_TO_OBJECT(val), sz))
+            return PR_TRUE;
+        return PR_FALSE;
+    }
+
+    PRBool AddGCRoot (void *aPtr, const char *aName) {
+        return JS_AddNamedRootRT(gScriptRuntime, aPtr, aName);
+    }
+
+    void ReleaseGCRoot (void *aPtr) {
+        JS_RemoveRootRT(gScriptRuntime, aPtr);
+    }
+
+    void SetRetVal (PRInt32 val) {
+        if (INT_FITS_IN_JSVAL(val))
+            SetRetValAsJSVal(INT_TO_JSVAL(val));
+        else
+            SetRetVal((double) val);
+    }
+
+    void SetRetVal (PRUint32 val) {
+        if (INT_FITS_IN_JSVAL(val))
+            SetRetValAsJSVal(INT_TO_JSVAL((int) val));
+        else
+            SetRetVal((double) val);
+    }
+
+    void SetRetVal (double val) {
+        jsval *vp;
+        ncc->GetRetValPtr(&vp);
+        JS_NewDoubleValue(ctx, val, vp);
+    }
+
+    void SetBoolRetVal (PRBool val) {
+        if (val)
+            SetRetValAsJSVal(JSVAL_TRUE);
+        else
+            SetRetValAsJSVal(JSVAL_FALSE);
+    }
+
+    void SetRetVal (PRInt32 *vp, PRUint32 len) {
+        nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
+
+        if (!JS_EnterLocalRootScope(ctx))
+            return; // XXX ???
+
+        for (PRUint32 i = 0; i < len; i++) {
+            if (INT_FITS_IN_JSVAL(vp[i])) {
+                jsvector[i] = INT_TO_JSVAL(vp[i]);
+            } else {
+                JS_NewDoubleValue(ctx, vp[i], &jsvector[i]);
+            }
+        }
+
+        JSObject *jsarr = JS_NewArrayObject(ctx, len, jsvector.get());
+        SetRetVal(jsarr);
+
+        JS_LeaveLocalRootScope(ctx);
+    }
+
+    void SetRetVal (PRUint32 *vp, PRUint32 len) {
+        nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
+
+        if (!JS_EnterLocalRootScope(ctx))
+            return; // XXX ???
+
+        for (PRUint32 i = 0; i < len; i++) {
+            JS_NewNumberValue(ctx, vp[i], &jsvector[i]);
+        }
+
+        JSObject *jsarr = JS_NewArrayObject(ctx, len, jsvector.get());
+        SetRetVal(jsarr);
+
+        JS_LeaveLocalRootScope(ctx);
+    }
+
+    void SetRetVal (double *dp, PRUint32 len) {
+        nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
+
+        if (!JS_EnterLocalRootScope(ctx))
+            return; // XXX ???
+
+        for (PRUint32 i = 0; i < len; i++)
+            JS_NewDoubleValue(ctx, (jsdouble) dp[i], &jsvector[i]);
+            
+        JSObject *jsarr = JS_NewArrayObject(ctx, len, jsvector.get());
+        SetRetVal(jsarr);
+
+        JS_LeaveLocalRootScope(ctx);
+    }
+
+    void SetRetVal (float *fp, PRUint32 len) {
+        nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
+
+        if (!JS_EnterLocalRootScope(ctx))
+            return; // XXX ???
+
+        for (PRUint32 i = 0; i < len; i++)
+            JS_NewDoubleValue(ctx, (jsdouble) fp[i], &jsvector[i]);
+        JSObject *jsarr = JS_NewArrayObject(ctx, len, jsvector.get());
+        SetRetVal(jsarr);
+
+        JS_LeaveLocalRootScope(ctx);
+    }
+
+    void SetRetValAsJSVal (jsval val) {
+        jsval *vp;
+        ncc->GetRetValPtr(&vp);
+        *vp = val;
+        ncc->SetReturnValueWasSet(PR_TRUE);
+    }
+
+    void SetRetVal (JSObject *obj) {
+        SetRetValAsJSVal(OBJECT_TO_JSVAL(obj));
+    }
+
+    void SetRetVal (JSObjectHelper& objh);
+
+    nsAXPCNativeCallContext *ncc;
+    nsresult error;
+    JSContext *ctx;
+    PRUint32 argc;
+    jsval *argv;
+
+public:
+    // static JS helpers
+
+    static inline PRBool JSValToFloatArray (JSContext *ctx, jsval val,
+                                            jsuint cnt, float *array)
+    {
+        JSObject *arrayObj;
+        jsuint arrayLen;
+        jsval jv;
+        jsdouble dv;
+
+        if (!::JS_ValueToObject(ctx, val, &arrayObj) ||
+            arrayObj == NULL ||
+            !::JS_IsArrayObject(ctx, arrayObj) ||
+            !::JS_GetArrayLength(ctx, arrayObj, &arrayLen) ||
+            (arrayLen < cnt))
+            return PR_FALSE;
+
+        for (jsuint i = 0; i < cnt; i++) {
+            ::JS_GetElement(ctx, arrayObj, i, &jv);
+            if (!::JS_ValueToNumber(ctx, jv, &dv))
+                return PR_FALSE;
+            array[i] = (float) dv;
+        }
+
+        return PR_TRUE;
+    }
+
+    static inline PRBool JSValToDoubleArray (JSContext *ctx, jsval val,
+                                             jsuint cnt, double *array)
+    {
+        JSObject *arrayObj;
+        jsuint arrayLen;
+        jsval jv;
+        jsdouble dv;
+
+        if (!::JS_ValueToObject(ctx, val, &arrayObj) ||
+            arrayObj == NULL ||
+            !::JS_IsArrayObject(ctx, arrayObj) ||
+            !::JS_GetArrayLength(ctx, arrayObj, &arrayLen) ||
+            (arrayLen < cnt))
+            return PR_FALSE;
+
+        for (jsuint i = 0; i < cnt; i++) {
+            ::JS_GetElement(ctx, arrayObj, i, &jv);
+            if (!::JS_ValueToNumber(ctx, jv, &dv))
+                return PR_FALSE;
+            array[i] = dv;
+        }
+
+        return PR_TRUE;
+    }
+
+    static inline PRBool JSValToJSArrayAndLength (JSContext *ctx, jsval val,
+                                                  JSObject **outObj, jsuint *outLen)
+    {
+        JSObject *obj = nsnull;
+        jsuint len;
+        if (!::JS_ValueToObject(ctx, val, &obj) ||
+            obj == NULL ||
+            !::JS_IsArrayObject(ctx, obj) ||
+            !::JS_GetArrayLength(ctx, obj, &len))
+        {
+            return PR_FALSE;
+        }
+
+        *outObj = obj;
+        *outLen = len;
+
+        return PR_TRUE;
+    }
+
+    template<class T>
+    static nsresult JSValToSpecificInterface(JSContext *ctx, jsval val, T **out)
+    {
+        if (JSVAL_IS_NULL(val)) {
+            *out = nsnull;
+            return NS_OK;
+        }
+
+        if (!JSVAL_IS_OBJECT(val))
+            return NS_ERROR_DOM_SYNTAX_ERR;
+
+        nsCOMPtr<nsISupports> isup;
+        nsresult rv = gXPConnect->WrapJS(ctx, JSVAL_TO_OBJECT(val),
+                                         NS_GET_IID(nsISupports),
+                                         getter_AddRefs(isup));
+        if (NS_FAILED(rv))
+            return NS_ERROR_DOM_SYNTAX_ERR;
+
+        nsCOMPtr<T> obj = do_QueryInterface(isup);
+        if (!obj)
+            return NS_ERROR_DOM_SYNTAX_ERR;
+
+        NS_ADDREF(*out = obj.get());
+        return NS_OK;
+    }
+
+    static inline JSObject *ArrayToJSArray (JSContext *ctx,
+                                            const PRInt32 *vals,
+                                            const PRUint32 len)
+    {
+        // XXX handle ints that are too big to fit
+        nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
+        for (PRUint32 i = 0; i < len; i++)
+            jsvector[i] = INT_TO_JSVAL(vals[i]);
+        return JS_NewArrayObject(ctx, len, jsvector);
+    }
+
+    static inline JSObject *ArrayToJSArray (JSContext *ctx,
+                                            const PRUint32 *vals,
+                                            const PRUint32 len)
+    {
+        // XXX handle ints that are too big to fit
+        nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
+        for (PRUint32 i = 0; i < len; i++)
+            jsvector[i] = INT_TO_JSVAL(vals[i]);
+        return JS_NewArrayObject(ctx, len, jsvector);
+    }
+
+};
+
+class JSObjectHelper {
+    friend class NativeJSContext;
+public:
+    JSObjectHelper(NativeJSContext *jsctx)
+        : mCtx (jsctx)
+    {
+        mObject = JS_NewObject(mCtx->ctx, NULL, NULL, NULL);
+        if (!mObject)
+            return;
+
+        if (!mCtx->AddGCRoot(&mObject, "JSObjectHelperCanvas3D"))
+            mObject = nsnull;
+    }
+
+    ~JSObjectHelper() {
+        if (mObject && mCtx)
+            mCtx->ReleaseGCRoot(&mObject);
+    }
+
+    PRBool DefineProperty(const char *name, PRInt32 val) {
+        // XXX handle too big ints
+        if (!JS_DefineProperty(mCtx->ctx, mObject, name, INT_TO_JSVAL(val), NULL, NULL, JSPROP_ENUMERATE))
+            return PR_FALSE;
+        return PR_TRUE;
+    }
+
+    PRBool DefineProperty(const char *name, PRUint32 val) {
+        // XXX handle too big ints
+        if (!JS_DefineProperty(mCtx->ctx, mObject, name, INT_TO_JSVAL((int)val), NULL, NULL, JSPROP_ENUMERATE))
+            return PR_FALSE;
+        return PR_TRUE;
+    }
+
+    PRBool DefineProperty(const char *name, double val) {
+        jsval dv;
+
+        if (!JS_NewDoubleValue(mCtx->ctx, val, &dv))
+            return PR_FALSE;
+
+        if (!JS_DefineProperty(mCtx->ctx, mObject, name, dv, NULL, NULL, JSPROP_ENUMERATE))
+            return PR_FALSE;
+        return PR_TRUE;
+    }
+
+    PRBool DefineProperty(const char *name, JSObject *val) {
+        if (!JS_DefineProperty(mCtx->ctx, mObject, name, OBJECT_TO_JSVAL(val), NULL, NULL, JSPROP_ENUMERATE))
+            return PR_FALSE;
+        return PR_TRUE;
+    }
+
+    // Blah.  We can't name this DefineProperty also because PRBool is the same as PRInt32
+    PRBool DefineBoolProperty(const char *name, PRBool val) {
+        if (!JS_DefineProperty(mCtx->ctx, mObject, name, val ? JS_TRUE : JS_FALSE, NULL, NULL, JSPROP_ENUMERATE))
+            return PR_FALSE;
+        return PR_TRUE;
+    }
+
+    // We can't use ns*Substring, because we don't have internal linkage
+#if 0
+    PRBool DefineProperty(const char *name, const nsCSubstring& val) {
+        JSString *jsstr = JS_NewStringCopyN(mCtx->ctx, val.BeginReading(), val.Length());
+        if (!jsstr ||
+            !JS_DefineProperty(mCtx->ctx, mObject, name, STRING_TO_JSVAL(jsstr), NULL, NULL, JSPROP_ENUMERATE))
+            return PR_FALSE;
+        return PR_TRUE;
+    }
+
+    PRBool DefineProperty(const char *name, const nsSubstring& val) {
+        JSString *jsstr = JS_NewUCStringCopyN(mCtx->ctx, val.BeginReading(), val.Length());
+        if (!jsstr ||
+            !JS_DefineProperty(mCtx->ctx, mObject, name, STRING_TO_JSVAL(jsstr), NULL, NULL, JSPROP_ENUMERATE))
+            return PR_FALSE;
+        return PR_TRUE;
+    }
+#endif
+
+    PRBool DefineProperty(const char *name, const char *val, PRUint32 len) {
+        JSString *jsstr = JS_NewStringCopyN(mCtx->ctx, val, len);
+        if (!jsstr ||
+            !JS_DefineProperty(mCtx->ctx, mObject, name, STRING_TO_JSVAL(jsstr), NULL, NULL, JSPROP_ENUMERATE))
+            return PR_FALSE;
+        return PR_TRUE;
+    }
+
+    JSObject *Object() {
+        return mObject;
+    }
+
+protected:
+    NativeJSContext *mCtx;
+    JSObject *mObject;
+};
+
+inline void
+NativeJSContext::SetRetVal(JSObjectHelper& objh) {
+    SetRetValAsJSVal(OBJECT_TO_JSVAL(objh.mObject));
+}
+
+#endif
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/glwrap.cpp
@@ -0,0 +1,298 @@
+#ifdef C3D_STANDALONE_BUILD
+#include "c3d-standalone.h"
+#endif
+
+#include <string.h>
+#include <stdio.h>
+
+#include "prlink.h"
+
+#include "glwrap.h"
+
+#define MAX_SYMBOL_LENGTH 128
+#define MAX_SYMBOL_NAMES 5
+
+#ifdef MOZ_X11
+#include <GL/glx.h>
+#endif
+
+bool
+LibrarySymbolLoader::OpenLibrary(const char *library)
+{
+    PRLibSpec lspec;
+    lspec.type = PR_LibSpec_Pathname;
+    lspec.value.pathname = library;
+
+    mLibrary = PR_LoadLibraryWithFlags(lspec, PR_LD_LAZY | PR_LD_LOCAL);
+    if (!mLibrary)
+        return false;
+
+    return true;
+}
+
+PRFuncPtr
+LibrarySymbolLoader::LookupSymbol(const char *sym, bool tryplatform)
+{
+    PRFuncPtr res = 0;
+
+    // try finding it in the library directly, if we have one
+    if (mLibrary) {
+        res = PR_FindFunctionSymbol(mLibrary, sym);
+    }
+
+    // try finding it in the process
+    if (!res) {
+        PRLibrary *leakedLibRef;
+        res = PR_FindFunctionSymbolAndLibrary(sym, &leakedLibRef);
+    }
+
+    // no? then try looking it up via the lookup symbol
+    if (!res && tryplatform && mLookupFunc) {
+        res = mLookupFunc (sym);
+    }
+
+    return res;
+}
+
+bool
+LibrarySymbolLoader::LoadSymbols(SymLoadStruct *firstStruct, bool tryplatform, const char *prefix)
+{
+    char sbuf[MAX_SYMBOL_LENGTH * 2];
+
+    SymLoadStruct *ss = firstStruct;
+    while (ss->symPointer) {
+        *ss->symPointer = 0;
+
+        for (int i = 0; i < MAX_SYMBOL_NAMES; i++) {
+            if (ss->symNames[i] == NULL)
+                break;
+
+            const char *s = ss->symNames[i];
+            if (prefix && *prefix != 0) {
+                strcpy(sbuf, prefix);
+                strcat(sbuf, ss->symNames[i]);
+                s = sbuf;
+            }
+
+            PRFuncPtr p = LookupSymbol(s, tryplatform);
+            if (p) {
+                *ss->symPointer = p;
+                break;
+            }
+        }
+
+        if (*ss->symPointer == 0) {
+            fprintf (stderr, "Can't find symbol '%s'\n", ss->symNames[0]);
+            return false;
+        }
+
+        ss++;
+    }
+
+    return true;
+}
+
+bool
+OSMesaWrap::Init()
+{
+    if (fCreateContextExt)
+        return true;
+
+    SymLoadStruct symbols[] = {
+        { (PRFuncPtr*) &fCreateContextExt, { "OSMesaCreateContextExt", NULL } },
+        { (PRFuncPtr*) &fMakeCurrent, { "OSMesaMakeCurrent", NULL } },
+        { (PRFuncPtr*) &fPixelStore, { "OSMesaPixelStore", NULL } },
+        { (PRFuncPtr*) &fDestroyContext, { "OSMesaDestroyContext", NULL } },
+        { (PRFuncPtr*) &fGetCurrentContext, { "OSMesaGetCurrentContext", NULL } },
+        { (PRFuncPtr*) &fMakeCurrent, { "OSMesaMakeCurrent", NULL } },
+        { (PRFuncPtr*) &fGetProcAddress, { "OSMesaGetProcAddress", NULL } },
+        { NULL, { NULL } }
+    };
+
+    return LoadSymbols(&symbols[0]);
+}
+
+bool
+GLES20Wrap::Init(NativeGLMode mode)
+{
+    if (mode & TRY_NATIVE_GL) {
+        if (InitNative())
+            return true;
+    }
+
+    if (mode & TRY_SOFTWARE_GL) {
+        if (InitSoftware())
+            return true;
+    }
+
+    return false;
+}
+
+bool
+GLES20Wrap::InitNative()
+{
+    return InitWithPrefix("gl", true);
+}
+
+bool
+GLES20Wrap::InitSoftware()
+{
+    return InitWithPrefix("mgl", true);
+}
+
+/*
+ * XXX - we should really know the ARB/EXT variants of these
+ * instead of only handling the symbol if it's exposed directly.
+ */
+
+bool
+GLES20Wrap::InitWithPrefix(const char *prefix, bool trygl)
+{
+    if (ok)
+        return true;
+
+    SymLoadStruct symbols[] = {
+        { (PRFuncPtr*) &fActiveTexture, { "ActiveTexture", "ActiveTextureARB", NULL } },
+        { (PRFuncPtr*) &fAttachShader, { "AttachShader", "AttachShaderARB", NULL } },
+        { (PRFuncPtr*) &fBindAttribLocation, { "BindAttribLocation", "BindAttribLocationARB", NULL } },
+        { (PRFuncPtr*) &fBindBuffer, { "BindBuffer", "BindBufferARB", NULL } },
+        { (PRFuncPtr*) &fBindTexture, { "BindTexture", "BindTextureARB", NULL } },
+        { (PRFuncPtr*) &fBlendColor, { "BlendColor", NULL } },
+        { (PRFuncPtr*) &fBlendEquation, { "BlendEquation", NULL } },
+        { (PRFuncPtr*) &fBlendEquationSeparate, { "BlendEquationSeparate", "BlendEquationSeparateEXT", NULL } },
+        { (PRFuncPtr*) &fBlendFunc, { "BlendFunc", NULL } },
+        { (PRFuncPtr*) &fBlendFuncSeparate, { "BlendFuncSeparate", "BlendFuncSeparateEXT", NULL } },
+        { (PRFuncPtr*) &fBufferData, { "BufferData", NULL } },
+        { (PRFuncPtr*) &fBufferSubData, { "BufferSubData", NULL } },
+        { (PRFuncPtr*) &fClear, { "Clear", NULL } },
+        { (PRFuncPtr*) &fClearColor, { "ClearColor", NULL } },
+        { (PRFuncPtr*) &fClearDepth, { "ClearDepth", NULL } },
+        { (PRFuncPtr*) &fClearStencil, { "ClearStencil", NULL } },
+        { (PRFuncPtr*) &fColorMask, { "ColorMask", NULL } },
+        { (PRFuncPtr*) &fCreateProgram, { "CreateProgram", "CreateProgramARB", NULL } },
+        { (PRFuncPtr*) &fCreateShader, { "CreateShader", "CreateShaderARB", NULL } },
+        { (PRFuncPtr*) &fCullFace, { "CullFace", NULL } },
+        { (PRFuncPtr*) &fDeleteBuffers, { "DeleteBuffers", "DeleteBuffersARB", NULL } },
+        { (PRFuncPtr*) &fDeleteTextures, { "DeleteTextures", "DeleteTexturesARB", NULL } },
+        { (PRFuncPtr*) &fDeleteProgram, { "DeleteProgram", "DeleteProgramARB", NULL } },
+        { (PRFuncPtr*) &fDeleteShader, { "DeleteShader", "DeleteShaderARB", NULL } },
+        { (PRFuncPtr*) &fDetachShader, { "DetachShader", "DetachShaderARB", NULL } },
+        { (PRFuncPtr*) &fDepthFunc, { "DepthFunc", NULL } },
+        { (PRFuncPtr*) &fDepthMask, { "DepthMask", NULL } },
+        { (PRFuncPtr*) &fDepthRange, { "DepthRange", NULL } },
+        { (PRFuncPtr*) &fDisable, { "Disable", NULL } },
+        { (PRFuncPtr*) &fDisableVertexAttribArray, { "DisableVertexAttribArray", "DisableVertexAttribArrayARB", NULL } },
+        { (PRFuncPtr*) &fDrawArrays, { "DrawArrays", NULL } },
+        { (PRFuncPtr*) &fDrawElements, { "DrawElements", NULL } },
+        { (PRFuncPtr*) &fEnable, { "Enable", NULL } },
+        { (PRFuncPtr*) &fEnableVertexAttribArray, { "EnableVertexAttribArray", "EnableVertexAttribArrayARB", NULL } },
+        { (PRFuncPtr*) &fFinish, { "Finish", NULL } },
+        { (PRFuncPtr*) &fFlush, { "Flush", NULL } },
+        { (PRFuncPtr*) &fFrontFace, { "FrontFace", NULL } },
+        { (PRFuncPtr*) &fGetActiveAttrib, { "GetActiveAttrib", "GetActiveAttribARB", NULL } },
+        { (PRFuncPtr*) &fGetActiveUniform, { "GetActiveUniform", "GetActiveUniformARB", NULL } },
+        { (PRFuncPtr*) &fGetAttachedShaders, { "GetAttachedShaders", "GetAttachedShadersARB", NULL } },
+        { (PRFuncPtr*) &fGetAttribLocation, { "GetAttribLocation", "GetAttribLocationARB", NULL } },
+        { (PRFuncPtr*) &fGetIntegerv, { "GetIntegerv", NULL } },
+        { (PRFuncPtr*) &fGetDoublev, { "GetDoublev", NULL } },
+        { (PRFuncPtr*) &fGetFloatv, { "GetFloatv", NULL } },
+        { (PRFuncPtr*) &fGetBooleanv, { "GetBooleanv", NULL } },
+        { (PRFuncPtr*) &fGetBufferParameteriv, { "GetBufferParameteriv", "GetBufferParameterivARB", NULL } },
+        { (PRFuncPtr*) &fGenBuffers, { "GenBuffers", "GenBuffersARB", NULL } },
+        { (PRFuncPtr*) &fGenTextures, { "GenTextures", NULL } },
+        { (PRFuncPtr*) &fGetError, { "GetError", NULL } },
+        { (PRFuncPtr*) &fGetProgramiv, { "GetProgramiv", "GetProgramivARB", NULL } },
+        { (PRFuncPtr*) &fGetProgramInfoLog, { "GetProgramInfoLog", "GetProgramInfoLogARB", NULL } },
+        { (PRFuncPtr*) &fTexParameteri, { "TexParameteri", NULL } },
+        { (PRFuncPtr*) &fTexParameterf, { "TexParameterf", NULL } },
+        { (PRFuncPtr*) &fGetTexParameteriv, { "GetTexParameteriv", NULL } },
+        { (PRFuncPtr*) &fGetUniformfv, { "GetUniformfv", "GetUniformfvARB", NULL } },
+        { (PRFuncPtr*) &fGetUniformiv, { "GetUniformiv", "GetUniformivARB", NULL } },
+        { (PRFuncPtr*) &fGetUniformLocation, { "GetUniformLocation", "GetUniformLocationARB", NULL } },
+        { (PRFuncPtr*) &fGetVertexAttribdv, { "GetVertexAttribdv", "GetVertexAttribdvARB", NULL } },
+        { (PRFuncPtr*) &fGetVertexAttribfv, { "GetVertexAttribfv", "GetVertexAttribfvARB", NULL } },
+        { (PRFuncPtr*) &fGetVertexAttribiv, { "GetVertexAttribiv", "GetVertexAttribivARB", NULL } },
+        { (PRFuncPtr*) &fHint, { "Hint", NULL } },
+        { (PRFuncPtr*) &fIsBuffer, { "IsBuffer", "IsBufferARB", NULL } },
+        { (PRFuncPtr*) &fIsEnabled, { "IsEnabled", NULL } },
+        { (PRFuncPtr*) &fIsProgram, { "IsProgram", "IsProgramARB", NULL } },
+        { (PRFuncPtr*) &fIsShader, { "IsShader", "IsShaderARB", NULL } },
+        { (PRFuncPtr*) &fIsTexture, { "IsTexture", "IsTextureARB", NULL } },
+        { (PRFuncPtr*) &fLineWidth, { "LineWidth", NULL } },
+        { (PRFuncPtr*) &fLinkProgram, { "LinkProgram", "LinkProgramARB", NULL } },
+        { (PRFuncPtr*) &fPixelStorei, { "PixelStorei", NULL } },
+        { (PRFuncPtr*) &fPolygonOffset, { "PolygonOffset", NULL } },
+        { (PRFuncPtr*) &fReadPixels, { "ReadPixels", NULL } },
+        { (PRFuncPtr*) &fSampleCoverage, { "SampleCoverage", NULL } },
+        { (PRFuncPtr*) &fScissor, { "Scissor", NULL } },
+        { (PRFuncPtr*) &fStencilFunc, { "StencilFunc", NULL } },
+        { (PRFuncPtr*) &fStencilFuncSeparate, { "StencilFuncSeparate", "StencilFuncSeparateEXT", NULL } },
+        { (PRFuncPtr*) &fStencilMask, { "StencilMask", NULL } },
+        { (PRFuncPtr*) &fStencilMaskSeparate, { "StencilMaskSeparate", "StencilMaskSeparateEXT", NULL } },
+        { (PRFuncPtr*) &fStencilOp, { "StencilOp", NULL } },
+        { (PRFuncPtr*) &fStencilOpSeparate, { "StencilOpSeparate", "StencilOpSeparateEXT", NULL } },
+        { (PRFuncPtr*) &fTexImage2D, { "TexImage2D", NULL } },
+        { (PRFuncPtr*) &fTexSubImage2D, { "TexSubImage2D", NULL } },
+        { (PRFuncPtr*) &fUniform1f, { "Uniform1f", NULL } },
+        { (PRFuncPtr*) &fUniform1fv, { "Uniform1fv", NULL } },
+        { (PRFuncPtr*) &fUniform1i, { "Uniform1i", NULL } },
+        { (PRFuncPtr*) &fUniform1iv, { "Uniform1iv", NULL } },
+        { (PRFuncPtr*) &fUniform2f, { "Uniform2f", NULL } },
+        { (PRFuncPtr*) &fUniform2fv, { "Uniform2fv", NULL } },
+        { (PRFuncPtr*) &fUniform2i, { "Uniform2i", NULL } },
+        { (PRFuncPtr*) &fUniform2iv, { "Uniform2iv", NULL } },
+        { (PRFuncPtr*) &fUniform3f, { "Uniform3f", NULL } },
+        { (PRFuncPtr*) &fUniform3fv, { "Uniform3fv", NULL } },
+        { (PRFuncPtr*) &fUniform3i, { "Uniform3i", NULL } },
+        { (PRFuncPtr*) &fUniform3iv, { "Uniform3iv", NULL } },
+        { (PRFuncPtr*) &fUniform4f, { "Uniform4f", NULL } },
+        { (PRFuncPtr*) &fUniform4fv, { "Uniform4fv", NULL } },
+        { (PRFuncPtr*) &fUniform4i, { "Uniform4i", NULL } },
+        { (PRFuncPtr*) &fUniform4iv, { "Uniform4iv", NULL } },
+        { (PRFuncPtr*) &fUniformMatrix2fv, { "UniformMatrix2fv", NULL } },
+        { (PRFuncPtr*) &fUniformMatrix3fv, { "UniformMatrix3fv", NULL } },
+        { (PRFuncPtr*) &fUniformMatrix4fv, { "UniformMatrix4fv", NULL } },
+        { (PRFuncPtr*) &fUseProgram, { "UseProgram", NULL } },
+        { (PRFuncPtr*) &fValidateProgram, { "ValidateProgram", NULL } },
+        { (PRFuncPtr*) &fVertexAttribPointer, { "VertexAttribPointer", NULL } },
+        { (PRFuncPtr*) &fVertexAttrib1f, { "VertexAttrib1f", NULL } },
+        { (PRFuncPtr*) &fVertexAttrib2f, { "VertexAttrib2f", NULL } },
+        { (PRFuncPtr*) &fVertexAttrib3f, { "VertexAttrib3f", NULL } },
+        { (PRFuncPtr*) &fVertexAttrib4f, { "VertexAttrib4f", NULL } },
+        { (PRFuncPtr*) &fVertexAttrib1fv, { "VertexAttrib1fv", NULL } },
+        { (PRFuncPtr*) &fVertexAttrib2fv, { "VertexAttrib2fv", NULL } },
+        { (PRFuncPtr*) &fVertexAttrib3fv, { "VertexAttrib3fv", NULL } },
+        { (PRFuncPtr*) &fVertexAttrib4fv, { "VertexAttrib4fv", NULL } },
+        { (PRFuncPtr*) &fViewport, { "Viewport", NULL } },
+        { (PRFuncPtr*) &fCompileShader, { "CompileShader", NULL } },
+        { (PRFuncPtr*) &fCopyTexImage2D, { "CopyTexImage2D", NULL } },
+        { (PRFuncPtr*) &fCopyTexSubImage2D, { "CopyTexSubImage2D", NULL } },
+        { (PRFuncPtr*) &fGetShaderiv, { "GetShaderiv", NULL } },
+        { (PRFuncPtr*) &fGetShaderInfoLog, { "GetShaderInfoLog", NULL } },
+        { (PRFuncPtr*) &fGetShaderSource, { "GetShaderSource", NULL } },
+        { (PRFuncPtr*) &fShaderSource, { "ShaderSource", NULL } },
+        { (PRFuncPtr*) &fVertexAttribPointer, { "VertexAttribPointer", NULL } },
+        { (PRFuncPtr*) &fBindFramebuffer, { "BindFramebuffer", "BindFramebufferEXT", NULL } },
+        { (PRFuncPtr*) &fBindRenderbuffer, { "BindRenderbuffer", "BindRenderbufferEXT", NULL } },
+        { (PRFuncPtr*) &fCheckFramebufferStatus, { "CheckFramebufferStatus", "CheckFramebufferStatusEXT", NULL } },
+        { (PRFuncPtr*) &fDeleteFramebuffers, { "DeleteFramebuffers", "DeleteFramebuffersEXT", NULL } },
+        { (PRFuncPtr*) &fDeleteRenderbuffers, { "DeleteRenderbuffers", "DeleteRenderbuffersEXT", NULL } },
+        { (PRFuncPtr*) &fFramebufferRenderbuffer, { "FramebufferRenderbuffer", "FramebufferRenderbufferEXT", NULL } },
+        { (PRFuncPtr*) &fFramebufferTexture2D, { "FramebufferTexture2D", "FramebufferTexture2DEXT", NULL } },
+        { (PRFuncPtr*) &fGenerateMipmap, { "GenerateMipmap", "GenerateMipmapEXT", NULL } },
+        { (PRFuncPtr*) &fGenFramebuffers, { "GenFramebuffers", "GenFramebuffersEXT", NULL } },
+        { (PRFuncPtr*) &fGenRenderbuffers, { "GenRenderbuffers", "GenRenderbuffersEXT", NULL } },
+        { (PRFuncPtr*) &fGetFramebufferAttachmentParameteriv, { "GetFramebufferAttachmentParameteriv", "GetFramebufferAttachmentParameterivEXT", NULL } },
+        { (PRFuncPtr*) &fGetRenderbufferParameteriv, { "GetRenderbufferParameteriv", "GetRenderbufferParameterivEXT", NULL } },
+        { (PRFuncPtr*) &fIsFramebuffer, { "IsFramebuffer", "IsFramebufferEXT", NULL } },
+        { (PRFuncPtr*) &fIsRenderbuffer, { "IsRenderbuffer", "IsRenderbufferEXT", NULL } },
+        { (PRFuncPtr*) &fRenderbufferStorage, { "RenderbufferStorage", "RenderbufferStorageEXT", NULL } },
+
+        { NULL, { NULL } },
+
+    };
+
+    ok = LoadSymbols(&symbols[0], trygl, prefix);
+
+    return ok;
+}
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/glwrap.h
@@ -0,0 +1,388 @@
+
+#ifndef GLWRAP_H_
+#define GLWRAP_H_
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#include "localgl.h"
+
+#include "prlink.h"
+
+#ifndef GLAPIENTRY
+#ifdef XP_WIN
+#define GLAPIENTRY __stdcall
+#else
+#define GLAPIENTRY
+#endif
+#define GLAPI
+#endif
+
+class LibrarySymbolLoader
+{
+public:
+    bool OpenLibrary(const char *library);
+
+    typedef PRFuncPtr (GLAPIENTRY * PlatformLookupFunction) (const char *);
+    void SetLookupFunc(PlatformLookupFunction plf) {
+        mLookupFunc = plf;
+    }
+
+    enum {
+        MAX_SYMBOL_NAMES = 5,
+        MAX_SYMBOL_LENGTH = 128
+    };
+
+    typedef struct {
+        PRFuncPtr *symPointer;
+        const char *symNames[MAX_SYMBOL_NAMES];
+    } SymLoadStruct;
+
+    PRFuncPtr LookupSymbol(const char *symname, bool tryplatform = false);
+    bool LoadSymbols(SymLoadStruct *firstStruct, bool tryplatform = false, const char *prefix = NULL);
+
+protected:
+    LibrarySymbolLoader() {
+        mLibrary = NULL;
+        mLookupFunc = NULL;
+    }
+
+    PRLibrary *mLibrary;
+    PlatformLookupFunction mLookupFunc;
+};
+
+typedef void *PrivateOSMesaContext;
+
+class OSMesaWrap
+    : public LibrarySymbolLoader
+{
+public:
+    OSMesaWrap() : fCreateContextExt(0) { }
+
+    bool Init();
+
+protected:
+
+    //
+    // the wrapped functions
+    //
+public:
+    typedef PrivateOSMesaContext (GLAPIENTRY * PFNOSMESACREATECONTEXTEXT) (GLenum, GLint, GLint, GLint, PrivateOSMesaContext);
+    typedef void (GLAPIENTRY * PFNOSMESADESTROYCONTEXT) (PrivateOSMesaContext);
+    typedef GLboolean (GLAPIENTRY * PFNOSMESAMAKECURRENT) (PrivateOSMesaContext, void *, GLenum, GLsizei, GLsizei);
+    typedef PrivateOSMesaContext (GLAPIENTRY * PFNOSMESAGETCURRENTCONTEXT) (void);
+    typedef void (GLAPIENTRY * PFNOSMESAPIXELSTORE) (GLint, GLint);
+    typedef PRFuncPtr (GLAPIENTRY * PFNOSMESAGETPROCADDRESS) (const char*);
+
+    PFNOSMESACREATECONTEXTEXT fCreateContextExt;
+    PFNOSMESADESTROYCONTEXT fDestroyContext;
+    PFNOSMESAMAKECURRENT fMakeCurrent;
+    PFNOSMESAGETCURRENTCONTEXT fGetCurrentContext;
+    PFNOSMESAPIXELSTORE fPixelStore;
+    PFNOSMESAGETPROCADDRESS fGetProcAddress;
+};
+
+class GLES20Wrap
+    : public LibrarySymbolLoader
+{
+public:
+    enum NativeGLMode {
+        TRY_NATIVE_GL = 1 << 0,
+        TRY_SOFTWARE_GL = 1 << 1
+    };
+
+    GLES20Wrap() : ok(false) { }
+
+    bool Init(NativeGLMode mode);
+
+protected:
+
+    bool ok;
+
+    bool InitNative();
+    bool InitSoftware();
+
+    bool InitWithPrefix(const char *prefix, bool trygl );
+
+    //
+    // the wrapped functions
+    //
+public:
+    /* One would think that this would live in some nice perl-or-python-or-js script somewhere and would be autogenerated;
+     * one would be wrong.
+     */
+    typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture);
+    PFNGLACTIVETEXTUREPROC fActiveTexture;
+    typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
+    PFNGLATTACHSHADERPROC fAttachShader;
+    typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name);
+    PFNGLBINDATTRIBLOCATIONPROC fBindAttribLocation;
+    typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
+    PFNGLBINDBUFFERPROC fBindBuffer;
+    typedef void (GLAPIENTRY * PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture);
+    PFNGLBINDTEXTUREPROC fBindTexture;
+    typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+    PFNGLBLENDCOLORPROC fBlendColor;
+    typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode);
+    PFNGLBLENDEQUATIONPROC fBlendEquation;
+    typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum);
+    PFNGLBLENDEQUATIONSEPARATEPROC fBlendEquationSeparate;
+    typedef void (GLAPIENTRY * PFNGLBLENDFUNCPROC) (GLenum, GLenum);
+    PFNGLBLENDFUNCPROC fBlendFunc;
+    typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+    PFNGLBLENDFUNCSEPARATEPROC fBlendFuncSeparate;
+    typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
+    PFNGLBUFFERDATAPROC fBufferData;
+    typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+    PFNGLBUFFERSUBDATAPROC fBufferSubData;
+    typedef void (GLAPIENTRY * PFNGLCLEARPROC) (GLbitfield);
+    PFNGLCLEARPROC fClear;
+    typedef void (GLAPIENTRY * PFNGLCLEARCOLORPROC) (GLclampf, GLclampf, GLclampf, GLclampf);
+    PFNGLCLEARCOLORPROC fClearColor;
+    typedef void (GLAPIENTRY * PFNGLCLEARDEPTHPROC) (GLclampd);
+    PFNGLCLEARDEPTHPROC fClearDepth;
+    typedef void (GLAPIENTRY * PFNGLCLEARSTENCILPROC) (GLint);
+    PFNGLCLEARSTENCILPROC fClearStencil;
+    typedef void (GLAPIENTRY * PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+    PFNGLCOLORMASKPROC fColorMask;
+    typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void);
+    PFNGLCREATEPROGRAMPROC fCreateProgram;
+    typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type);
+    PFNGLCREATESHADERPROC fCreateShader;
+    typedef void (GLAPIENTRY * PFNGLCULLFACEPROC) (GLenum mode);
+    PFNGLCULLFACEPROC fCullFace;
+    typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers);
+    PFNGLDELETEBUFFERSPROC fDeleteBuffers;
+    typedef void (GLAPIENTRY * PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint* textures);
+    PFNGLDELETETEXTURESPROC fDeleteTextures;
+    typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program);
+    PFNGLDELETEPROGRAMPROC fDeleteProgram;
+    typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader);
+    PFNGLDELETESHADERPROC fDeleteShader;
+    typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
+    PFNGLDETACHSHADERPROC fDetachShader;
+    typedef void (GLAPIENTRY * PFNGLDEPTHFUNCPROC) (GLenum);
+    PFNGLDEPTHFUNCPROC fDepthFunc;
+    typedef void (GLAPIENTRY * PFNGLDEPTHMASKPROC) (GLboolean);
+    PFNGLDEPTHMASKPROC fDepthMask;
+    typedef void (GLAPIENTRY * PFNGLDEPTHRANGEPROC) (GLclampd, GLclampd);
+    PFNGLDEPTHRANGEPROC fDepthRange;
+    typedef void (GLAPIENTRY * PFNGLDISABLEPROC) (GLenum);
+    PFNGLDISABLEPROC fDisable;
+    typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
+    PFNGLDISABLEVERTEXATTRIBARRAYPROC fDisableVertexAttribArray;
+    typedef void (GLAPIENTRY * PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count);
+    PFNGLDRAWARRAYSPROC fDrawArrays;
+    typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+    PFNGLDRAWELEMENTSPROC fDrawElements;
+    typedef void (GLAPIENTRY * PFNGLENABLEPROC) (GLenum);
+    PFNGLENABLEPROC fEnable;
+    typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint);
+    PFNGLENABLEVERTEXATTRIBARRAYPROC fEnableVertexAttribArray;
+    typedef void (GLAPIENTRY * PFNGLFINISHPROC) (void);
+    PFNGLFINISHPROC fFinish;
+    typedef void (GLAPIENTRY * PFNGLFLUSHPROC) (void);
+    PFNGLFLUSHPROC fFlush;
+    typedef void (GLAPIENTRY * PFNGLFRONTFACEPROC) (GLenum);
+    PFNGLFRONTFACEPROC fFrontFace;
+    typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+    PFNGLGETACTIVEATTRIBPROC fGetActiveAttrib;
+    typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+    PFNGLGETACTIVEUNIFORMPROC fGetActiveUniform;
+    typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders);
+    PFNGLGETATTACHEDSHADERSPROC fGetAttachedShaders;
+    typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name);
+    PFNGLGETATTRIBLOCATIONPROC fGetAttribLocation;
+    typedef void (GLAPIENTRY * PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
+    PFNGLGETINTEGERVPROC fGetIntegerv;
+    typedef void (GLAPIENTRY * PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *params);
+    PFNGLGETDOUBLEVPROC fGetDoublev;
+    typedef void (GLAPIENTRY * PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params);
+    PFNGLGETFLOATVPROC fGetFloatv;
+    typedef void (GLAPIENTRY * PFNGLGETBOOLEANBPROC) (GLenum pname, GLboolean *params);
+    PFNGLGETBOOLEANBPROC fGetBooleanv;
+    typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);
+    PFNGLGETBUFFERPARAMETERIVPROC fGetBufferParameteriv;
+    typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers);
+    PFNGLGENBUFFERSPROC fGenBuffers;
+    typedef void (GLAPIENTRY * PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
+    PFNGLGENTEXTURESPROC fGenTextures;
+    typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target);
+    PFNGLGENERATEMIPMAPPROC fGenerateMipmap;
+    typedef GLenum (GLAPIENTRY * PFNGLGETERRORPROC) (void);
+    PFNGLGETERRORPROC fGetError;
+    typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param);
+    PFNGLGETPROGRAMIVPROC fGetProgramiv;
+    typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
+    PFNGLGETPROGRAMINFOLOGPROC fGetProgramInfoLog;
+    typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
+    PFNGLTEXPARAMETERIPROC fTexParameteri;
+    typedef void (GLAPIENTRY * PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param);
+    PFNGLTEXPARAMETERFPROC fTexParameterf;
+    typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+    PFNGLTEXPARAMETERIVPROC fGetTexParameteriv;
+    typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params);
+    PFNGLGETUNIFORMFVPROC fGetUniformfv;
+    typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params);
+    PFNGLGETUNIFORMIVPROC fGetUniformiv;
+    typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLint programObj, const GLchar* name);
+    PFNGLGETUNIFORMLOCATIONPROC fGetUniformLocation;
+    typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*);
+    PFNGLGETVERTEXATTRIBDVPROC fGetVertexAttribdv;
+    typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*);
+    PFNGLGETVERTEXATTRIBFVPROC fGetVertexAttribfv;
+    typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*);
+    PFNGLGETVERTEXATTRIBIVPROC fGetVertexAttribiv;
+    typedef void (GLAPIENTRY * PFNGLHINTPROC) (GLenum target, GLenum mode);
+    PFNGLHINTPROC fHint;
+    typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer);
+    PFNGLISBUFFERPROC fIsBuffer;
+    typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDPROC) (GLenum cap);
+    PFNGLISENABLEDPROC fIsEnabled;
+    typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program);
+    PFNGLISPROGRAMPROC fIsProgram;
+    typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader);
+    PFNGLISSHADERPROC fIsShader;
+    typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREPROC) (GLuint texture);
+    PFNGLISTEXTUREPROC fIsTexture;
+    typedef void (GLAPIENTRY * PFNGLLINEWIDTHPROC) (GLfloat width);
+    PFNGLLINEWIDTHPROC fLineWidth;
+    typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program);
+    PFNGLLINKPROGRAMPROC fLinkProgram;
+    typedef void (GLAPIENTRY * PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
+    PFNGLPIXELSTOREIPROC fPixelStorei;
+    typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat bias);
+    PFNGLPOLYGONOFFSETPROC fPolygonOffset;
+    typedef void (GLAPIENTRY * PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+    PFNGLREADPIXELSPROC fReadPixels;
+    typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
+    PFNGLSAMPLECOVERAGEPROC fSampleCoverage;
+    typedef void (GLAPIENTRY * PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
+    PFNGLSCISSORPROC fScissor;
+    typedef void (GLAPIENTRY * PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask);
+    PFNGLSTENCILFUNCPROC fStencilFunc;
+    typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+    PFNGLSTENCILFUNCSEPARATEPROC fStencilFuncSeparate;
+    typedef void (GLAPIENTRY * PFNGLSTENCILMASKPROC) (GLuint mask);
+    PFNGLSTENCILMASKPROC fStencilMask;
+    typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint);
+    PFNGLSTENCILMASKSEPARATEPROC fStencilMaskSeparate;
+    typedef void (GLAPIENTRY * PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass);
+    PFNGLSTENCILOPPROC fStencilOp;
+    typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+    PFNGLSTENCILOPSEPARATEPROC fStencilOpSeparate;
+    typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+    PFNGLTEXIMAGE2DPROC fTexImage2D;
+    typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
+    PFNGLTEXSUBIMAGE2DPROC fTexSubImage2D;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
+    PFNGLUNIFORM1FPROC fUniform1f;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value);
+    PFNGLUNIFORM1FVPROC fUniform1fv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
+    PFNGLUNIFORM1IPROC fUniform1i;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value);
+    PFNGLUNIFORM1IVPROC fUniform1iv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
+    PFNGLUNIFORM2FPROC fUniform2f;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value);
+    PFNGLUNIFORM2FVPROC fUniform2fv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
+    PFNGLUNIFORM2IPROC fUniform2i;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value);
+    PFNGLUNIFORM2IVPROC fUniform2iv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+    PFNGLUNIFORM3FPROC fUniform3f;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value);
+    PFNGLUNIFORM3FVPROC fUniform3fv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+    PFNGLUNIFORM3IPROC fUniform3i;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value);
+    PFNGLUNIFORM3IVPROC fUniform3iv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+    PFNGLUNIFORM4FPROC fUniform4f;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value);
+    PFNGLUNIFORM4FVPROC fUniform4fv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+    PFNGLUNIFORM4IPROC fUniform4i;
+    typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value);
+    PFNGLUNIFORM4IVPROC fUniform4iv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    PFNGLUNIFORMMATRIX2FVPROC fUniformMatrix2fv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    PFNGLUNIFORMMATRIX3FVPROC fUniformMatrix3fv;
+    typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    PFNGLUNIFORMMATRIX4FVPROC fUniformMatrix4fv;
+    typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program);
+    PFNGLUSEPROGRAMPROC fUseProgram;
+    typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program);
+    PFNGLVALIDATEPROGRAMPROC fValidateProgram;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);
+    PFNGLVERTEXATTRIBPOINTERPROC fVertexAttribPointer;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
+    PFNGLVERTEXATTRIB1FPROC fVertexAttrib1f;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
+    PFNGLVERTEXATTRIB2FPROC fVertexAttrib2f;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+    PFNGLVERTEXATTRIB3FPROC fVertexAttrib3f;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+    PFNGLVERTEXATTRIB4FPROC fVertexAttrib4f;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v);
+    PFNGLVERTEXATTRIB1FVPROC fVertexAttrib1fv;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v);
+    PFNGLVERTEXATTRIB2FVPROC fVertexAttrib2fv;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v);
+    PFNGLVERTEXATTRIB3FVPROC fVertexAttrib3fv;
+    typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v);
+    PFNGLVERTEXATTRIB4FVPROC fVertexAttrib4fv;
+    typedef void (GLAPIENTRY * PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
+    PFNGLVIEWPORTPROC fViewport;
+    typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader);
+    PFNGLCOMPILESHADERPROC fCompileShader;
+    typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+    PFNGLCOPYTEXIMAGE2DPROC fCopyTexImage2D;
+    typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+    PFNGLCOPYTEXSUBIMAGE2DPROC fCopyTexSubImage2D;
+    typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param);
+    PFNGLGETSHADERIVPROC fGetShaderiv;
+    typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
+    PFNGLGETSHADERINFOLOGPROC fGetShaderInfoLog;
+    typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source);
+    PFNGLGETSHADERSOURCEPROC fGetShaderSource;
+    typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths);
+    PFNGLSHADERSOURCEPROC fShaderSource;
+
+    typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFER) (GLenum target, GLuint framebuffer);
+    PFNGLBINDFRAMEBUFFER fBindFramebuffer;
+    typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFER) (GLenum target, GLuint renderbuffer);
+    PFNGLBINDRENDERBUFFER fBindRenderbuffer;
+    typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUS) (GLenum target);
+    PFNGLCHECKFRAMEBUFFERSTATUS fCheckFramebufferStatus;
+    typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERS) (GLsizei n, const GLuint* ids);
+    PFNGLDELETEFRAMEBUFFERS fDeleteFramebuffers;
+    typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERS) (GLsizei n, const GLuint* ids);
+    PFNGLDELETERENDERBUFFERS fDeleteRenderbuffers;
+    typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFER) (GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer);
+    PFNGLFRAMEBUFFERRENDERBUFFER fFramebufferRenderbuffer;
+    typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2D) (GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint texture, GLint level);
+    PFNGLFRAMEBUFFERTEXTURE2D fFramebufferTexture2D;
+    typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIV) (GLenum target, GLenum attachment, GLenum pname, GLint* value);
+    PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIV fGetFramebufferAttachmentParameteriv;
+    typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIV) (GLenum target, GLenum pname, GLint* value);
+    PFNGLGETRENDERBUFFERPARAMETERIV fGetRenderbufferParameteriv;
+    typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERS) (GLsizei n, GLuint* ids);
+    PFNGLGENFRAMEBUFFERS fGenFramebuffers;
+    typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERS) (GLsizei n, GLuint* ids);
+    PFNGLGENRENDERBUFFERS fGenRenderbuffers;
+    typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFER) (GLuint framebuffer);
+    PFNGLISFRAMEBUFFER fIsFramebuffer;
+    typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFER) (GLuint renderbuffer);
+    PFNGLISRENDERBUFFER fIsRenderbuffer;
+    typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGE) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
+    PFNGLRENDERBUFFERSTORAGE fRenderbufferStorage;
+
+};
+
+
+#endif
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/localgl.h
@@ -0,0 +1,3051 @@
+
+#if !defined(LOCALGL_H_) && !defined(__gl_h_)
+
+#define LOCALGL_H_
+#define __gl_h_
+
+#if defined(__APPLE__)
+typedef unsigned long GLenum;
+typedef unsigned long GLbitfield;
+typedef unsigned long GLuint;
+typedef long GLint;
+typedef long GLsizei;
+#else
+typedef unsigned int GLenum;
+typedef unsigned int GLbitfield;
+typedef unsigned int GLuint;
+typedef int GLint;
+typedef int GLsizei;
+#endif
+typedef unsigned char GLboolean;
+typedef signed char GLbyte;
+typedef short GLshort;
+typedef unsigned char GLubyte;
+typedef unsigned short GLushort;
+typedef float GLfloat;
+typedef float GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void GLvoid;
+
+typedef char GLchar;
+typedef ptrdiff_t GLsizeiptr;
+typedef ptrdiff_t GLintptr;
+
+#ifndef GLAPIENTRY
+# ifdef WIN32
+#  define GLAPIENTRY APIENTRY
+#  define GLAPI
+# else
+#  define GLAPIENTRY
+#  define GLAPI
+# endif
+#endif
+
+#define GL_VERSION_1_1 1
+#define GL_ACCUM 0x0100
+#define GL_LOAD 0x0101
+#define GL_RETURN 0x0102
+#define GL_MULT 0x0103
+#define GL_ADD 0x0104
+#define GL_NEVER 0x0200
+#define GL_LESS 0x0201
+#define GL_EQUAL 0x0202
+#define GL_LEQUAL 0x0203
+#define GL_GREATER 0x0204
+#define GL_NOTEQUAL 0x0205
+#define GL_GEQUAL 0x0206
+#define GL_ALWAYS 0x0207
+#define GL_CURRENT_BIT 0x00000001
+#define GL_POINT_BIT 0x00000002
+#define GL_LINE_BIT 0x00000004
+#define GL_POLYGON_BIT 0x00000008
+#define GL_POLYGON_STIPPLE_BIT 0x00000010
+#define GL_PIXEL_MODE_BIT 0x00000020
+#define GL_LIGHTING_BIT 0x00000040
+#define GL_FOG_BIT 0x00000080
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_ACCUM_BUFFER_BIT 0x00000200
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_VIEWPORT_BIT 0x00000800
+#define GL_TRANSFORM_BIT 0x00001000
+#define GL_ENABLE_BIT 0x00002000
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_HINT_BIT 0x00008000
+#define GL_EVAL_BIT 0x00010000
+#define GL_LIST_BIT 0x00020000
+#define GL_TEXTURE_BIT 0x00040000
+#define GL_SCISSOR_BIT 0x00080000
+#define GL_ALL_ATTRIB_BITS 0x000fffff
+#define GL_POINTS 0x0000
+#define GL_LINES 0x0001
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_QUADS 0x0007
+#define GL_QUAD_STRIP 0x0008
+#define GL_POLYGON 0x0009
+#define GL_ZERO 0
+#define GL_ONE 1
+#define GL_SRC_COLOR 0x0300
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DST_ALPHA 0x0304
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_DST_COLOR 0x0306
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#define GL_TRUE 1
+#define GL_FALSE 0
+#define GL_CLIP_PLANE0 0x3000
+#define GL_CLIP_PLANE1 0x3001
+#define GL_CLIP_PLANE2 0x3002
+#define GL_CLIP_PLANE3 0x3003
+#define GL_CLIP_PLANE4 0x3004
+#define GL_CLIP_PLANE5 0x3005
+#define GL_BYTE 0x1400
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_SHORT 0x1402
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_INT 0x1404
+#define GL_UNSIGNED_INT 0x1405
+#define GL_FLOAT 0x1406
+#define GL_2_BYTES 0x1407
+#define GL_3_BYTES 0x1408
+#define GL_4_BYTES 0x1409
+#define GL_DOUBLE 0x140A
+#define GL_NONE 0
+#define GL_FRONT_LEFT 0x0400
+#define GL_FRONT_RIGHT 0x0401
+#define GL_BACK_LEFT 0x0402
+#define GL_BACK_RIGHT 0x0403
+#define GL_FRONT 0x0404
+#define GL_BACK 0x0405
+#define GL_LEFT 0x0406
+#define GL_RIGHT 0x0407
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_AUX0 0x0409
+#define GL_AUX1 0x040A
+#define GL_AUX2 0x040B
+#define GL_AUX3 0x040C
+#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
+#define GL_2D 0x0600
+#define GL_3D 0x0601
+#define GL_3D_COLOR 0x0602
+#define GL_3D_COLOR_TEXTURE 0x0603
+#define GL_4D_COLOR_TEXTURE 0x0604
+#define GL_PASS_THROUGH_TOKEN 0x0700
+#define GL_POINT_TOKEN 0x0701
+#define GL_LINE_TOKEN 0x0702
+#define GL_POLYGON_TOKEN 0x0703
+#define GL_BITMAP_TOKEN 0x0704
+#define GL_DRAW_PIXEL_TOKEN 0x0705
+#define GL_COPY_PIXEL_TOKEN 0x0706
+#define GL_LINE_RESET_TOKEN 0x0707
+#define GL_EXP 0x0800
+#define GL_EXP2 0x0801
+#define GL_CW 0x0900
+#define GL_CCW 0x0901
+#define GL_COEFF 0x0A00
+#define GL_ORDER 0x0A01
+#define GL_DOMAIN 0x0A02
+#define GL_CURRENT_COLOR 0x0B00
+#define GL_CURRENT_INDEX 0x0B01
+#define GL_CURRENT_NORMAL 0x0B02
+#define GL_CURRENT_TEXTURE_COORDS 0x0B03
+#define GL_CURRENT_RASTER_COLOR 0x0B04
+#define GL_CURRENT_RASTER_INDEX 0x0B05
+#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
+#define GL_CURRENT_RASTER_POSITION 0x0B07
+#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
+#define GL_CURRENT_RASTER_DISTANCE 0x0B09
+#define GL_POINT_SMOOTH 0x0B10
+#define GL_POINT_SIZE 0x0B11
+#define GL_POINT_SIZE_RANGE 0x0B12
+#define GL_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_LINE_SMOOTH 0x0B20
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINE_WIDTH_RANGE 0x0B22
+#define GL_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_LINE_STIPPLE 0x0B24
+#define GL_LINE_STIPPLE_PATTERN 0x0B25
+#define GL_LINE_STIPPLE_REPEAT 0x0B26
+#define GL_LIST_MODE 0x0B30
+#define GL_MAX_LIST_NESTING 0x0B31
+#define GL_LIST_BASE 0x0B32
+#define GL_LIST_INDEX 0x0B33
+#define GL_POLYGON_MODE 0x0B40
+#define GL_POLYGON_SMOOTH 0x0B41
+#define GL_POLYGON_STIPPLE 0x0B42
+#define GL_EDGE_FLAG 0x0B43
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_FRONT_FACE 0x0B46
+#define GL_LIGHTING 0x0B50
+#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
+#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
+#define GL_LIGHT_MODEL_AMBIENT 0x0B53
+#define GL_SHADE_MODEL 0x0B54
+#define GL_COLOR_MATERIAL_FACE 0x0B55
+#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
+#define GL_COLOR_MATERIAL 0x0B57
+#define GL_FOG 0x0B60
+#define GL_FOG_INDEX 0x0B61
+#define GL_FOG_DENSITY 0x0B62
+#define GL_FOG_START 0x0B63
+#define GL_FOG_END 0x0B64
+#define GL_FOG_MODE 0x0B65
+#define GL_FOG_COLOR 0x0B66
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_ACCUM_CLEAR_VALUE 0x0B80
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_MATRIX_MODE 0x0BA0
+#define GL_NORMALIZE 0x0BA1
+#define GL_VIEWPORT 0x0BA2
+#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
+#define GL_PROJECTION_STACK_DEPTH 0x0BA4
+#define GL_TEXTURE_STACK_DEPTH 0x0BA5
+#define GL_MODELVIEW_MATRIX 0x0BA6
+#define GL_PROJECTION_MATRIX 0x0BA7
+#define GL_TEXTURE_MATRIX 0x0BA8
+#define GL_ATTRIB_STACK_DEPTH 0x0BB0
+#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
+#define GL_ALPHA_TEST 0x0BC0
+#define GL_ALPHA_TEST_FUNC 0x0BC1
+#define GL_ALPHA_TEST_REF 0x0BC2
+#define GL_DITHER 0x0BD0
+#define GL_BLEND_DST 0x0BE0
+#define GL_BLEND_SRC 0x0BE1
+#define GL_BLEND 0x0BE2
+#define GL_LOGIC_OP_MODE 0x0BF0
+#define GL_INDEX_LOGIC_OP 0x0BF1
+#define GL_COLOR_LOGIC_OP 0x0BF2
+#define GL_AUX_BUFFERS 0x0C00
+#define GL_DRAW_BUFFER 0x0C01
+#define GL_READ_BUFFER 0x0C02
+#define GL_SCISSOR_BOX 0x0C10
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_INDEX_CLEAR_VALUE 0x0C20
+#define GL_INDEX_WRITEMASK 0x0C21
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_INDEX_MODE 0x0C30
+#define GL_RGBA_MODE 0x0C31
+#define GL_DOUBLEBUFFER 0x0C32
+#define GL_STEREO 0x0C33
+#define GL_RENDER_MODE 0x0C40
+#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
+#define GL_POINT_SMOOTH_HINT 0x0C51
+#define GL_LINE_SMOOTH_HINT 0x0C52
+#define GL_POLYGON_SMOOTH_HINT 0x0C53
+#define GL_FOG_HINT 0x0C54
+#define GL_TEXTURE_GEN_S 0x0C60
+#define GL_TEXTURE_GEN_T 0x0C61
+#define GL_TEXTURE_GEN_R 0x0C62
+#define GL_TEXTURE_GEN_Q 0x0C63
+#define GL_PIXEL_MAP_I_TO_I 0x0C70
+#define GL_PIXEL_MAP_S_TO_S 0x0C71
+#define GL_PIXEL_MAP_I_TO_R 0x0C72
+#define GL_PIXEL_MAP_I_TO_G 0x0C73
+#define GL_PIXEL_MAP_I_TO_B 0x0C74
+#define GL_PIXEL_MAP_I_TO_A 0x0C75
+#define GL_PIXEL_MAP_R_TO_R 0x0C76
+#define GL_PIXEL_MAP_G_TO_G 0x0C77
+#define GL_PIXEL_MAP_B_TO_B 0x0C78
+#define GL_PIXEL_MAP_A_TO_A 0x0C79
+#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
+#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
+#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
+#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
+#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
+#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
+#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
+#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
+#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
+#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
+#define GL_UNPACK_SWAP_BYTES 0x0CF0
+#define GL_UNPACK_LSB_FIRST 0x0CF1
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_PACK_SWAP_BYTES 0x0D00
+#define GL_PACK_LSB_FIRST 0x0D01
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_PACK_SKIP_ROWS 0x0D03
+#define GL_PACK_SKIP_PIXELS 0x0D04
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_MAP_COLOR 0x0D10
+#define GL_MAP_STENCIL 0x0D11
+#define GL_INDEX_SHIFT 0x0D12
+#define GL_INDEX_OFFSET 0x0D13
+#define GL_RED_SCALE 0x0D14
+#define GL_RED_BIAS 0x0D15
+#define GL_ZOOM_X 0x0D16
+#define GL_ZOOM_Y 0x0D17
+#define GL_GREEN_SCALE 0x0D18
+#define GL_GREEN_BIAS 0x0D19
+#define GL_BLUE_SCALE 0x0D1A
+#define GL_BLUE_BIAS 0x0D1B
+#define GL_ALPHA_SCALE 0x0D1C
+#define GL_ALPHA_BIAS 0x0D1D
+#define GL_DEPTH_SCALE 0x0D1E
+#define GL_DEPTH_BIAS 0x0D1F
+#define GL_MAX_EVAL_ORDER 0x0D30
+#define GL_MAX_LIGHTS 0x0D31
+#define GL_MAX_CLIP_PLANES 0x0D32
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_PIXEL_MAP_TABLE 0x0D34
+#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
+#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
+#define GL_MAX_NAME_STACK_DEPTH 0x0D37
+#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_INDEX_BITS 0x0D51
+#define GL_RED_BITS 0x0D52
+#define GL_GREEN_BITS 0x0D53
+#define GL_BLUE_BITS 0x0D54
+#define GL_ALPHA_BITS 0x0D55
+#define GL_DEPTH_BITS 0x0D56
+#define GL_STENCIL_BITS 0x0D57
+#define GL_ACCUM_RED_BITS 0x0D58
+#define GL_ACCUM_GREEN_BITS 0x0D59
+#define GL_ACCUM_BLUE_BITS 0x0D5A
+#define GL_ACCUM_ALPHA_BITS 0x0D5B
+#define GL_NAME_STACK_DEPTH 0x0D70
+#define GL_AUTO_NORMAL 0x0D80
+#define GL_MAP1_COLOR_4 0x0D90
+#define GL_MAP1_INDEX 0x0D91
+#define GL_MAP1_NORMAL 0x0D92
+#define GL_MAP1_TEXTURE_COORD_1 0x0D93
+#define GL_MAP1_TEXTURE_COORD_2 0x0D94
+#define GL_MAP1_TEXTURE_COORD_3 0x0D95
+#define GL_MAP1_TEXTURE_COORD_4 0x0D96
+#define GL_MAP1_VERTEX_3 0x0D97
+#define GL_MAP1_VERTEX_4 0x0D98
+#define GL_MAP2_COLOR_4 0x0DB0
+#define GL_MAP2_INDEX 0x0DB1
+#define GL_MAP2_NORMAL 0x0DB2
+#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
+#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
+#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
+#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
+#define GL_MAP2_VERTEX_3 0x0DB7
+#define GL_MAP2_VERTEX_4 0x0DB8
+#define GL_MAP1_GRID_DOMAIN 0x0DD0
+#define GL_MAP1_GRID_SEGMENTS 0x0DD1
+#define GL_MAP2_GRID_DOMAIN 0x0DD2
+#define GL_MAP2_GRID_SEGMENTS 0x0DD3
+#define GL_TEXTURE_1D 0x0DE0
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
+#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
+#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
+#define GL_SELECTION_BUFFER_POINTER 0x0DF3
+#define GL_SELECTION_BUFFER_SIZE 0x0DF4
+#define GL_TEXTURE_WIDTH 0x1000
+#define GL_TEXTURE_HEIGHT 0x1001
+#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
+#define GL_TEXTURE_BORDER_COLOR 0x1004
+#define GL_TEXTURE_BORDER 0x1005
+#define GL_DONT_CARE 0x1100
+#define GL_FASTEST 0x1101
+#define GL_NICEST 0x1102
+#define GL_LIGHT0 0x4000
+#define GL_LIGHT1 0x4001
+#define GL_LIGHT2 0x4002
+#define GL_LIGHT3 0x4003
+#define GL_LIGHT4 0x4004
+#define GL_LIGHT5 0x4005
+#define GL_LIGHT6 0x4006
+#define GL_LIGHT7 0x4007
+#define GL_AMBIENT 0x1200
+#define GL_DIFFUSE 0x1201
+#define GL_SPECULAR 0x1202
+#define GL_POSITION 0x1203
+#define GL_SPOT_DIRECTION 0x1204
+#define GL_SPOT_EXPONENT 0x1205
+#define GL_SPOT_CUTOFF 0x1206
+#define GL_CONSTANT_ATTENUATION 0x1207
+#define GL_LINEAR_ATTENUATION 0x1208
+#define GL_QUADRATIC_ATTENUATION 0x1209
+#define GL_COMPILE 0x1300
+#define GL_COMPILE_AND_EXECUTE 0x1301
+#define GL_CLEAR 0x1500
+#define GL_AND 0x1501
+#define GL_AND_REVERSE 0x1502
+#define GL_COPY 0x1503
+#define GL_AND_INVERTED 0x1504
+#define GL_NOOP 0x1505
+#define GL_XOR 0x1506
+#define GL_OR 0x1507
+#define GL_NOR 0x1508
+#define GL_EQUIV 0x1509
+#define GL_INVERT 0x150A
+#define GL_OR_REVERSE 0x150B
+#define GL_COPY_INVERTED 0x150C
+#define GL_OR_INVERTED 0x150D
+#define GL_NAND 0x150E
+#define GL_SET 0x150F
+#define GL_EMISSION 0x1600
+#define GL_SHININESS 0x1601
+#define GL_AMBIENT_AND_DIFFUSE 0x1602
+#define GL_COLOR_INDEXES 0x1603
+#define GL_MODELVIEW 0x1700
+#define GL_PROJECTION 0x1701
+#define GL_TEXTURE 0x1702
+#define GL_COLOR 0x1800
+#define GL_DEPTH 0x1801
+#define GL_STENCIL 0x1802
+#define GL_COLOR_INDEX 0x1900
+#define GL_STENCIL_INDEX 0x1901
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_RED 0x1903
+#define GL_GREEN 0x1904
+#define GL_BLUE 0x1905
+#define GL_ALPHA 0x1906
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+#define GL_LUMINANCE 0x1909
+#define GL_LUMINANCE_ALPHA 0x190A
+#define GL_BITMAP 0x1A00
+#define GL_POINT 0x1B00
+#define GL_LINE 0x1B01
+#define GL_FILL 0x1B02
+#define GL_RENDER 0x1C00
+#define GL_FEEDBACK 0x1C01
+#define GL_SELECT 0x1C02
+#define GL_FLAT 0x1D00
+#define GL_SMOOTH 0x1D01
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_INCR 0x1E02
+#define GL_DECR 0x1E03
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+#define GL_VERSION 0x1F02
+#define GL_EXTENSIONS 0x1F03
+#define GL_S 0x2000
+#define GL_T 0x2001
+#define GL_R 0x2002
+#define GL_Q 0x2003
+#define GL_MODULATE 0x2100
+#define GL_DECAL 0x2101
+#define GL_TEXTURE_ENV_MODE 0x2200
+#define GL_TEXTURE_ENV_COLOR 0x2201
+#define GL_TEXTURE_ENV 0x2300
+#define GL_EYE_LINEAR 0x2400
+#define GL_OBJECT_LINEAR 0x2401
+#define GL_SPHERE_MAP 0x2402
+#define GL_TEXTURE_GEN_MODE 0x2500
+#define GL_OBJECT_PLANE 0x2501
+#define GL_EYE_PLANE 0x2502
+#define GL_NEAREST 0x2600
+#define GL_LINEAR 0x2601
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_CLAMP 0x2900
+#define GL_REPEAT 0x2901
+#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
+#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
+#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_POLYGON_OFFSET_POINT 0x2A01
+#define GL_POLYGON_OFFSET_LINE 0x2A02
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_ALPHA4 0x803B
+#define GL_ALPHA8 0x803C
+#define GL_ALPHA12 0x803D
+#define GL_ALPHA16 0x803E
+#define GL_LUMINANCE4 0x803F
+#define GL_LUMINANCE8 0x8040
+#define GL_LUMINANCE12 0x8041
+#define GL_LUMINANCE16 0x8042
+#define GL_LUMINANCE4_ALPHA4 0x8043
+#define GL_LUMINANCE6_ALPHA2 0x8044
+#define GL_LUMINANCE8_ALPHA8 0x8045
+#define GL_LUMINANCE12_ALPHA4 0x8046
+#define GL_LUMINANCE12_ALPHA12 0x8047
+#define GL_LUMINANCE16_ALPHA16 0x8048
+#define GL_INTENSITY 0x8049
+#define GL_INTENSITY4 0x804A
+#define GL_INTENSITY8 0x804B
+#define GL_INTENSITY12 0x804C
+#define GL_INTENSITY16 0x804D
+#define GL_R3_G3_B2 0x2A10
+#define GL_RGB4 0x804F
+#define GL_RGB5 0x8050
+#define GL_RGB8 0x8051
+#define GL_RGB10 0x8052
+#define GL_RGB12 0x8053
+#define GL_RGB16 0x8054
+#define GL_RGBA2 0x8055
+#define GL_RGBA4 0x8056
+#define GL_RGB5_A1 0x8057
+#define GL_RGBA8 0x8058
+#define GL_RGB10_A2 0x8059
+#define GL_RGBA12 0x805A
+#define GL_RGBA16 0x805B
+#define GL_TEXTURE_RED_SIZE 0x805C
+#define GL_TEXTURE_GREEN_SIZE 0x805D
+#define GL_TEXTURE_BLUE_SIZE 0x805E
+#define GL_TEXTURE_ALPHA_SIZE 0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
+#define GL_TEXTURE_INTENSITY_SIZE 0x8061
+#define GL_PROXY_TEXTURE_1D 0x8063
+#define GL_PROXY_TEXTURE_2D 0x8064
+#define GL_TEXTURE_PRIORITY 0x8066
+#define GL_TEXTURE_RESIDENT 0x8067
+#define GL_TEXTURE_BINDING_1D 0x8068
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_VERTEX_ARRAY 0x8074
+#define GL_NORMAL_ARRAY 0x8075
+#define GL_COLOR_ARRAY 0x8076
+#define GL_INDEX_ARRAY 0x8077
+#define GL_TEXTURE_COORD_ARRAY 0x8078
+#define GL_EDGE_FLAG_ARRAY 0x8079
+#define GL_VERTEX_ARRAY_SIZE 0x807A
+#define GL_VERTEX_ARRAY_TYPE 0x807B
+#define GL_VERTEX_ARRAY_STRIDE 0x807C
+#define GL_NORMAL_ARRAY_TYPE 0x807E
+#define GL_NORMAL_ARRAY_STRIDE 0x807F
+#define GL_COLOR_ARRAY_SIZE 0x8081
+#define GL_COLOR_ARRAY_TYPE 0x8082
+#define GL_COLOR_ARRAY_STRIDE 0x8083
+#define GL_INDEX_ARRAY_TYPE 0x8085
+#define GL_INDEX_ARRAY_STRIDE 0x8086
+#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
+#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
+#define GL_VERTEX_ARRAY_POINTER 0x808E
+#define GL_NORMAL_ARRAY_POINTER 0x808F
+#define GL_COLOR_ARRAY_POINTER 0x8090
+#define GL_INDEX_ARRAY_POINTER 0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
+#define GL_V2F 0x2A20
+#define GL_V3F 0x2A21
+#define GL_C4UB_V2F 0x2A22
+#define GL_C4UB_V3F 0x2A23
+#define GL_C3F_V3F 0x2A24
+#define GL_N3F_V3F 0x2A25
+#define GL_C4F_N3F_V3F 0x2A26
+#define GL_T2F_V3F 0x2A27
+#define GL_T4F_V4F 0x2A28
+#define GL_T2F_C4UB_V3F 0x2A29
+#define GL_T2F_C3F_V3F 0x2A2A
+#define GL_T2F_N3F_V3F 0x2A2B
+#define GL_T2F_C4F_N3F_V3F 0x2A2C
+#define GL_T4F_C4F_N3F_V4F 0x2A2D
+#define GL_LOGIC_OP GL_INDEX_LOGIC_OP
+#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT
+#define GL_COLOR_INDEX1_EXT 0x80E2
+#define GL_COLOR_INDEX2_EXT 0x80E3
+#define GL_COLOR_INDEX4_EXT 0x80E4
+#define GL_COLOR_INDEX8_EXT 0x80E5
+#define GL_COLOR_INDEX12_EXT 0x80E6
+#define GL_COLOR_INDEX16_EXT 0x80E7
+#define GL_VERSION_1_2 1
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_RESCALE_NORMAL 0x803A
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_BGR 0x80E0
+#define GL_BGRA 0x80E1
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
+#define GL_SINGLE_COLOR 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_VERSION_1_3 1
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_CLAMP_TO_BORDER 0x812D
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
+#define GL_MAX_TEXTURE_UNITS 0x84E2
+#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
+#define GL_SUBTRACT 0x84E7
+#define GL_COMPRESSED_ALPHA 0x84E9
+#define GL_COMPRESSED_LUMINANCE 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
+#define GL_COMPRESSED_INTENSITY 0x84EC
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_NORMAL_MAP 0x8511
+#define GL_REFLECTION_MAP 0x8512
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_COMBINE 0x8570
+#define GL_COMBINE_RGB 0x8571
+#define GL_COMBINE_ALPHA 0x8572
+#define GL_RGB_SCALE 0x8573
+#define GL_ADD_SIGNED 0x8574
+#define GL_INTERPOLATE 0x8575
+#define GL_CONSTANT 0x8576
+#define GL_PRIMARY_COLOR 0x8577
+#define GL_PREVIOUS 0x8578
+#define GL_SOURCE0_RGB 0x8580
+#define GL_SOURCE1_RGB 0x8581
+#define GL_SOURCE2_RGB 0x8582
+#define GL_SOURCE0_ALPHA 0x8588
+#define GL_SOURCE1_ALPHA 0x8589
+#define GL_SOURCE2_ALPHA 0x858A
+#define GL_OPERAND0_RGB 0x8590
+#define GL_OPERAND1_RGB 0x8591
+#define GL_OPERAND2_RGB 0x8592
+#define GL_OPERAND0_ALPHA 0x8598
+#define GL_OPERAND1_ALPHA 0x8599
+#define GL_OPERAND2_ALPHA 0x859A
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_TEXTURE_COMPRESSED 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_DOT3_RGB 0x86AE
+#define GL_DOT3_RGBA 0x86AF
+#define GL_MULTISAMPLE_BIT 0x20000000
+#define GL_VERSION_1_4 1
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_POINT_SIZE_MIN 0x8126
+#define GL_POINT_SIZE_MAX 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
+#define GL_POINT_DISTANCE_ATTENUATION 0x8129
+#define GL_GENERATE_MIPMAP 0x8191
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_DEPTH_COMPONENT32 0x81A7
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_FOG_COORDINATE_SOURCE 0x8450
+#define GL_FOG_COORDINATE 0x8451
+#define GL_FRAGMENT_DEPTH 0x8452
+#define GL_CURRENT_FOG_COORDINATE 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456
+#define GL_FOG_COORDINATE_ARRAY 0x8457
+#define GL_COLOR_SUM 0x8458
+#define GL_CURRENT_SECONDARY_COLOR 0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
+#define GL_SECONDARY_COLOR_ARRAY 0x845E
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_TEXTURE_FILTER_CONTROL 0x8500
+#define GL_TEXTURE_LOD_BIAS 0x8501
+#define GL_INCR_WRAP 0x8507
+#define GL_DECR_WRAP 0x8508
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_DEPTH_TEXTURE_MODE 0x884B
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_COMPARE_R_TO_TEXTURE 0x884E
+#define GL_VERSION_1_5 1
+#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE
+#define GL_FOG_COORD GL_FOG_COORDINATE
+#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY
+#define GL_SRC0_RGB GL_SOURCE0_RGB
+#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER
+#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE
+#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA
+#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE
+#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE
+#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA
+#define GL_SRC1_RGB GL_SOURCE1_RGB
+#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING
+#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA
+#define GL_SRC2_RGB GL_SOURCE2_RGB
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+#define GL_QUERY_COUNTER_BITS 0x8864
+#define GL_CURRENT_QUERY 0x8865
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_READ_ONLY 0x88B8
+#define GL_WRITE_ONLY 0x88B9
+#define GL_READ_WRITE 0x88BA
+#define GL_BUFFER_ACCESS 0x88BB
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STREAM_READ 0x88E1
+#define GL_STREAM_COPY 0x88E2
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STATIC_READ 0x88E5
+#define GL_STATIC_COPY 0x88E6
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_SAMPLES_PASSED 0x8914
+#define GL_VERSION_2_0 1
+#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_POINT_SPRITE 0x8861
+#define GL_COORD_REPLACE 0x8862
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_MAX_TEXTURE_COORDS 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_1D 0x8B5D
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_1D_SHADOW 0x8B61
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_DELETE_STATUS 0x8B80
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#define GL_3DFX_multisample 1
+#define GL_MULTISAMPLE_3DFX 0x86B2
+#define GL_SAMPLE_BUFFERS_3DFX 0x86B3
+#define GL_SAMPLES_3DFX 0x86B4
+#define GL_MULTISAMPLE_BIT_3DFX 0x20000000
+#define GL_3DFX_tbuffer 1
+#define GL_3DFX_texture_compression_FXT1 1
+#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
+#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1
+#define GL_APPLE_client_storage 1
+#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2
+#define GL_APPLE_element_array 1
+#define GL_ELEMENT_ARRAY_APPLE 0x8768
+#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769
+#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A
+#define GL_APPLE_fence 1
+#define GL_DRAW_PIXELS_APPLE 0x8A0A
+#define GL_FENCE_APPLE 0x8A0B
+#define GL_APPLE_float_pixels 1
+#define GL_HALF_APPLE 0x140B
+#define GL_RGBA_FLOAT32_APPLE 0x8814
+#define GL_RGB_FLOAT32_APPLE 0x8815
+#define GL_ALPHA_FLOAT32_APPLE 0x8816
+#define GL_INTENSITY_FLOAT32_APPLE 0x8817
+#define GL_LUMINANCE_FLOAT32_APPLE 0x8818
+#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819
+#define GL_RGBA_FLOAT16_APPLE 0x881A
+#define GL_RGB_FLOAT16_APPLE 0x881B
+#define GL_ALPHA_FLOAT16_APPLE 0x881C
+#define GL_INTENSITY_FLOAT16_APPLE 0x881D
+#define GL_LUMINANCE_FLOAT16_APPLE 0x881E
+#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F
+#define GL_COLOR_FLOAT_APPLE 0x8A0F
+#define GL_APPLE_pixel_buffer 1
+#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10
+#define GL_APPLE_specular_vector 1
+#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0
+#define GL_APPLE_texture_range 1
+#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7
+#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8
+#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC
+#define GL_STORAGE_PRIVATE_APPLE 0x85BD
+#define GL_STORAGE_CACHED_APPLE 0x85BE
+#define GL_STORAGE_SHARED_APPLE 0x85BF
+#define GL_APPLE_transform_hint 1
+#define GL_TRANSFORM_HINT_APPLE 0x85B1
+#define GL_APPLE_vertex_array_object 1
+#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5
+#define GL_APPLE_vertex_array_range 1
+#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D
+#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E
+#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F
+#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520
+#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521
+#define GL_STORAGE_CACHED_APPLE 0x85BE
+#define GL_STORAGE_SHARED_APPLE 0x85BF
+#define GL_APPLE_ycbcr_422 1
+#define GL_YCBCR_422_APPLE 0x85B9
+#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
+#define GL_ARB_color_buffer_float 1
+#define GL_RGBA_FLOAT_MODE_ARB 0x8820
+#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
+#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
+#define GL_CLAMP_READ_COLOR_ARB 0x891C
+#define GL_FIXED_ONLY_ARB 0x891D
+#define GL_ARB_depth_texture 1
+#define GL_DEPTH_COMPONENT16_ARB 0x81A5
+#define GL_DEPTH_COMPONENT24_ARB 0x81A6
+#define GL_DEPTH_COMPONENT32_ARB 0x81A7
+#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
+#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
+#define GL_ARB_draw_buffers 1
+#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
+#define GL_DRAW_BUFFER0_ARB 0x8825
+#define GL_DRAW_BUFFER1_ARB 0x8826
+#define GL_DRAW_BUFFER2_ARB 0x8827
+#define GL_DRAW_BUFFER3_ARB 0x8828
+#define GL_DRAW_BUFFER4_ARB 0x8829
+#define GL_DRAW_BUFFER5_ARB 0x882A
+#define GL_DRAW_BUFFER6_ARB 0x882B
+#define GL_DRAW_BUFFER7_ARB 0x882C
+#define GL_DRAW_BUFFER8_ARB 0x882D
+#define GL_DRAW_BUFFER9_ARB 0x882E
+#define GL_DRAW_BUFFER10_ARB 0x882F
+#define GL_DRAW_BUFFER11_ARB 0x8830
+#define GL_DRAW_BUFFER12_ARB 0x8831
+#define GL_DRAW_BUFFER13_ARB 0x8832
+#define GL_DRAW_BUFFER14_ARB 0x8833
+#define GL_DRAW_BUFFER15_ARB 0x8834
+#define GL_ARB_fragment_program 1
+#define GL_FRAGMENT_PROGRAM_ARB 0x8804
+#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
+#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
+#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
+#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
+#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
+#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
+#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
+#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
+#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
+#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
+#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
+#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
+#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
+#define GL_ARB_fragment_program_shadow 1
+#define GL_ARB_fragment_shader 1
+#define GL_FRAGMENT_SHADER_ARB 0x8B30
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
+#define GL_ARB_half_float_pixel 1
+#define GL_HALF_FLOAT_ARB 0x140B
+#define GL_ARB_imaging 1
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_BLEND_COLOR 0x8005
+#define GL_FUNC_ADD 0x8006
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_BLEND_EQUATION 0x8009
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_CONVOLUTION_1D 0x8010
+#define GL_CONVOLUTION_2D 0x8011
+#define GL_SEPARABLE_2D 0x8012
+#define GL_CONVOLUTION_BORDER_MODE 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS 0x8015
+#define GL_REDUCE 0x8016
+#define GL_CONVOLUTION_FORMAT 0x8017
+#define GL_CONVOLUTION_WIDTH 0x8018
+#define GL_CONVOLUTION_HEIGHT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
+#define GL_HISTOGRAM 0x8024
+#define GL_PROXY_HISTOGRAM 0x8025
+#define GL_HISTOGRAM_WIDTH 0x8026
+#define GL_HISTOGRAM_FORMAT 0x8027
+#define GL_HISTOGRAM_RED_SIZE 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
+#define GL_HISTOGRAM_SINK 0x802D
+#define GL_MINMAX 0x802E
+#define GL_MINMAX_FORMAT 0x802F
+#define GL_MINMAX_SINK 0x8030
+#define GL_TABLE_TOO_LARGE 0x8031
+#define GL_COLOR_MATRIX 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
+#define GL_COLOR_TABLE 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
+#define GL_PROXY_COLOR_TABLE 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
+#define GL_COLOR_TABLE_SCALE 0x80D6
+#define GL_COLOR_TABLE_BIAS 0x80D7
+#define GL_COLOR_TABLE_FORMAT 0x80D8
+#define GL_COLOR_TABLE_WIDTH 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
+#define GL_IGNORE_BORDER 0x8150
+#define GL_CONSTANT_BORDER 0x8151
+#define GL_WRAP_BORDER 0x8152
+#define GL_REPLICATE_BORDER 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR 0x8154
+#define GL_ARB_matrix_palette 1
+#define GL_MATRIX_PALETTE_ARB 0x8840
+#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841
+#define GL_MAX_PALETTE_MATRICES_ARB 0x8842
+#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843
+#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844
+#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845
+#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846
+#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847
+#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848
+#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849
+#define GL_ARB_multisample 1
+#define GL_MULTISAMPLE_ARB 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
+#define GL_SAMPLE_COVERAGE_ARB 0x80A0
+#define GL_SAMPLE_BUFFERS_ARB 0x80A8
+#define GL_SAMPLES_ARB 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
+#define GL_MULTISAMPLE_BIT_ARB 0x20000000
+#define GL_ARB_multitexture 1
+#define GL_TEXTURE0_ARB 0x84C0
+#define GL_TEXTURE1_ARB 0x84C1
+#define GL_TEXTURE2_ARB 0x84C2
+#define GL_TEXTURE3_ARB 0x84C3
+#define GL_TEXTURE4_ARB 0x84C4
+#define GL_TEXTURE5_ARB 0x84C5
+#define GL_TEXTURE6_ARB 0x84C6
+#define GL_TEXTURE7_ARB 0x84C7
+#define GL_TEXTURE8_ARB 0x84C8
+#define GL_TEXTURE9_ARB 0x84C9
+#define GL_TEXTURE10_ARB 0x84CA
+#define GL_TEXTURE11_ARB 0x84CB
+#define GL_TEXTURE12_ARB 0x84CC
+#define GL_TEXTURE13_ARB 0x84CD
+#define GL_TEXTURE14_ARB 0x84CE
+#define GL_TEXTURE15_ARB 0x84CF
+#define GL_TEXTURE16_ARB 0x84D0
+#define GL_TEXTURE17_ARB 0x84D1
+#define GL_TEXTURE18_ARB 0x84D2
+#define GL_TEXTURE19_ARB 0x84D3
+#define GL_TEXTURE20_ARB 0x84D4
+#define GL_TEXTURE21_ARB 0x84D5
+#define GL_TEXTURE22_ARB 0x84D6
+#define GL_TEXTURE23_ARB 0x84D7
+#define GL_TEXTURE24_ARB 0x84D8
+#define GL_TEXTURE25_ARB 0x84D9
+#define GL_TEXTURE26_ARB 0x84DA
+#define GL_TEXTURE27_ARB 0x84DB
+#define GL_TEXTURE28_ARB 0x84DC
+#define GL_TEXTURE29_ARB 0x84DD
+#define GL_TEXTURE30_ARB 0x84DE
+#define GL_TEXTURE31_ARB 0x84DF
+#define GL_ACTIVE_TEXTURE_ARB 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
+#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
+#define GL_ARB_occlusion_query 1
+#define GL_QUERY_COUNTER_BITS_ARB 0x8864
+#define GL_CURRENT_QUERY_ARB 0x8865
+#define GL_QUERY_RESULT_ARB 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
+#define GL_SAMPLES_PASSED_ARB 0x8914
+#define GL_ARB_pixel_buffer_object 1
+#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
+#define GL_ARB_point_parameters 1
+#define GL_POINT_SIZE_MIN_ARB 0x8126
+#define GL_POINT_SIZE_MAX_ARB 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128
+#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129
+#define GL_ARB_point_sprite 1
+#define GL_POINT_SPRITE_ARB 0x8861
+#define GL_COORD_REPLACE_ARB 0x8862
+#define GL_ARB_shader_objects 1
+#define GL_PROGRAM_OBJECT_ARB 0x8B40
+#define GL_SHADER_OBJECT_ARB 0x8B48
+#define GL_OBJECT_TYPE_ARB 0x8B4E
+#define GL_OBJECT_SUBTYPE_ARB 0x8B4F
+#define GL_FLOAT_VEC2_ARB 0x8B50
+#define GL_FLOAT_VEC3_ARB 0x8B51
+#define GL_FLOAT_VEC4_ARB 0x8B52
+#define GL_INT_VEC2_ARB 0x8B53
+#define GL_INT_VEC3_ARB 0x8B54
+#define GL_INT_VEC4_ARB 0x8B55
+#define GL_BOOL_ARB 0x8B56
+#define GL_BOOL_VEC2_ARB 0x8B57
+#define GL_BOOL_VEC3_ARB 0x8B58
+#define GL_BOOL_VEC4_ARB 0x8B59
+#define GL_FLOAT_MAT2_ARB 0x8B5A
+#define GL_FLOAT_MAT3_ARB 0x8B5B
+#define GL_FLOAT_MAT4_ARB 0x8B5C
+#define GL_SAMPLER_1D_ARB 0x8B5D
+#define GL_SAMPLER_2D_ARB 0x8B5E
+#define GL_SAMPLER_3D_ARB 0x8B5F
+#define GL_SAMPLER_CUBE_ARB 0x8B60
+#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61
+#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62
+#define GL_SAMPLER_2D_RECT_ARB 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
+#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80
+#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
+#define GL_OBJECT_LINK_STATUS_ARB 0x8B82
+#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83
+#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84
+#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85
+#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86
+#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
+#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88
+#define GL_ARB_shading_language_100 1
+#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C
+#define GL_ARB_shadow 1
+#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C
+#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D
+#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
+#define GL_ARB_shadow_ambient 1
+#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
+#define GL_ARB_texture_border_clamp 1
+#define GL_CLAMP_TO_BORDER_ARB 0x812D
+#define GL_ARB_texture_compression 1
+#define GL_COMPRESSED_ALPHA_ARB 0x84E9
+#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
+#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
+#define GL_COMPRESSED_RGB_ARB 0x84ED
+#define GL_COMPRESSED_RGBA_ARB 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
+#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
+#define GL_ARB_texture_cube_map 1
+#define GL_NORMAL_MAP_ARB 0x8511
+#define GL_REFLECTION_MAP_ARB 0x8512
+#define GL_TEXTURE_CUBE_MAP_ARB 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
+#define GL_ARB_texture_env_add 1
+#define GL_ARB_texture_env_combine 1
+#define GL_SUBTRACT_ARB 0x84E7
+#define GL_COMBINE_ARB 0x8570
+#define GL_COMBINE_RGB_ARB 0x8571
+#define GL_COMBINE_ALPHA_ARB 0x8572
+#define GL_RGB_SCALE_ARB 0x8573
+#define GL_ADD_SIGNED_ARB 0x8574
+#define GL_INTERPOLATE_ARB 0x8575
+#define GL_CONSTANT_ARB 0x8576
+#define GL_PRIMARY_COLOR_ARB 0x8577
+#define GL_PREVIOUS_ARB 0x8578
+#define GL_SOURCE0_RGB_ARB 0x8580
+#define GL_SOURCE1_RGB_ARB 0x8581
+#define GL_SOURCE2_RGB_ARB 0x8582
+#define GL_SOURCE0_ALPHA_ARB 0x8588
+#define GL_SOURCE1_ALPHA_ARB 0x8589
+#define GL_SOURCE2_ALPHA_ARB 0x858A
+#define GL_OPERAND0_RGB_ARB 0x8590
+#define GL_OPERAND1_RGB_ARB 0x8591
+#define GL_OPERAND2_RGB_ARB 0x8592
+#define GL_OPERAND0_ALPHA_ARB 0x8598
+#define GL_OPERAND1_ALPHA_ARB 0x8599
+#define GL_OPERAND2_ALPHA_ARB 0x859A
+#define GL_ARB_texture_env_crossbar 1
+#define GL_ARB_texture_env_dot3 1
+#define GL_DOT3_RGB_ARB 0x86AE
+#define GL_DOT3_RGBA_ARB 0x86AF
+#define GL_ARB_texture_float 1
+#define GL_RGBA32F_ARB 0x8814
+#define GL_RGB32F_ARB 0x8815
+#define GL_ALPHA32F_ARB 0x8816
+#define GL_INTENSITY32F_ARB 0x8817
+#define GL_LUMINANCE32F_ARB 0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
+#define GL_RGBA16F_ARB 0x881A
+#define GL_RGB16F_ARB 0x881B
+#define GL_ALPHA16F_ARB 0x881C
+#define GL_INTENSITY16F_ARB 0x881D
+#define GL_LUMINANCE16F_ARB 0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
+#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
+#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
+#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
+#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
+#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
+#define GL_ARB_texture_mirrored_repeat 1
+#define GL_MIRRORED_REPEAT_ARB 0x8370
+#define GL_ARB_texture_non_power_of_two 1
+#define GL_ARB_texture_rectangle 1
+#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
+#define GL_SAMPLER_2D_RECT_ARB 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
+#define GL_ARB_transpose_matrix 1
+#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6
+#define GL_ARB_vertex_blend 1
+#define GL_MODELVIEW0_ARB 0x1700
+#define GL_MODELVIEW1_ARB 0x850A
+#define GL_MAX_VERTEX_UNITS_ARB 0x86A4
+#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5
+#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6
+#define GL_VERTEX_BLEND_ARB 0x86A7
+#define GL_CURRENT_WEIGHT_ARB 0x86A8
+#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9
+#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA
+#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB
+#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC
+#define GL_WEIGHT_ARRAY_ARB 0x86AD
+#define GL_MODELVIEW2_ARB 0x8722
+#define GL_MODELVIEW3_ARB 0x8723
+#define GL_MODELVIEW4_ARB 0x8724
+#define GL_MODELVIEW5_ARB 0x8725
+#define GL_MODELVIEW6_ARB 0x8726
+#define GL_MODELVIEW7_ARB 0x8727
+#define GL_MODELVIEW8_ARB 0x8728
+#define GL_MODELVIEW9_ARB 0x8729
+#define GL_MODELVIEW10_ARB 0x872A
+#define GL_MODELVIEW11_ARB 0x872B
+#define GL_MODELVIEW12_ARB 0x872C
+#define GL_MODELVIEW13_ARB 0x872D
+#define GL_MODELVIEW14_ARB 0x872E
+#define GL_MODELVIEW15_ARB 0x872F
+#define GL_MODELVIEW16_ARB 0x8730
+#define GL_MODELVIEW17_ARB 0x8731
+#define GL_MODELVIEW18_ARB 0x8732
+#define GL_MODELVIEW19_ARB 0x8733
+#define GL_MODELVIEW20_ARB 0x8734
+#define GL_MODELVIEW21_ARB 0x8735
+#define GL_MODELVIEW22_ARB 0x8736
+#define GL_MODELVIEW23_ARB 0x8737
+#define GL_MODELVIEW24_ARB 0x8738
+#define GL_MODELVIEW25_ARB 0x8739
+#define GL_MODELVIEW26_ARB 0x873A
+#define GL_MODELVIEW27_ARB 0x873B
+#define GL_MODELVIEW28_ARB 0x873C
+#define GL_MODELVIEW29_ARB 0x873D
+#define GL_MODELVIEW30_ARB 0x873E
+#define GL_MODELVIEW31_ARB 0x873F
+#define GL_ARB_vertex_buffer_object 1
+#define GL_BUFFER_SIZE_ARB 0x8764
+#define GL_BUFFER_USAGE_ARB 0x8765
+#define GL_ARRAY_BUFFER_ARB 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
+#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
+#define GL_READ_ONLY_ARB 0x88B8
+#define GL_WRITE_ONLY_ARB 0x88B9
+#define GL_READ_WRITE_ARB 0x88BA
+#define GL_BUFFER_ACCESS_ARB 0x88BB
+#define GL_BUFFER_MAPPED_ARB 0x88BC
+#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
+#define GL_STREAM_DRAW_ARB 0x88E0
+#define GL_STREAM_READ_ARB 0x88E1
+#define GL_STREAM_COPY_ARB 0x88E2
+#define GL_STATIC_DRAW_ARB 0x88E4
+#define GL_STATIC_READ_ARB 0x88E5
+#define GL_STATIC_COPY_ARB 0x88E6
+#define GL_DYNAMIC_DRAW_ARB 0x88E8
+#define GL_DYNAMIC_READ_ARB 0x88E9
+#define GL_DYNAMIC_COPY_ARB 0x88EA
+#define GL_ARB_vertex_program 1
+#define GL_COLOR_SUM_ARB 0x8458
+#define GL_VERTEX_PROGRAM_ARB 0x8620
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
+#define GL_PROGRAM_LENGTH_ARB 0x8627
+#define GL_PROGRAM_STRING_ARB 0x8628
+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
+#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
+#define GL_CURRENT_MATRIX_ARB 0x8641
+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
+#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
+#define GL_PROGRAM_BINDING_ARB 0x8677
+#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
+#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
+#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
+#define GL_PROGRAM_FORMAT_ARB 0x8876
+#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
+#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
+#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
+#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
+#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
+#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
+#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
+#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
+#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
+#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
+#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
+#define GL_MATRIX0_ARB 0x88C0
+#define GL_MATRIX1_ARB 0x88C1
+#define GL_MATRIX2_ARB 0x88C2
+#define GL_MATRIX3_ARB 0x88C3
+#define GL_MATRIX4_ARB 0x88C4
+#define GL_MATRIX5_ARB 0x88C5
+#define GL_MATRIX6_ARB 0x88C6
+#define GL_MATRIX7_ARB 0x88C7
+#define GL_MATRIX8_ARB 0x88C8
+#define GL_MATRIX9_ARB 0x88C9
+#define GL_MATRIX10_ARB 0x88CA
+#define GL_MATRIX11_ARB 0x88CB
+#define GL_MATRIX12_ARB 0x88CC
+#define GL_MATRIX13_ARB 0x88CD
+#define GL_MATRIX14_ARB 0x88CE
+#define GL_MATRIX15_ARB 0x88CF
+#define GL_MATRIX16_ARB 0x88D0
+#define GL_MATRIX17_ARB 0x88D1
+#define GL_MATRIX18_ARB 0x88D2
+#define GL_MATRIX19_ARB 0x88D3
+#define GL_MATRIX20_ARB 0x88D4
+#define GL_MATRIX21_ARB 0x88D5
+#define GL_MATRIX22_ARB 0x88D6
+#define GL_MATRIX23_ARB 0x88D7
+#define GL_MATRIX24_ARB 0x88D8
+#define GL_MATRIX25_ARB 0x88D9
+#define GL_MATRIX26_ARB 0x88DA
+#define GL_MATRIX27_ARB 0x88DB
+#define GL_MATRIX28_ARB 0x88DC
+#define GL_MATRIX29_ARB 0x88DD
+#define GL_MATRIX30_ARB 0x88DE
+#define GL_MATRIX31_ARB 0x88DF
+#define GL_ARB_vertex_shader 1
+#define GL_VERTEX_SHADER_ARB 0x8B31
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
+#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
+#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
+#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
+#define GL_ARB_window_pos 1
+#define GL_ATIX_point_sprites 1
+#define GL_ATIX_texture_env_combine3 1
+#define GL_MODULATE_ADD_ATIX 0x8744
+#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745
+#define GL_MODULATE_SUBTRACT_ATIX 0x8746
+#define GL_ATIX_texture_env_route 1
+#define GL_SECONDARY_COLOR_ATIX 0x8747
+#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748
+#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749
+#define GL_ATIX_vertex_shader_output_point_size 1
+#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E
+#define GL_ATI_draw_buffers 1
+#define GL_MAX_DRAW_BUFFERS_ATI 0x8824
+#define GL_DRAW_BUFFER0_ATI 0x8825
+#define GL_DRAW_BUFFER1_ATI 0x8826
+#define GL_DRAW_BUFFER2_ATI 0x8827
+#define GL_DRAW_BUFFER3_ATI 0x8828
+#define GL_DRAW_BUFFER4_ATI 0x8829
+#define GL_DRAW_BUFFER5_ATI 0x882A
+#define GL_DRAW_BUFFER6_ATI 0x882B
+#define GL_DRAW_BUFFER7_ATI 0x882C
+#define GL_DRAW_BUFFER8_ATI 0x882D
+#define GL_DRAW_BUFFER9_ATI 0x882E
+#define GL_DRAW_BUFFER10_ATI 0x882F
+#define GL_DRAW_BUFFER11_ATI 0x8830
+#define GL_DRAW_BUFFER12_ATI 0x8831
+#define GL_DRAW_BUFFER13_ATI 0x8832
+#define GL_DRAW_BUFFER14_ATI 0x8833
+#define GL_DRAW_BUFFER15_ATI 0x8834
+#define GL_ATI_element_array 1
+#define GL_ELEMENT_ARRAY_ATI 0x8768
+#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769
+#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A
+#define GL_ATI_envmap_bumpmap 1
+#define GL_BUMP_ROT_MATRIX_ATI 0x8775
+#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776
+#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777
+#define GL_BUMP_TEX_UNITS_ATI 0x8778
+#define GL_DUDV_ATI 0x8779
+#define GL_DU8DV8_ATI 0x877A
+#define GL_BUMP_ENVMAP_ATI 0x877B
+#define GL_BUMP_TARGET_ATI 0x877C
+#define GL_ATI_fragment_shader 1
+#define GL_RED_BIT_ATI 0x00000001
+#define GL_2X_BIT_ATI 0x00000001
+#define GL_4X_BIT_ATI 0x00000002
+#define GL_GREEN_BIT_ATI 0x00000002
+#define GL_COMP_BIT_ATI 0x00000002
+#define GL_BLUE_BIT_ATI 0x00000004
+#define GL_8X_BIT_ATI 0x00000004
+#define GL_NEGATE_BIT_ATI 0x00000004
+#define GL_BIAS_BIT_ATI 0x00000008
+#define GL_HALF_BIT_ATI 0x00000008
+#define GL_QUARTER_BIT_ATI 0x00000010
+#define GL_EIGHTH_BIT_ATI 0x00000020
+#define GL_SATURATE_BIT_ATI 0x00000040
+#define GL_FRAGMENT_SHADER_ATI 0x8920
+#define GL_REG_0_ATI 0x8921
+#define GL_REG_1_ATI 0x8922
+#define GL_REG_2_ATI 0x8923
+#define GL_REG_3_ATI 0x8924
+#define GL_REG_4_ATI 0x8925
+#define GL_REG_5_ATI 0x8926
+#define GL_CON_0_ATI 0x8941
+#define GL_CON_1_ATI 0x8942
+#define GL_CON_2_ATI 0x8943
+#define GL_CON_3_ATI 0x8944
+#define GL_CON_4_ATI 0x8945
+#define GL_CON_5_ATI 0x8946
+#define GL_CON_6_ATI 0x8947
+#define GL_CON_7_ATI 0x8948
+#define GL_MOV_ATI 0x8961
+#define GL_ADD_ATI 0x8963
+#define GL_MUL_ATI 0x8964
+#define GL_SUB_ATI 0x8965
+#define GL_DOT3_ATI 0x8966
+#define GL_DOT4_ATI 0x8967
+#define GL_MAD_ATI 0x8968
+#define GL_LERP_ATI 0x8969
+#define GL_CND_ATI 0x896A
+#define GL_CND0_ATI 0x896B
+#define GL_DOT2_ADD_ATI 0x896C
+#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D
+#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
+#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F
+#define GL_NUM_PASSES_ATI 0x8970
+#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971
+#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972
+#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973
+#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974
+#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975
+#define GL_SWIZZLE_STR_ATI 0x8976
+#define GL_SWIZZLE_STQ_ATI 0x8977
+#define GL_SWIZZLE_STR_DR_ATI 0x8978
+#define GL_SWIZZLE_STQ_DQ_ATI 0x8979
+#define GL_SWIZZLE_STRQ_ATI 0x897A
+#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B
+#define GL_ATI_map_object_buffer 1
+#define GL_ATI_pn_triangles 1
+#define GL_PN_TRIANGLES_ATI 0x87F0
+#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1
+#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2
+#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3
+#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4
+#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5
+#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6
+#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7
+#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8
+#define GL_ATI_separate_stencil 1
+#define GL_STENCIL_BACK_FUNC_ATI 0x8800
+#define GL_STENCIL_BACK_FAIL_ATI 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803
+#define GL_ATI_text_fragment_shader 1
+#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200
+#define GL_ATI_texture_compression_3dc 1
+#define GL_COMPRESSED_RGB_3DC_ATI 0x8837
+#define GL_ATI_texture_env_combine3 1
+#define GL_MODULATE_ADD_ATI 0x8744
+#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
+#define GL_MODULATE_SUBTRACT_ATI 0x8746
+#define GL_ATI_texture_float 1
+#define GL_RGBA_FLOAT32_ATI 0x8814
+#define GL_RGB_FLOAT32_ATI 0x8815
+#define GL_ALPHA_FLOAT32_ATI 0x8816
+#define GL_INTENSITY_FLOAT32_ATI 0x8817
+#define GL_LUMINANCE_FLOAT32_ATI 0x8818
+#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819
+#define GL_RGBA_FLOAT16_ATI 0x881A
+#define GL_RGB_FLOAT16_ATI 0x881B
+#define GL_ALPHA_FLOAT16_ATI 0x881C
+#define GL_INTENSITY_FLOAT16_ATI 0x881D
+#define GL_LUMINANCE_FLOAT16_ATI 0x881E
+#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F
+#define GL_ATI_texture_mirror_once 1
+#define GL_MIRROR_CLAMP_ATI 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
+#define GL_ATI_vertex_array_object 1
+#define GL_STATIC_ATI 0x8760
+#define GL_DYNAMIC_ATI 0x8761
+#define GL_PRESERVE_ATI 0x8762
+#define GL_DISCARD_ATI 0x8763
+#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764
+#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765
+#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766
+#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767
+#define GL_ATI_vertex_attrib_array_object 1
+#define GL_ATI_vertex_streams 1
+#define GL_MAX_VERTEX_STREAMS_ATI 0x876B
+#define GL_VERTEX_SOURCE_ATI 0x876C
+#define GL_VERTEX_STREAM0_ATI 0x876D
+#define GL_VERTEX_STREAM1_ATI 0x876E
+#define GL_VERTEX_STREAM2_ATI 0x876F
+#define GL_VERTEX_STREAM3_ATI 0x8770
+#define GL_VERTEX_STREAM4_ATI 0x8771
+#define GL_VERTEX_STREAM5_ATI 0x8772
+#define GL_VERTEX_STREAM6_ATI 0x8773
+#define GL_VERTEX_STREAM7_ATI 0x8774
+#define GL_EXT_422_pixels 1
+#define GL_422_EXT 0x80CC
+#define GL_422_REV_EXT 0x80CD
+#define GL_422_AVERAGE_EXT 0x80CE
+#define GL_422_REV_AVERAGE_EXT 0x80CF
+#define GL_EXT_Cg_shader 1
+#define GL_CG_VERTEX_SHADER_EXT 0x890E
+#define GL_CG_FRAGMENT_SHADER_EXT 0x890F
+#define GL_EXT_abgr 1
+#define GL_ABGR_EXT 0x8000
+#define GL_EXT_bgra 1
+#define GL_BGR_EXT 0x80E0
+#define GL_BGRA_EXT 0x80E1
+#define GL_EXT_blend_color 1
+#define GL_CONSTANT_COLOR_EXT 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
+#define GL_CONSTANT_ALPHA_EXT 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
+#define GL_BLEND_COLOR_EXT 0x8005
+#define GL_EXT_blend_equation_separate 1
+#define GL_BLEND_EQUATION_RGB_EXT 0x8009
+#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D
+#define GL_EXT_blend_func_separate 1
+#define GL_BLEND_DST_RGB_EXT 0x80C8
+#define GL_BLEND_SRC_RGB_EXT 0x80C9
+#define GL_BLEND_DST_ALPHA_EXT 0x80CA
+#define GL_BLEND_SRC_ALPHA_EXT 0x80CB
+#define GL_EXT_blend_logic_op 1
+#define GL_EXT_blend_minmax 1
+#define GL_FUNC_ADD_EXT 0x8006
+#define GL_MIN_EXT 0x8007
+#define GL_MAX_EXT 0x8008
+#define GL_BLEND_EQUATION_EXT 0x8009
+#define GL_EXT_blend_subtract 1
+#define GL_FUNC_SUBTRACT_EXT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B
+#define GL_EXT_clip_volume_hint 1
+#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0
+#define GL_EXT_cmyka 1
+#define GL_CMYK_EXT 0x800C
+#define GL_CMYKA_EXT 0x800D
+#define GL_PACK_CMYK_HINT_EXT 0x800E
+#define GL_UNPACK_CMYK_HINT_EXT 0x800F
+#define GL_EXT_color_subtable 1
+#define GL_EXT_compiled_vertex_array 1
+#define GL_EXT_convolution 1
+#define GL_CONVOLUTION_1D_EXT 0x8010
+#define GL_CONVOLUTION_2D_EXT 0x8011
+#define GL_SEPARABLE_2D_EXT 0x8012
+#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015
+#define GL_REDUCE_EXT 0x8016
+#define GL_CONVOLUTION_FORMAT_EXT 0x8017
+#define GL_CONVOLUTION_WIDTH_EXT 0x8018
+#define GL_CONVOLUTION_HEIGHT_EXT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023
+#define GL_EXT_coordinate_frame 1
+#define GL_TANGENT_ARRAY_EXT 0x8439
+#define GL_BINORMAL_ARRAY_EXT 0x843A
+#define GL_CURRENT_TANGENT_EXT 0x843B
+#define GL_CURRENT_BINORMAL_EXT 0x843C
+#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E
+#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F
+#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440
+#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441
+#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442
+#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443
+#define GL_MAP1_TANGENT_EXT 0x8444
+#define GL_MAP2_TANGENT_EXT 0x8445
+#define GL_MAP1_BINORMAL_EXT 0x8446
+#define GL_MAP2_BINORMAL_EXT 0x8447
+#define GL_EXT_copy_texture 1
+#define GL_EXT_cull_vertex 1
+#define GL_EXT_depth_bounds_test 1
+#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890
+#define GL_DEPTH_BOUNDS_EXT 0x8891
+#define GL_EXT_draw_range_elements 1
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_EXT_fog_coord 1
+#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450
+#define GL_FOG_COORDINATE_EXT 0x8451
+#define GL_FRAGMENT_DEPTH_EXT 0x8452
+#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
+#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
+#define GL_EXT_fragment_lighting 1
+#define GL_FRAGMENT_LIGHTING_EXT 0x8400
+#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401
+#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402
+#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403
+#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404
+#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405
+#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406
+#define GL_LIGHT_ENV_MODE_EXT 0x8407
+#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408
+#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409
+#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A
+#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B
+#define GL_FRAGMENT_LIGHT0_EXT 0x840C
+#define GL_FRAGMENT_LIGHT7_EXT 0x8413
+#define GL_EXT_framebuffer_blit 1
+#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
+#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
+#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
+#define GL_EXT_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_EXT_framebuffer_object 1
+#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
+#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
+#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
+#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
+#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
+#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
+#define GL_FRAMEBUFFER_EXT 0x8D40
+#define GL_RENDERBUFFER_EXT 0x8D41
+#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
+#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
+#define GL_STENCIL_INDEX1_EXT 0x8D46
+#define GL_STENCIL_INDEX4_EXT 0x8D47
+#define GL_STENCIL_INDEX8_EXT 0x8D48
+#define GL_STENCIL_INDEX16_EXT 0x8D49
+#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
+#define GL_EXT_histogram 1
+#define GL_HISTOGRAM_EXT 0x8024
+#define GL_PROXY_HISTOGRAM_EXT 0x8025
+#define GL_HISTOGRAM_WIDTH_EXT 0x8026
+#define GL_HISTOGRAM_FORMAT_EXT 0x8027
+#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C
+#define GL_HISTOGRAM_SINK_EXT 0x802D
+#define GL_MINMAX_EXT 0x802E
+#define GL_MINMAX_FORMAT_EXT 0x802F
+#define GL_MINMAX_SINK_EXT 0x8030
+#define GL_EXT_index_array_formats 1
+#define GL_EXT_index_func 1
+#define GL_EXT_index_material 1
+#define GL_EXT_index_texture 1
+#define GL_EXT_light_texture 1
+#define GL_FRAGMENT_MATERIAL_EXT 0x8349
+#define GL_FRAGMENT_NORMAL_EXT 0x834A
+#define GL_FRAGMENT_COLOR_EXT 0x834C
+#define GL_ATTENUATION_EXT 0x834D
+#define GL_SHADOW_ATTENUATION_EXT 0x834E
+#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F
+#define GL_TEXTURE_LIGHT_EXT 0x8350
+#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351
+#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352
+#define GL_FRAGMENT_DEPTH_EXT 0x8452
+#define GL_EXT_misc_attribute 1
+#define GL_EXT_multi_draw_arrays 1
+#define GL_EXT_multisample 1
+#define GL_MULTISAMPLE_EXT 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
+#define GL_SAMPLE_MASK_EXT 0x80A0
+#define GL_1PASS_EXT 0x80A1
+#define GL_2PASS_0_EXT 0x80A2
+#define GL_2PASS_1_EXT 0x80A3
+#define GL_4PASS_0_EXT 0x80A4
+#define GL_4PASS_1_EXT 0x80A5
+#define GL_4PASS_2_EXT 0x80A6
+#define GL_4PASS_3_EXT 0x80A7
+#define GL_SAMPLE_BUFFERS_EXT 0x80A8
+#define GL_SAMPLES_EXT 0x80A9
+#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA
+#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB
+#define GL_SAMPLE_PATTERN_EXT 0x80AC
+#define GL_MULTISAMPLE_BIT_EXT 0x20000000
+#define GL_EXT_packed_depth_stencil 1
+#define GL_DEPTH_STENCIL_EXT 0x84F9
+#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
+#define GL_DEPTH24_STENCIL8_EXT 0x88F0
+#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
+#define GL_EXT_packed_pixels 1
+#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036
+#define GL_EXT_paletted_texture 1
+#define GL_TEXTURE_1D 0x0DE0
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_PROXY_TEXTURE_1D 0x8063
+#define GL_PROXY_TEXTURE_2D 0x8064
+#define GL_TEXTURE_3D_EXT 0x806F
+#define GL_PROXY_TEXTURE_3D_EXT 0x8070
+#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8
+#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF
+#define GL_COLOR_INDEX1_EXT 0x80E2
+#define GL_COLOR_INDEX2_EXT 0x80E3
+#define GL_COLOR_INDEX4_EXT 0x80E4
+#define GL_COLOR_INDEX8_EXT 0x80E5
+#define GL_COLOR_INDEX12_EXT 0x80E6
+#define GL_COLOR_INDEX16_EXT 0x80E7
+#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
+#define GL_TEXTURE_CUBE_MAP_ARB 0x8513
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
+#define GL_EXT_pixel_buffer_object 1
+#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF
+#define GL_EXT_pixel_transform 1
+#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330
+#define GL_PIXEL_MAG_FILTER_EXT 0x8331
+#define GL_PIXEL_MIN_FILTER_EXT 0x8332
+#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333
+#define GL_CUBIC_EXT 0x8334
+#define GL_AVERAGE_EXT 0x8335
+#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336
+#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337
+#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338
+#define GL_EXT_pixel_transform_color_table 1
+#define GL_EXT_point_parameters 1
+#define GL_POINT_SIZE_MIN_EXT 0x8126
+#define GL_POINT_SIZE_MAX_EXT 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
+#define GL_DISTANCE_ATTENUATION_EXT 0x8129
+#define GL_EXT_polygon_offset 1
+#define GL_POLYGON_OFFSET_EXT 0x8037
+#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038
+#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039
+#define GL_EXT_rescale_normal 1
+#define GL_EXT_scene_marker 1
+#define GL_EXT_secondary_color 1
+#define GL_COLOR_SUM_EXT 0x8458
+#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
+#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E
+#define GL_EXT_separate_specular_color 1
+#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
+#define GL_SINGLE_COLOR_EXT 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA
+#define GL_EXT_shadow_funcs 1
+#define GL_EXT_shared_texture_palette 1
+#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
+#define GL_EXT_stencil_clear_tag 1
+#define GL_STENCIL_TAG_BITS_EXT 0x88F2
+#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3
+#define GL_EXT_stencil_two_side 1
+#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910
+#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911
+#define GL_EXT_stencil_wrap 1
+#define GL_INCR_WRAP_EXT 0x8507
+#define GL_DECR_WRAP_EXT 0x8508
+#define GL_EXT_subtexture 1
+#define GL_EXT_texture 1
+#define GL_ALPHA4_EXT 0x803B
+#define GL_ALPHA8_EXT 0x803C
+#define GL_ALPHA12_EXT 0x803D
+#define GL_ALPHA16_EXT 0x803E
+#define GL_LUMINANCE4_EXT 0x803F
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE12_EXT 0x8041
+#define GL_LUMINANCE16_EXT 0x8042
+#define GL_LUMINANCE4_ALPHA4_EXT 0x8043
+#define GL_LUMINANCE6_ALPHA2_EXT 0x8044
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_LUMINANCE12_ALPHA4_EXT 0x8046
+#define GL_LUMINANCE12_ALPHA12_EXT 0x8047
+#define GL_LUMINANCE16_ALPHA16_EXT 0x8048
+#define GL_INTENSITY_EXT 0x8049
+#define GL_INTENSITY4_EXT 0x804A
+#define GL_INTENSITY8_EXT 0x804B
+#define GL_INTENSITY12_EXT 0x804C
+#define GL_INTENSITY16_EXT 0x804D
+#define GL_RGB2_EXT 0x804E
+#define GL_RGB4_EXT 0x804F
+#define GL_RGB5_EXT 0x8050
+#define GL_RGB8_EXT 0x8051
+#define GL_RGB10_EXT 0x8052
+#define GL_RGB12_EXT 0x8053
+#define GL_RGB16_EXT 0x8054
+#define GL_RGBA2_EXT 0x8055
+#define GL_RGBA4_EXT 0x8056
+#define GL_RGB5_A1_EXT 0x8057
+#define GL_RGBA8_EXT 0x8058
+#define GL_RGB10_A2_EXT 0x8059
+#define GL_RGBA12_EXT 0x805A
+#define GL_RGBA16_EXT 0x805B
+#define GL_TEXTURE_RED_SIZE_EXT 0x805C
+#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D
+#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E
+#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060
+#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061
+#define GL_REPLACE_EXT 0x8062
+#define GL_PROXY_TEXTURE_1D_EXT 0x8063
+#define GL_PROXY_TEXTURE_2D_EXT 0x8064
+#define GL_EXT_texture3D 1
+#define GL_PACK_SKIP_IMAGES_EXT 0x806B
+#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C
+#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E
+#define GL_TEXTURE_3D_EXT 0x806F
+#define GL_PROXY_TEXTURE_3D_EXT 0x8070
+#define GL_TEXTURE_DEPTH_EXT 0x8071
+#define GL_TEXTURE_WRAP_R_EXT 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073
+#define GL_EXT_texture_compression_dxt1 1
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#define GL_EXT_texture_compression_s3tc 1
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#define GL_EXT_texture_cube_map 1
+#define GL_NORMAL_MAP_EXT 0x8511
+#define GL_REFLECTION_MAP_EXT 0x8512
+#define GL_TEXTURE_CUBE_MAP_EXT 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C
+#define GL_EXT_texture_edge_clamp 1
+#define GL_CLAMP_TO_EDGE_EXT 0x812F
+#define GL_EXT_texture_env 1
+#define GL_TEXTURE_ENV0_EXT 0
+#define GL_ENV_BLEND_EXT 0
+#define GL_TEXTURE_ENV_SHIFT_EXT 0
+#define GL_ENV_REPLACE_EXT 0
+#define GL_ENV_ADD_EXT 0
+#define GL_ENV_SUBTRACT_EXT 0
+#define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0
+#define GL_ENV_REVERSE_SUBTRACT_EXT 0
+#define GL_ENV_REVERSE_BLEND_EXT 0
+#define GL_ENV_COPY_EXT 0
+#define GL_ENV_MODULATE_EXT 0
+#define GL_EXT_texture_env_add 1
+#define GL_EXT_texture_env_combine 1
+#define GL_COMBINE_EXT 0x8570
+#define GL_COMBINE_RGB_EXT 0x8571
+#define GL_COMBINE_ALPHA_EXT 0x8572
+#define GL_RGB_SCALE_EXT 0x8573
+#define GL_ADD_SIGNED_EXT 0x8574
+#define GL_INTERPOLATE_EXT 0x8575
+#define GL_CONSTANT_EXT 0x8576
+#define GL_PRIMARY_COLOR_EXT 0x8577
+#define GL_PREVIOUS_EXT 0x8578
+#define GL_SOURCE0_RGB_EXT 0x8580
+#define GL_SOURCE1_RGB_EXT 0x8581
+#define GL_SOURCE2_RGB_EXT 0x8582
+#define GL_SOURCE0_ALPHA_EXT 0x8588
+#define GL_SOURCE1_ALPHA_EXT 0x8589
+#define GL_SOURCE2_ALPHA_EXT 0x858A
+#define GL_OPERAND0_RGB_EXT 0x8590
+#define GL_OPERAND1_RGB_EXT 0x8591
+#define GL_OPERAND2_RGB_EXT 0x8592
+#define GL_OPERAND0_ALPHA_EXT 0x8598
+#define GL_OPERAND1_ALPHA_EXT 0x8599
+#define GL_OPERAND2_ALPHA_EXT 0x859A
+#define GL_EXT_texture_env_dot3 1
+#define GL_DOT3_RGB_EXT 0x8740
+#define GL_DOT3_RGBA_EXT 0x8741
+#define GL_EXT_texture_filter_anisotropic 1
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#define GL_EXT_texture_lod_bias 1
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD
+#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT 0x8501
+#define GL_EXT_texture_mirror_clamp 1
+#define GL_MIRROR_CLAMP_EXT 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
+#define GL_EXT_texture_object 1
+#define GL_TEXTURE_PRIORITY_EXT 0x8066
+#define GL_TEXTURE_RESIDENT_EXT 0x8067
+#define GL_TEXTURE_1D_BINDING_EXT 0x8068
+#define GL_TEXTURE_2D_BINDING_EXT 0x8069
+#define GL_TEXTURE_3D_BINDING_EXT 0x806A
+#define GL_EXT_texture_perturb_normal 1
+#define GL_PERTURB_EXT 0x85AE
+#define GL_TEXTURE_NORMAL_EXT 0x85AF
+#define GL_EXT_texture_rectangle 1
+#define GL_TEXTURE_RECTANGLE_EXT 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8
+#define GL_EXT_texture_sRGB 1
+#define GL_SRGB_EXT 0x8C40
+#define GL_SRGB8_EXT 0x8C41
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_SLUMINANCE_ALPHA_EXT 0x8C44
+#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45
+#define GL_SLUMINANCE_EXT 0x8C46
+#define GL_SLUMINANCE8_EXT 0x8C47
+#define GL_COMPRESSED_SRGB_EXT 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
+#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
+#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
+#define GL_EXT_vertex_array 1
+#define GL_DOUBLE_EXT 0x140A
+#define GL_VERTEX_ARRAY_EXT 0x8074
+#define GL_NORMAL_ARRAY_EXT 0x8075
+#define GL_COLOR_ARRAY_EXT 0x8076
+#define GL_INDEX_ARRAY_EXT 0x8077
+#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
+#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
+#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
+#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
+#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
+#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
+#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
+#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
+#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
+#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
+#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
+#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
+#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
+#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
+#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
+#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
+#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
+#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
+#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
+#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
+#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
+#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
+#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
+#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
+#define GL_EXT_vertex_shader 1
+#define GL_VERTEX_SHADER_EXT 0x8780
+#define GL_VERTEX_SHADER_BINDING_EXT 0x8781
+#define GL_OP_INDEX_EXT 0x8782
+#define GL_OP_NEGATE_EXT 0x8783
+#define GL_OP_DOT3_EXT 0x8784
+#define GL_OP_DOT4_EXT 0x8785
+#define GL_OP_MUL_EXT 0x8786
+#define GL_OP_ADD_EXT 0x8787
+#define GL_OP_MADD_EXT 0x8788
+#define GL_OP_FRAC_EXT 0x8789
+#define GL_OP_MAX_EXT 0x878A
+#define GL_OP_MIN_EXT 0x878B
+#define GL_OP_SET_GE_EXT 0x878C
+#define GL_OP_SET_LT_EXT 0x878D
+#define GL_OP_CLAMP_EXT 0x878E
+#define GL_OP_FLOOR_EXT 0x878F
+#define GL_OP_ROUND_EXT 0x8790
+#define GL_OP_EXP_BASE_2_EXT 0x8791
+#define GL_OP_LOG_BASE_2_EXT 0x8792
+#define GL_OP_POWER_EXT 0x8793
+#define GL_OP_RECIP_EXT 0x8794
+#define GL_OP_RECIP_SQRT_EXT 0x8795
+#define GL_OP_SUB_EXT 0x8796
+#define GL_OP_CROSS_PRODUCT_EXT 0x8797
+#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798
+#define GL_OP_MOV_EXT 0x8799
+#define GL_OUTPUT_VERTEX_EXT 0x879A
+#define GL_OUTPUT_COLOR0_EXT 0x879B
+#define GL_OUTPUT_COLOR1_EXT 0x879C
+#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D
+#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E
+#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F
+#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0
+#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1
+#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2
+#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3
+#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4
+#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5
+#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6
+#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7
+#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8
+#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9
+#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA
+#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB
+#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC
+#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD
+#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE
+#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF
+#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0
+#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1
+#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2
+#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3
+#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4
+#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5
+#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6
+#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7
+#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8
+#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9
+#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA
+#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB
+#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC
+#define GL_OUTPUT_FOG_EXT 0x87BD
+#define GL_SCALAR_EXT 0x87BE
+#define GL_VECTOR_EXT 0x87BF
+#define GL_MATRIX_EXT 0x87C0
+#define GL_VARIANT_EXT 0x87C1
+#define GL_INVARIANT_EXT 0x87C2
+#define GL_LOCAL_CONSTANT_EXT 0x87C3
+#define GL_LOCAL_EXT 0x87C4
+#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5
+#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6
+#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7
+#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8
+#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE
+#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF
+#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0
+#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1
+#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2
+#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3
+#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4
+#define GL_X_EXT 0x87D5
+#define GL_Y_EXT 0x87D6
+#define GL_Z_EXT 0x87D7
+#define GL_W_EXT 0x87D8
+#define GL_NEGATIVE_X_EXT 0x87D9
+#define GL_NEGATIVE_Y_EXT 0x87DA
+#define GL_NEGATIVE_Z_EXT 0x87DB
+#define GL_NEGATIVE_W_EXT 0x87DC
+#define GL_ZERO_EXT 0x87DD
+#define GL_ONE_EXT 0x87DE
+#define GL_NEGATIVE_ONE_EXT 0x87DF
+#define GL_NORMALIZED_RANGE_EXT 0x87E0
+#define GL_FULL_RANGE_EXT 0x87E1
+#define GL_CURRENT_VERTEX_EXT 0x87E2
+#define GL_MVP_MATRIX_EXT 0x87E3
+#define GL_VARIANT_VALUE_EXT 0x87E4
+#define GL_VARIANT_DATATYPE_EXT 0x87E5
+#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6
+#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7
+#define GL_VARIANT_ARRAY_EXT 0x87E8
+#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9
+#define GL_INVARIANT_VALUE_EXT 0x87EA
+#define GL_INVARIANT_DATATYPE_EXT 0x87EB
+#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC
+#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED
+#define GL_EXT_vertex_weighting 1
+#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3
+#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6
+#define GL_MODELVIEW0_EXT 0x1700
+#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502
+#define GL_MODELVIEW1_MATRIX_EXT 0x8506
+#define GL_VERTEX_WEIGHTING_EXT 0x8509
+#define GL_MODELVIEW1_EXT 0x850A
+#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B
+#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C
+#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D
+#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E
+#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F
+#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510
+#define GL_GREMEDY_string_marker 1
+#define GL_HP_convolution_border_modes 1
+#define GL_HP_image_transform 1
+#define GL_HP_occlusion_test 1
+#define GL_OCCLUSION_TEST_HP 0x8165
+#define GL_OCCLUSION_TEST_RESULT_HP 0x8166
+#define GL_HP_texture_lighting 1
+#define GL_IBM_cull_vertex 1
+#define GL_CULL_VERTEX_IBM 103050
+#define GL_IBM_multimode_draw_arrays 1
+#define GL_IBM_rasterpos_clip 1
+#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010
+#define GL_IBM_static_data 1
+#define GL_ALL_STATIC_DATA_IBM 103060
+#define GL_STATIC_VERTEX_ARRAY_IBM 103061
+#define GL_IBM_texture_mirrored_repeat 1
+#define GL_MIRRORED_REPEAT_IBM 0x8370
+#define GL_IBM_vertex_array_lists 1
+#define GL_VERTEX_ARRAY_LIST_IBM 103070
+#define GL_NORMAL_ARRAY_LIST_IBM 103071
+#define GL_COLOR_ARRAY_LIST_IBM 103072
+#define GL_INDEX_ARRAY_LIST_IBM 103073
+#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074
+#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075
+#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076
+#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077
+#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080
+#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081
+#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082
+#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083
+#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084
+#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085
+#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086
+#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087
+#define GL_INGR_color_clamp 1
+#define GL_RED_MIN_CLAMP_INGR 0x8560
+#define GL_GREEN_MIN_CLAMP_INGR 0x8561
+#define GL_BLUE_MIN_CLAMP_INGR 0x8562
+#define GL_ALPHA_MIN_CLAMP_INGR 0x8563
+#define GL_RED_MAX_CLAMP_INGR 0x8564
+#define GL_GREEN_MAX_CLAMP_INGR 0x8565
+#define GL_BLUE_MAX_CLAMP_INGR 0x8566
+#define GL_ALPHA_MAX_CLAMP_INGR 0x8567
+#define GL_INGR_interlace_read 1
+#define GL_INTERLACE_READ_INGR 0x8568
+#define GL_INTEL_parallel_arrays 1
+#define GL_PARALLEL_ARRAYS_INTEL 0x83F4
+#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5
+#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6
+#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7
+#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8
+#define GL_INTEL_texture_scissor 1
+#define GL_KTX_buffer_region 1
+#define GL_KTX_FRONT_REGION 0x0
+#define GL_KTX_BACK_REGION 0x1
+#define GL_KTX_Z_REGION 0x2
+#define GL_KTX_STENCIL_REGION 0x3
+#define GL_MESAX_texture_stack 1
+#define GL_TEXTURE_1D_STACK_MESAX 0x8759
+#define GL_TEXTURE_2D_STACK_MESAX 0x875A
+#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B
+#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C
+#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D
+#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E
+#define GL_MESA_pack_invert 1
+#define GL_PACK_INVERT_MESA 0x8758
+#define GL_MESA_resize_buffers 1
+#define GL_MESA_window_pos 1
+#define GL_MESA_ycbcr_texture 1
+#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB
+#define GL_YCBCR_MESA 0x8757
+#define GL_NV_blend_square 1
+#define GL_NV_copy_depth_to_color 1
+#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E
+#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F
+#define GL_NV_depth_clamp 1
+#define GL_DEPTH_CLAMP_NV 0x864F
+#define GL_NV_evaluators 1
+#define GL_EVAL_2D_NV 0x86C0
+#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1
+#define GL_MAP_TESSELLATION_NV 0x86C2
+#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3
+#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4
+#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5
+#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6
+#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7
+#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8
+#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9
+#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA
+#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB
+#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC
+#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD
+#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE
+#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF
+#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0
+#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1
+#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2
+#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3
+#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4
+#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5
+#define GL_MAX_MAP_TESSELLATION_NV 0x86D6
+#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7
+#define GL_NV_fence 1
+#define GL_ALL_COMPLETED_NV 0x84F2
+#define GL_FENCE_STATUS_NV 0x84F3
+#define GL_FENCE_CONDITION_NV 0x84F4
+#define GL_NV_float_buffer 1
+#define GL_FLOAT_R_NV 0x8880
+#define GL_FLOAT_RG_NV 0x8881
+#define GL_FLOAT_RGB_NV 0x8882
+#define GL_FLOAT_RGBA_NV 0x8883
+#define GL_FLOAT_R16_NV 0x8884
+#define GL_FLOAT_R32_NV 0x8885
+#define GL_FLOAT_RG16_NV 0x8886
+#define GL_FLOAT_RG32_NV 0x8887
+#define GL_FLOAT_RGB16_NV 0x8888
+#define GL_FLOAT_RGB32_NV 0x8889
+#define GL_FLOAT_RGBA16_NV 0x888A
+#define GL_FLOAT_RGBA32_NV 0x888B
+#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C
+#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D
+#define GL_FLOAT_RGBA_MODE_NV 0x888E
+#define GL_NV_fog_distance 1
+#define GL_FOG_DISTANCE_MODE_NV 0x855A
+#define GL_EYE_RADIAL_NV 0x855B
+#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
+#define GL_NV_fragment_program 1
+#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868
+#define GL_FRAGMENT_PROGRAM_NV 0x8870
+#define GL_MAX_TEXTURE_COORDS_NV 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872
+#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873
+#define GL_PROGRAM_ERROR_STRING_NV 0x8874
+#define GL_NV_fragment_program2 1
+#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4
+#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5
+#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6
+#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7
+#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8
+#define GL_NV_fragment_program_option 1
+#define GL_NV_half_float 1
+#define GL_HALF_FLOAT_NV 0x140B
+#define GL_NV_light_max_exponent 1
+#define GL_MAX_SHININESS_NV 0x8504
+#define GL_MAX_SPOT_EXPONENT_NV 0x8505
+#define GL_NV_multisample_filter_hint 1
+#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534
+#define GL_NV_occlusion_query 1
+#define GL_PIXEL_COUNTER_BITS_NV 0x8864
+#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865
+#define GL_PIXEL_COUNT_NV 0x8866
+#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867
+#define GL_NV_packed_depth_stencil 1
+#define GL_DEPTH_STENCIL_NV 0x84F9
+#define GL_UNSIGNED_INT_24_8_NV 0x84FA
+#define GL_NV_pixel_data_range 1
+#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878
+#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879
+#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A
+#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B
+#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C
+#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D
+#define GL_NV_point_sprite 1
+#define GL_POINT_SPRITE_NV 0x8861
+#define GL_COORD_REPLACE_NV 0x8862
+#define GL_POINT_SPRITE_R_MODE_NV 0x8863
+#define GL_NV_primitive_restart 1
+#define GL_PRIMITIVE_RESTART_NV 0x8558
+#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559
+#define GL_NV_register_combiners 1
+#define GL_REGISTER_COMBINERS_NV 0x8522
+#define GL_VARIABLE_A_NV 0x8523
+#define GL_VARIABLE_B_NV 0x8524
+#define GL_VARIABLE_C_NV 0x8525
+#define GL_VARIABLE_D_NV 0x8526
+#define GL_VARIABLE_E_NV 0x8527
+#define GL_VARIABLE_F_NV 0x8528
+#define GL_VARIABLE_G_NV 0x8529
+#define GL_CONSTANT_COLOR0_NV 0x852A
+#define GL_CONSTANT_COLOR1_NV 0x852B
+#define GL_PRIMARY_COLOR_NV 0x852C
+#define GL_SECONDARY_COLOR_NV 0x852D
+#define GL_SPARE0_NV 0x852E
+#define GL_SPARE1_NV 0x852F
+#define GL_DISCARD_NV 0x8530
+#define GL_E_TIMES_F_NV 0x8531
+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
+#define GL_UNSIGNED_IDENTITY_NV 0x8536
+#define GL_UNSIGNED_INVERT_NV 0x8537
+#define GL_EXPAND_NORMAL_NV 0x8538
+#define GL_EXPAND_NEGATE_NV 0x8539
+#define GL_HALF_BIAS_NORMAL_NV 0x853A
+#define GL_HALF_BIAS_NEGATE_NV 0x853B
+#define GL_SIGNED_IDENTITY_NV 0x853C
+#define GL_SIGNED_NEGATE_NV 0x853D
+#define GL_SCALE_BY_TWO_NV 0x853E
+#define GL_SCALE_BY_FOUR_NV 0x853F
+#define GL_SCALE_BY_ONE_HALF_NV 0x8540
+#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541
+#define GL_COMBINER_INPUT_NV 0x8542
+#define GL_COMBINER_MAPPING_NV 0x8543
+#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544
+#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545
+#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546
+#define GL_COMBINER_MUX_SUM_NV 0x8547
+#define GL_COMBINER_SCALE_NV 0x8548
+#define GL_COMBINER_BIAS_NV 0x8549
+#define GL_COMBINER_AB_OUTPUT_NV 0x854A
+#define GL_COMBINER_CD_OUTPUT_NV 0x854B
+#define GL_COMBINER_SUM_OUTPUT_NV 0x854C
+#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
+#define GL_NUM_GENERAL_COMBINERS_NV 0x854E
+#define GL_COLOR_SUM_CLAMP_NV 0x854F
+#define GL_COMBINER0_NV 0x8550
+#define GL_COMBINER1_NV 0x8551
+#define GL_COMBINER2_NV 0x8552
+#define GL_COMBINER3_NV 0x8553
+#define GL_COMBINER4_NV 0x8554
+#define GL_COMBINER5_NV 0x8555
+#define GL_COMBINER6_NV 0x8556
+#define GL_COMBINER7_NV 0x8557
+#define GL_NV_register_combiners2 1
+#define GL_PER_STAGE_CONSTANTS_NV 0x8535
+#define GL_NV_texgen_emboss 1
+#define GL_EMBOSS_LIGHT_NV 0x855D
+#define GL_EMBOSS_CONSTANT_NV 0x855E
+#define GL_EMBOSS_MAP_NV 0x855F
+#define GL_NV_texgen_reflection 1
+#define GL_NORMAL_MAP_NV 0x8511
+#define GL_REFLECTION_MAP_NV 0x8512
+#define GL_NV_texture_compression_vtc 1
+#define GL_NV_texture_env_combine4 1
+#define GL_COMBINE4_NV 0x8503
+#define GL_SOURCE3_RGB_NV 0x8583
+#define GL_SOURCE3_ALPHA_NV 0x858B
+#define GL_OPERAND3_RGB_NV 0x8593
+#define GL_OPERAND3_ALPHA_NV 0x859B
+#define GL_NV_texture_expand_normal 1
+#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F
+#define GL_NV_texture_rectangle 1
+#define GL_TEXTURE_RECTANGLE_NV 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8
+#define GL_NV_texture_shader 1
+#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C
+#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
+#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
+#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
+#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA
+#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB
+#define GL_DSDT_MAG_INTENSITY_NV 0x86DC
+#define GL_SHADER_CONSISTENT_NV 0x86DD
+#define GL_TEXTURE_SHADER_NV 0x86DE
+#define GL_SHADER_OPERATION_NV 0x86DF
+#define GL_CULL_MODES_NV 0x86E0
+#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1
+#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2
+#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3
+#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4
+#define GL_CONST_EYE_NV 0x86E5
+#define GL_PASS_THROUGH_NV 0x86E6
+#define GL_CULL_FRAGMENT_NV 0x86E7
+#define GL_OFFSET_TEXTURE_2D_NV 0x86E8
+#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9
+#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA
+#define GL_DOT_PRODUCT_NV 0x86EC
+#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED
+#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE
+#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
+#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
+#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
+#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
+#define GL_HILO_NV 0x86F4
+#define GL_DSDT_NV 0x86F5
+#define GL_DSDT_MAG_NV 0x86F6
+#define GL_DSDT_MAG_VIB_NV 0x86F7
+#define GL_HILO16_NV 0x86F8
+#define GL_SIGNED_HILO_NV 0x86F9
+#define GL_SIGNED_HILO16_NV 0x86FA
+#define GL_SIGNED_RGBA_NV 0x86FB
+#define GL_SIGNED_RGBA8_NV 0x86FC
+#define GL_SIGNED_RGB_NV 0x86FE
+#define GL_SIGNED_RGB8_NV 0x86FF
+#define GL_SIGNED_LUMINANCE_NV 0x8701
+#define GL_SIGNED_LUMINANCE8_NV 0x8702
+#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703
+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704
+#define GL_SIGNED_ALPHA_NV 0x8705
+#define GL_SIGNED_ALPHA8_NV 0x8706
+#define GL_SIGNED_INTENSITY_NV 0x8707
+#define GL_SIGNED_INTENSITY8_NV 0x8708
+#define GL_DSDT8_NV 0x8709
+#define GL_DSDT8_MAG8_NV 0x870A
+#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B
+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C
+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
+#define GL_HI_SCALE_NV 0x870E
+#define GL_LO_SCALE_NV 0x870F
+#define GL_DS_SCALE_NV 0x8710
+#define GL_DT_SCALE_NV 0x8711
+#define GL_MAGNITUDE_SCALE_NV 0x8712
+#define GL_VIBRANCE_SCALE_NV 0x8713
+#define GL_HI_BIAS_NV 0x8714
+#define GL_LO_BIAS_NV 0x8715
+#define GL_DS_BIAS_NV 0x8716
+#define GL_DT_BIAS_NV 0x8717
+#define GL_MAGNITUDE_BIAS_NV 0x8718
+#define GL_VIBRANCE_BIAS_NV 0x8719
+#define GL_TEXTURE_BORDER_VALUES_NV 0x871A
+#define GL_TEXTURE_HI_SIZE_NV 0x871B
+#define GL_TEXTURE_LO_SIZE_NV 0x871C
+#define GL_TEXTURE_DS_SIZE_NV 0x871D
+#define GL_TEXTURE_DT_SIZE_NV 0x871E
+#define GL_TEXTURE_MAG_SIZE_NV 0x871F
+#define GL_NV_texture_shader2 1
+#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA
+#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB
+#define GL_DSDT_MAG_INTENSITY_NV 0x86DC
+#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF
+#define GL_HILO_NV 0x86F4
+#define GL_DSDT_NV 0x86F5
+#define GL_DSDT_MAG_NV 0x86F6
+#define GL_DSDT_MAG_VIB_NV 0x86F7
+#define GL_HILO16_NV 0x86F8
+#define GL_SIGNED_HILO_NV 0x86F9
+#define GL_SIGNED_HILO16_NV 0x86FA
+#define GL_SIGNED_RGBA_NV 0x86FB
+#define GL_SIGNED_RGBA8_NV 0x86FC
+#define GL_SIGNED_RGB_NV 0x86FE
+#define GL_SIGNED_RGB8_NV 0x86FF
+#define GL_SIGNED_LUMINANCE_NV 0x8701
+#define GL_SIGNED_LUMINANCE8_NV 0x8702
+#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703
+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704
+#define GL_SIGNED_ALPHA_NV 0x8705
+#define GL_SIGNED_ALPHA8_NV 0x8706
+#define GL_SIGNED_INTENSITY_NV 0x8707
+#define GL_SIGNED_INTENSITY8_NV 0x8708
+#define GL_DSDT8_NV 0x8709
+#define GL_DSDT8_MAG8_NV 0x870A
+#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B
+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C
+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
+#define GL_NV_texture_shader3 1
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853
+#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854
+#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857
+#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858
+#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859
+#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A
+#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B
+#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C
+#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D
+#define GL_HILO8_NV 0x885E
+#define GL_SIGNED_HILO8_NV 0x885F
+#define GL_FORCE_BLUE_TO_ONE_NV 0x8860
+#define GL_NV_vertex_array_range 1
+#define GL_VERTEX_ARRAY_RANGE_NV 0x851D
+#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E
+#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F
+#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520
+#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521
+#define GL_NV_vertex_array_range2 1
+#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533
+#define GL_NV_vertex_program 1
+#define GL_VERTEX_PROGRAM_NV 0x8620
+#define GL_VERTEX_STATE_PROGRAM_NV 0x8621
+#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623
+#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624
+#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625
+#define GL_CURRENT_ATTRIB_NV 0x8626
+#define GL_PROGRAM_LENGTH_NV 0x8627
+#define GL_PROGRAM_STRING_NV 0x8628
+#define GL_MODELVIEW_PROJECTION_NV 0x8629
+#define GL_IDENTITY_NV 0x862A
+#define GL_INVERSE_NV 0x862B
+#define GL_TRANSPOSE_NV 0x862C
+#define GL_INVERSE_TRANSPOSE_NV 0x862D
+#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E
+#define GL_MAX_TRACK_MATRICES_NV 0x862F
+#define GL_MATRIX0_NV 0x8630
+#define GL_MATRIX1_NV 0x8631
+#define GL_MATRIX2_NV 0x8632
+#define GL_MATRIX3_NV 0x8633
+#define GL_MATRIX4_NV 0x8634
+#define GL_MATRIX5_NV 0x8635
+#define GL_MATRIX6_NV 0x8636
+#define GL_MATRIX7_NV 0x8637
+#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640
+#define GL_CURRENT_MATRIX_NV 0x8641
+#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643
+#define GL_PROGRAM_PARAMETER_NV 0x8644
+#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645
+#define GL_PROGRAM_TARGET_NV 0x8646
+#define GL_PROGRAM_RESIDENT_NV 0x8647
+#define GL_TRACK_MATRIX_NV 0x8648
+#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649
+#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A
+#define GL_PROGRAM_ERROR_POSITION_NV 0x864B
+#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650
+#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651
+#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652
+#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653
+#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654
+#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655
+#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656
+#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657
+#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658
+#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659
+#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A
+#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B
+#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C
+#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D
+#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E
+#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F
+#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660
+#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661
+#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662
+#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663
+#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664
+#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665
+#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666
+#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667
+#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668
+#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669
+#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A
+#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B
+#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C
+#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D
+#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E
+#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F
+#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670
+#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671
+#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672
+#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673
+#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674
+#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675
+#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676
+#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677
+#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678
+#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679
+#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A
+#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B
+#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C
+#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D
+#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E
+#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F
+#define GL_NV_vertex_program1_1 1
+#define GL_NV_vertex_program2 1
+#define GL_NV_vertex_program2_option 1
+#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4
+#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5
+#define GL_NV_vertex_program3 1
+#define GL_OML_interlace 1
+#define GL_INTERLACE_OML 0x8980
+#define GL_INTERLACE_READ_OML 0x8981
+#define GL_OML_resample 1
+#define GL_PACK_RESAMPLE_OML 0x8984
+#define GL_UNPACK_RESAMPLE_OML 0x8985
+#define GL_RESAMPLE_REPLICATE_OML 0x8986
+#define GL_RESAMPLE_ZERO_FILL_OML 0x8987
+#define GL_RESAMPLE_AVERAGE_OML 0x8988
+#define GL_RESAMPLE_DECIMATE_OML 0x8989
+#define GL_OML_subsample 1
+#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982
+#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983
+#define GL_PGI_misc_hints 1
+#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000
+#define GL_CONSERVE_MEMORY_HINT_PGI 107005
+#define GL_RECLAIM_MEMORY_HINT_PGI 107006
+#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010
+#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011
+#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012
+#define GL_ALWAYS_FAST_HINT_PGI 107020
+#define GL_ALWAYS_SOFT_HINT_PGI 107021
+#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022
+#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023
+#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024
+#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025
+#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030
+#define GL_STRICT_LIGHTING_HINT_PGI 107031
+#define GL_STRICT_SCISSOR_HINT_PGI 107032
+#define GL_FULL_STIPPLE_HINT_PGI 107033
+#define GL_CLIP_NEAR_HINT_PGI 107040
+#define GL_CLIP_FAR_HINT_PGI 107041
+#define GL_WIDE_LINE_HINT_PGI 107042
+#define GL_BACK_NORMALS_HINT_PGI 107043
+#define GL_PGI_vertex_hints 1
+#define GL_VERTEX23_BIT_PGI 0x00000004
+#define GL_VERTEX4_BIT_PGI 0x00000008
+#define GL_COLOR3_BIT_PGI 0x00010000
+#define GL_COLOR4_BIT_PGI 0x00020000
+#define GL_EDGEFLAG_BIT_PGI 0x00040000
+#define GL_INDEX_BIT_PGI 0x00080000
+#define GL_MAT_AMBIENT_BIT_PGI 0x00100000
+#define GL_VERTEX_DATA_HINT_PGI 107050
+#define GL_VERTEX_CONSISTENT_HINT_PGI 107051
+#define GL_MATERIAL_SIDE_HINT_PGI 107052
+#define GL_MAX_VERTEX_HINT_PGI 107053
+#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000
+#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000
+#define GL_MAT_EMISSION_BIT_PGI 0x00800000
+#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000
+#define GL_MAT_SHININESS_BIT_PGI 0x02000000
+#define GL_MAT_SPECULAR_BIT_PGI 0x04000000
+#define GL_NORMAL_BIT_PGI 0x08000000
+#define GL_TEXCOORD1_BIT_PGI 0x10000000
+#define GL_TEXCOORD2_BIT_PGI 0x20000000
+#define GL_TEXCOORD3_BIT_PGI 0x40000000
+#define GL_TEXCOORD4_BIT_PGI 0x80000000
+#define GL_REND_screen_coordinates 1
+#define GL_SCREEN_COORDINATES_REND 0x8490
+#define GL_INVERTED_SCREEN_W_REND 0x8491
+#define GL_S3_s3tc 1
+#define GL_RGB_S3TC 0x83A0
+#define GL_RGB4_S3TC 0x83A1
+#define GL_RGBA_S3TC 0x83A2
+#define GL_RGBA4_S3TC 0x83A3
+#define GL_RGBA_DXT5_S3TC 0x83A4
+#define GL_RGBA4_DXT5_S3TC 0x83A5
+#define GL_SGIS_color_range 1
+#define GL_EXTENDED_RANGE_SGIS 0x85A5
+#define GL_MIN_RED_SGIS 0x85A6
+#define GL_MAX_RED_SGIS 0x85A7
+#define GL_MIN_GREEN_SGIS 0x85A8
+#define GL_MAX_GREEN_SGIS 0x85A9
+#define GL_MIN_BLUE_SGIS 0x85AA
+#define GL_MAX_BLUE_SGIS 0x85AB
+#define GL_MIN_ALPHA_SGIS 0x85AC
+#define GL_MAX_ALPHA_SGIS 0x85AD
+#define GL_SGIS_detail_texture 1
+#define GL_SGIS_fog_function 1
+#define GL_SGIS_generate_mipmap 1
+#define GL_GENERATE_MIPMAP_SGIS 0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
+#define GL_SGIS_multisample 1
+#define GL_MULTISAMPLE_SGIS 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F
+#define GL_SAMPLE_MASK_SGIS 0x80A0
+#define GL_1PASS_SGIS 0x80A1
+#define GL_2PASS_0_SGIS 0x80A2
+#define GL_2PASS_1_SGIS 0x80A3
+#define GL_4PASS_0_SGIS 0x80A4
+#define GL_4PASS_1_SGIS 0x80A5
+#define GL_4PASS_2_SGIS 0x80A6
+#define GL_4PASS_3_SGIS 0x80A7
+#define GL_SAMPLE_BUFFERS_SGIS 0x80A8
+#define GL_SAMPLES_SGIS 0x80A9
+#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA
+#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB
+#define GL_SAMPLE_PATTERN_SGIS 0x80AC
+#define GL_MULTISAMPLE_BIT_EXT 0x20000000
+#define GL_SGIS_pixel_texture 1
+#define GL_SGIS_sharpen_texture 1
+#define GL_SGIS_texture4D 1
+#define GL_SGIS_texture_border_clamp 1
+#define GL_CLAMP_TO_BORDER_SGIS 0x812D
+#define GL_SGIS_texture_edge_clamp 1
+#define GL_CLAMP_TO_EDGE_SGIS 0x812F
+#define GL_SGIS_texture_filter4 1
+#define GL_SGIS_texture_lod 1
+#define GL_TEXTURE_MIN_LOD_SGIS 0x813A
+#define GL_TEXTURE_MAX_LOD_SGIS 0x813B
+#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C
+#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D
+#define GL_SGIS_texture_select 1
+#define GL_SGIX_async 1
+#define GL_ASYNC_MARKER_SGIX 0x8329
+#define GL_SGIX_async_histogram 1
+#define GL_ASYNC_HISTOGRAM_SGIX 0x832C
+#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D
+#define GL_SGIX_async_pixel 1
+#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C
+#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D
+#define GL_ASYNC_READ_PIXELS_SGIX 0x835E
+#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F
+#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360
+#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361
+#define GL_SGIX_blend_alpha_minmax 1
+#define GL_ALPHA_MIN_SGIX 0x8320
+#define GL_ALPHA_MAX_SGIX 0x8321
+#define GL_SGIX_clipmap 1
+#define GL_SGIX_depth_texture 1
+#define GL_DEPTH_COMPONENT16_SGIX 0x81A5
+#define GL_DEPTH_COMPONENT24_SGIX 0x81A6
+#define GL_DEPTH_COMPONENT32_SGIX 0x81A7
+#define GL_SGIX_flush_raster 1
+#define GL_SGIX_fog_offset 1
+#define GL_FOG_OFFSET_SGIX 0x8198
+#define GL_FOG_OFFSET_VALUE_SGIX 0x8199
+#define GL_SGIX_fog_texture 1
+#define GL_TEXTURE_FOG_SGIX 0
+#define GL_FOG_PATCHY_FACTOR_SGIX 0
+#define GL_FRAGMENT_FOG_SGIX 0
+#define GL_SGIX_fragment_specular_lighting 1
+#define GL_SGIX_framezoom 1
+#define GL_SGIX_interlace 1
+#define GL_INTERLACE_SGIX 0x8094
+#define GL_SGIX_ir_instrument1 1
+#define GL_SGIX_list_priority 1
+#define GL_SGIX_pixel_texture 1
+#define GL_SGIX_pixel_texture_bits 1
+#define GL_SGIX_reference_plane 1
+#define GL_SGIX_resample 1
+#define GL_PACK_RESAMPLE_SGIX 0x842E
+#define GL_UNPACK_RESAMPLE_SGIX 0x842F
+#define GL_RESAMPLE_DECIMATE_SGIX 0x8430
+#define GL_RESAMPLE_REPLICATE_SGIX 0x8433
+#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434
+#define GL_SGIX_shadow 1
+#define GL_TEXTURE_COMPARE_SGIX 0x819A
+#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B
+#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C
+#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D
+#define GL_SGIX_shadow_ambient 1
+#define GL_SHADOW_AMBIENT_SGIX 0x80BF
+#define GL_SGIX_sprite 1
+#define GL_SGIX_tag_sample_buffer 1
+#define GL_SGIX_texture_add_env 1
+#define GL_SGIX_texture_coordinate_clamp 1
+#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369
+#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A
+#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B
+#define GL_SGIX_texture_lod_bias 1
+#define GL_SGIX_texture_multi_buffer 1
+#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E
+#define GL_SGIX_texture_range 1
+#define GL_RGB_SIGNED_SGIX 0x85E0
+#define GL_RGBA_SIGNED_SGIX 0x85E1
+#define GL_ALPHA_SIGNED_SGIX 0x85E2
+#define GL_LUMINANCE_SIGNED_SGIX 0x85E3
+#define GL_INTENSITY_SIGNED_SGIX 0x85E4
+#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5
+#define GL_RGB16_SIGNED_SGIX 0x85E6
+#define GL_RGBA16_SIGNED_SGIX 0x85E7
+#define GL_ALPHA16_SIGNED_SGIX 0x85E8
+#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9
+#define GL_INTENSITY16_SIGNED_SGIX 0x85EA
+#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB
+#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC
+#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED
+#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE
+#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF
+#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0
+#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1
+#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2
+#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3
+#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4
+#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5
+#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6
+#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7
+#define GL_MIN_LUMINANCE_SGIS 0x85F8
+#define GL_MAX_LUMINANCE_SGIS 0x85F9
+#define GL_MIN_INTENSITY_SGIS 0x85FA
+#define GL_MAX_INTENSITY_SGIS 0x85FB
+#define GL_SGIX_texture_scale_bias 1
+#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179
+#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A
+#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B
+#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C
+#define GL_SGIX_vertex_preclip 1
+#define GL_VERTEX_PRECLIP_SGIX 0x83EE
+#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF
+#define GL_SGIX_vertex_preclip_hint 1
+#define GL_VERTEX_PRECLIP_SGIX 0x83EE
+#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF
+#define GL_SGIX_ycrcb 1
+#define GL_SGI_color_matrix 1
+#define GL_COLOR_MATRIX_SGI 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB
+#define GL_SGI_color_table 1
+#define GL_COLOR_TABLE_SGI 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2
+#define GL_PROXY_COLOR_TABLE_SGI 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5
+#define GL_COLOR_TABLE_SCALE_SGI 0x80D6
+#define GL_COLOR_TABLE_BIAS_SGI 0x80D7
+#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8
+#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF
+#define GL_SGI_texture_color_table 1
+#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC
+#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD
+#define GL_SUNX_constant_data 1
+#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5
+#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6
+#define GL_SUN_convolution_border_modes 1
+#define GL_WRAP_BORDER_SUN 0x81D4
+#define GL_SUN_global_alpha 1
+#define GL_GLOBAL_ALPHA_SUN 0x81D9
+#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA
+#define GL_SUN_mesh_array 1
+#define GL_QUAD_MESH_SUN 0x8614
+#define GL_TRIANGLE_MESH_SUN 0x8615
+#define GL_SUN_read_video_pixels 1
+#define GL_SUN_slice_accum 1
+#define GL_SLICE_ACCUM_SUN 0x85CC
+#define GL_SUN_triangle_list 1
+#define GL_RESTART_SUN 0x01
+#define GL_REPLACE_MIDDLE_SUN 0x02
+#define GL_REPLACE_OLDEST_SUN 0x03
+#define GL_TRIANGLE_LIST_SUN 0x81D7
+#define GL_REPLACEMENT_CODE_SUN 0x81D8
+#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0
+#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1
+#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2
+#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3
+#define GL_R1UI_V3F_SUN 0x85C4
+#define GL_R1UI_C4UB_V3F_SUN 0x85C5
+#define GL_R1UI_C3F_V3F_SUN 0x85C6
+#define GL_R1UI_N3F_V3F_SUN 0x85C7
+#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8
+#define GL_R1UI_T2F_V3F_SUN 0x85C9
+#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA
+#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB
+#define GL_SUN_vertex 1
+#define GL_WIN_phong_shading 1
+#define GL_PHONG_WIN 0x80EA
+#define GL_PHONG_HINT_WIN 0x80EB
+#define GL_WIN_specular_fog 1
+#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC
+#define GL_WIN_swap_hint 1
+
+#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
+#define WGL_DRAW_TO_WINDOW_ARB 0x2001
+#define WGL_DRAW_TO_BITMAP_ARB 0x2002
+#define WGL_ACCELERATION_ARB 0x2003
+#define WGL_NEED_PALETTE_ARB 0x2004
+#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
+#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
+#define WGL_SWAP_METHOD_ARB 0x2007
+#define WGL_NUMBER_OVERLAYS_ARB 0x2008
+#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
+#define WGL_TRANSPARENT_ARB 0x200A
+#define WGL_SHARE_DEPTH_ARB 0x200C
+#define WGL_SHARE_STENCIL_ARB 0x200D
+#define WGL_SHARE_ACCUM_ARB 0x200E
+#define WGL_SUPPORT_GDI_ARB 0x200F
+#define WGL_SUPPORT_OPENGL_ARB 0x2010
+#define WGL_DOUBLE_BUFFER_ARB 0x2011
+#define WGL_STEREO_ARB 0x2012
+#define WGL_PIXEL_TYPE_ARB 0x2013
+#define WGL_COLOR_BITS_ARB 0x2014
+#define WGL_RED_BITS_ARB 0x2015
+#define WGL_RED_SHIFT_ARB 0x2016
+#define WGL_GREEN_BITS_ARB 0x2017
+#define WGL_GREEN_SHIFT_ARB 0x2018
+#define WGL_BLUE_BITS_ARB 0x2019
+#define WGL_BLUE_SHIFT_ARB 0x201A
+#define WGL_ALPHA_BITS_ARB 0x201B
+#define WGL_ALPHA_SHIFT_ARB 0x201C
+#define WGL_ACCUM_BITS_ARB 0x201D
+#define WGL_ACCUM_RED_BITS_ARB 0x201E
+#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
+#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
+#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
+#define WGL_DEPTH_BITS_ARB 0x2022
+#define WGL_STENCIL_BITS_ARB 0x2023
+#define WGL_AUX_BUFFERS_ARB 0x2024
+#define WGL_NO_ACCELERATION_ARB 0x2025
+#define WGL_GENERIC_ACCELERATION_ARB 0x2026
+#define WGL_FULL_ACCELERATION_ARB 0x2027
+#define WGL_SWAP_EXCHANGE_ARB 0x2028
+#define WGL_SWAP_COPY_ARB 0x2029
+#define WGL_SWAP_UNDEFINED_ARB 0x202A
+#define WGL_TYPE_RGBA_ARB 0x202B
+#define WGL_TYPE_COLORINDEX_ARB 0x202C
+#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
+#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
+#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
+#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
+#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
+
+#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
+#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
+#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
+#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
+#define WGL_PBUFFER_LARGEST_ARB 0x2033
+#define WGL_PBUFFER_WIDTH_ARB 0x2034
+#define WGL_PBUFFER_HEIGHT_ARB 0x2035
+#define WGL_PBUFFER_LOST_ARB 0x2036
+
+#define WGL_SAMPLE_BUFFERS_ARB 0x2041
+#define WGL_SAMPLES_ARB 0x2042
+
+#endif
--- a/content/canvas/src/nsCanvasRenderingContext2D.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ -2933,19 +2933,17 @@ nsCanvasRenderingContext2D::DrawImage()
     if (!ConvertJSValToXPCObject(getter_AddRefs(imgElt),
                                  NS_GET_IID(nsIDOMElement),
                                  ctx, argv[0]))
         return NS_ERROR_DOM_TYPE_MISMATCH_ERR;
 
     gfxMatrix matrix;
     nsRefPtr<gfxPattern> pattern;
     nsRefPtr<gfxPath> path;
-#ifdef WINCE
-    nsRefPtr<gfxASurface> currentSurface;
-#endif
+
     nsLayoutUtils::SurfaceFromElementResult res =
         nsLayoutUtils::SurfaceFromElement(imgElt);
     if (!res.mSurface)
         return NS_ERROR_NOT_AVAILABLE;
 
 #ifndef WINCE
     // On non-CE, force a copy if we're using drawImage with our destination
     // as a source to work around some Cairo self-copy semantics issues.
@@ -3021,39 +3019,40 @@ nsCanvasRenderingContext2D::DrawImage()
         // XXX ERRMSG we need to report an error to developers here! (bug 329026)
         rv = NS_ERROR_DOM_INDEX_SIZE_ERR;
         goto FINISH;
     }
     
     matrix.Translate(gfxPoint(sx, sy));
     matrix.Scale(sw/dw, sh/dh);
 #ifdef WINCE
-    currentSurface = getter_AddRefs(mThebes->CurrentSurface());
-
     /* cairo doesn't have consistent semantics for drawing a surface onto
      * itself. Specifically, pixman will not preserve the contents when doing
      * the copy. So to get the desired semantics a temporary copy would be needed.
      * Instead we optimize opaque self copies here */
-    if (currentSurface == imgsurf) {
-        if (imgsurf->GetType() == gfxASurface::SurfaceTypeImage) {
-            gfxImageSurface *surf = static_cast<gfxImageSurface*>(imgsurf.get());
-            gfxContext::GraphicsOperator op = mThebes->CurrentOperator();
-            PRBool opaque, unscaled;
-
-            opaque  = surf->Format() == gfxASurface::ImageFormatARGB32 &&
-                (op == gfxContext::OPERATOR_SOURCE);
-            opaque |= surf->Format() == gfxASurface::ImageFormatRGB24  &&
-                (op == gfxContext::OPERATOR_SOURCE || op == gfxContext::OPERATOR_OVER);
-
-            unscaled = sw == dw && sh == dh;
-
-            if (opaque && unscaled) {
-                bitblt(surf, sx, sy, sw, sh, dx, dy);
-                rv = NS_OK;
-                goto FINISH;
+    {
+        nsRefPtr<gfxASurface> csurf = mThebes->CurrentSurface();
+        if (csurf == imgsurf) {
+            if (imgsurf->GetType() == gfxASurface::SurfaceTypeImage) {
+                gfxImageSurface *surf = static_cast<gfxImageSurface*>(imgsurf.get());
+                gfxContext::GraphicsOperator op = mThebes->CurrentOperator();
+                PRBool opaque, unscaled;
+
+                opaque  = surf->Format() == gfxASurface::ImageFormatARGB32 &&
+                    (op == gfxContext::OPERATOR_SOURCE);
+                opaque |= surf->Format() == gfxASurface::ImageFormatRGB24  &&
+                    (op == gfxContext::OPERATOR_SOURCE || op == gfxContext::OPERATOR_OVER);
+
+                unscaled = sw == dw && sh == dh;
+
+                if (opaque && unscaled) {
+                    bitblt(surf, sx, sy, sw, sh, dx, dy);
+                    rv = NS_OK;
+                    goto FINISH;
+                }
             }
         }
     }
 #endif
 
     pattern = new gfxPattern(imgsurf);
     pattern->SetMatrix(matrix);
 
@@ -3242,32 +3241,16 @@ nsCanvasRenderingContext2D::ConvertJSVal
       WrapJS(aContext, JSVAL_TO_OBJECT(aValue), aIID, (void**)aSupports);
 
     return NS_SUCCEEDED(rv);
   }
 
   return JS_FALSE;
 }
 
-/* Check that the rect [x,y,w,h] is a valid subrect of [0,0,realWidth,realHeight]
- * without overflowing any integers and the like.
- */
-PRBool
-CheckSaneSubrectSize (PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h, PRInt32 realWidth, PRInt32 realHeight)
-{
-    if (w <= 0 || h <= 0 || x < 0 || y < 0)
-        return PR_FALSE;
-
-    if (x >= realWidth  || w > (realWidth - x) ||
-        y >= realHeight || h > (realHeight - y))
-        return PR_FALSE;
-
-    return PR_TRUE;
-}
-
 static void
 FlushLayoutForTree(nsIDOMWindow* aWindow)
 {
     nsCOMPtr<nsPIDOMWindow> piWin = do_QueryInterface(aWindow);
     if (!piWin)
         return;
 
     // Note that because FlushPendingNotifications flushes parents, this
@@ -3760,23 +3743,26 @@ nsCanvasRenderingContext2D::CreateImageD
     PRUint32 argc;
     jsval *argv = nsnull;
 
     ncc->GetArgc(&argc);
     ncc->GetArgvPtr(&argv);
 
     JSAutoRequest ar(ctx);
 
-    int32 w, h;
-    if (!JS_ConvertArguments (ctx, argc, argv, "jj", &w, &h))
+    int32 width, height;
+    if (!JS_ConvertArguments (ctx, argc, argv, "jj", &width, &height))
         return NS_ERROR_DOM_SYNTAX_ERR;
 
-    if (w <= 0 || h <= 0)
+    if (width <= 0 || height <= 0)
         return NS_ERROR_DOM_INDEX_SIZE_ERR;
 
+    PRUint32 w = (PRUint32) width;
+    PRUint32 h = (PRUint32) height;
+
     // check for overflow when calculating len
     PRUint32 len0 = w * h;
     if (len0 / w != (PRUint32) h)
         return NS_ERROR_DOM_INDEX_SIZE_ERR;
     PRUint32 len = len0 * 4;
     if (len / 4 != len0)
         return NS_ERROR_DOM_INDEX_SIZE_ERR;
 
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/nsCanvasRenderingContextGL.cpp
@@ -0,0 +1,1071 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Vladimir Vukicevic <vladimir@pobox.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "prmem.h"
+#include "prlog.h"
+
+#include "nsCanvasRenderingContextGL.h"
+
+#include "nsICanvasRenderingContextGL.h"
+
+#include "nsIRenderingContext.h"
+
+#include "nsICanvasRenderingContextInternal.h"
+#include "nsIDOMHTMLCanvasElement.h"
+#include "nsIView.h"
+#include "nsIViewManager.h"
+
+#include "nsIDocument.h"
+
+#include "nsTransform2D.h"
+
+#include "nsIScriptSecurityManager.h"
+#include "nsISecurityCheckedComponent.h"
+
+#include "imgIRequest.h"
+#include "imgIContainer.h"
+#include "gfxIImageFrame.h"
+#include "nsIDOMHTMLCanvasElement.h"
+#include "nsICanvasElement.h"
+#include "nsIDOMHTMLImageElement.h"
+#include "nsIImageLoadingContent.h"
+#include "nsIInterfaceRequestorUtils.h"
+#include "nsIImage.h"
+#include "nsDOMError.h"
+#include "nsIJSRuntimeService.h"
+
+#include "imgIEncoder.h"
+
+#include "nsIPrefService.h"
+
+#include "nsIClassInfoImpl.h"
+
+#include "nsComponentManagerUtils.h"
+#include "nsServiceManagerUtils.h"
+
+#include "nsDOMError.h"
+
+#include "nsIXPConnect.h"
+#include "jsapi.h"
+#include "jsarray.h"
+
+#include "nsIDOMDocument.h"
+#include "nsIDOMDocumentEvent.h"
+#include "nsIDOMEvent.h"
+#include "nsIDOMEventTarget.h"
+#include "nsIPrivateDOMEvent.h"
+#include "nsIDOMDataContainerEvent.h"
+
+#include "nsLayoutUtils.h"
+
+#ifdef ARGH_NEED_SEPARATE_SERVICE
+#include "nsIContentURIGrouper.h"
+#include "nsIContentPrefService.h"
+#endif
+
+// we're hoping that something is setting us up the remap
+
+#include "gfxContext.h"
+#include "gfxASurface.h"
+
+#ifdef XP_WIN
+#include "gfxWindowsSurface.h"
+#endif
+
+#ifdef XP_MACOSX
+#include "gfxQuartzImageSurface.h"
+#endif
+
+#ifdef MOZ_X11
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#include "cairo-xlib.h"
+#endif
+
+// can't do this due to linkage
+#undef MOZ_MEDIA
+
+#ifndef GL_FRAMEBUFFER
+#define GL_FRAMEBUFFER 0x8D40
+#endif
+
+nsIXPConnect *gXPConnect = nsnull;
+JSRuntime *gScriptRuntime = nsnull;
+nsIJSRuntimeService *gJSRuntimeService = nsnull;
+
+// CanvasGLBuffer
+NS_DECL_CLASSINFO(CanvasGLBuffer)
+NS_IMPL_ADDREF(CanvasGLBuffer)
+NS_IMPL_RELEASE(CanvasGLBuffer)
+
+NS_IMPL_CI_INTERFACE_GETTER1(CanvasGLBuffer, nsICanvasRenderingContextGLBuffer)
+
+NS_INTERFACE_MAP_BEGIN(CanvasGLBuffer)
+  NS_INTERFACE_MAP_ENTRY(nsICanvasRenderingContextGLBuffer)
+  NS_INTERFACE_MAP_ENTRY(nsISecurityCheckedComponent)
+  NS_INTERFACE_MAP_ENTRY(nsICanvasGLBuffer)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasRenderingContextGLBuffer)
+  NS_IMPL_QUERY_CLASSINFO(CanvasGLBuffer)
+NS_INTERFACE_MAP_END
+
+// CanvasGLTexture
+NS_DECL_CLASSINFO(CanvasGLTexture)
+NS_IMPL_ADDREF(CanvasGLTexture)
+NS_IMPL_RELEASE(CanvasGLTexture)
+
+NS_IMPL_CI_INTERFACE_GETTER1(CanvasGLTexture, nsICanvasRenderingContextGLTexture)
+
+NS_INTERFACE_MAP_BEGIN(CanvasGLTexture)
+  NS_INTERFACE_MAP_ENTRY(nsICanvasRenderingContextGLTexture)
+  NS_INTERFACE_MAP_ENTRY(nsICanvasGLTexture)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasRenderingContextGLTexture)
+  NS_IMPL_QUERY_CLASSINFO(CanvasGLTexture)
+NS_INTERFACE_MAP_END
+
+/**
+ ** CanvasGLBuffer
+ **/
+
+static int bufferCount = 0;
+
+CanvasGLBuffer::CanvasGLBuffer(nsCanvasRenderingContextGLPrivate *owner)
+    : mDisposed(PR_TRUE),
+      mLength(0), mSize(0), mType(0), mUsage(GL_STATIC_DRAW),
+      mBufferID(0), mMaxUShort(0), mMaxUShortComputed(false)
+{
+    owner->GetWeakReference(getter_AddRefs(mOwnerContext));
+
+    gl = owner->gl;
+
+    bufferCount++;
+    //fprintf (stderr, "VVVV Created; Buffers now: %d\n", bufferCount); fflush(stderr);
+}
+
+CanvasGLBuffer::~CanvasGLBuffer()
+{
+    Dispose();
+
+    --bufferCount;
+    //fprintf (stderr, "VVVV Released; Buffers now: %d\n", bufferCount); fflush(stderr);
+}
+
+/* nsISecurityCheckedComponent bits */
+
+static char* cloneAllAccess()
+{
+    static const char allAccess[] = "allAccess";
+    return (char*)nsMemory::Clone(allAccess, sizeof(allAccess));
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::CanCreateWrapper(const nsIID* iid, char **_retval) {
+    *_retval = cloneAllAccess();
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::CanCallMethod(const nsIID *iid, const PRUnichar *methodName, char **_retval) {
+    *_retval = cloneAllAccess();
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::CanGetProperty(const nsIID *iid, const PRUnichar *propertyName, char **_retval) {
+    *_retval = cloneAllAccess();
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::CanSetProperty(const nsIID *iid, const PRUnichar *propertyName, char **_retval) {
+    *_retval = cloneAllAccess();
+    return NS_OK;
+}
+
+nsresult
+CanvasGLBuffer::Init(PRUint32 usage,
+                     PRUint32 size,
+                     PRUint32 type,
+                     JSContext *ctx,
+                     JSObject *arrayObj,
+                     jsuint arrayLen)
+{
+    nsresult rv;
+
+    //fprintf (stderr, "VVVV CanvasGLBuffer::Init\n");
+
+    if (!mDisposed)
+        Dispose();
+
+    if (usage != GL_STATIC_DRAW &&
+        usage != GL_STREAM_DRAW &&
+        usage != GL_DYNAMIC_DRAW)
+        return NS_ERROR_INVALID_ARG;
+
+    rv = mSimpleBuffer.InitFromJSArray(type, size, ctx, arrayObj, arrayLen);
+    if (NS_FAILED(rv))
+        return rv;
+
+    mUsage = usage;
+    mSize = size;
+    mType = type;
+    mLength = arrayLen;
+
+    mMaxUShortComputed = false;
+    
+    mBufferID = 0;
+
+    mDisposed = PR_FALSE;
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::Dispose()
+{
+    if (mDisposed)
+        return NS_OK;
+
+    if (mBufferID) {
+        nsCOMPtr<nsICanvasRenderingContextInternal> ctx = do_QueryReferent(mOwnerContext);
+        if (ctx) {
+            nsCanvasRenderingContextGLPrivate *priv = (nsCanvasRenderingContextGLPrivate*) ctx.get();
+            priv->MakeContextCurrent();
+
+            gl->fDeleteBuffers(1, &mBufferID);
+            mBufferID = 0;
+        }
+    }
+
+    mSimpleBuffer.Release();
+
+    mDisposed = PR_TRUE;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::GetOwnerContext(nsICanvasRenderingContextGL **retval)
+{
+    nsCOMPtr<nsICanvasRenderingContextInternal> ctx = do_QueryReferent(mOwnerContext);
+    if (ctx) {
+        nsCanvasRenderingContextGLPrivate *priv = (nsCanvasRenderingContextGLPrivate*) ctx.get();
+        *retval = priv->GetSelf();
+    } else {
+        *retval = nsnull;
+    }
+
+    NS_IF_ADDREF(*retval);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::GetDisposed(PRBool *retval)
+{
+    *retval = mDisposed;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::GetUsage(PRUint32 *usage)
+{
+    if (mDisposed)
+        return NS_ERROR_FAILURE;
+
+    *usage = mUsage;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::GetLength(PRUint32 *retval)
+{
+    if (mDisposed)
+        return NS_ERROR_FAILURE;
+
+    *retval = mLength;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLBuffer::GetType(PRUint32 *retval)
+{
+    if (mDisposed)
+        return NS_ERROR_FAILURE;
+
+    *retval = mType;
+    return NS_OK;
+}
+
+/**
+ ** CanvasGLTexture
+ **/
+
+CanvasGLTexture::CanvasGLTexture(nsCanvasRenderingContextGLPrivate *owner)
+    : mDisposed(PR_FALSE),
+      //mGlitzTextureSurface(nsnull), mGlitzTextureObject(nsnull),
+      mWidth(0), mHeight(0)
+{
+    owner->GetWeakReference(getter_AddRefs(mOwnerContext));
+
+    gl = owner->gl;
+}
+
+CanvasGLTexture::~CanvasGLTexture()
+{
+    Dispose();
+}
+
+nsresult
+CanvasGLTexture::Init()
+{
+    return NS_OK;
+}
+
+nsresult
+CanvasGLTexture::Dispose()
+{
+    if (mDisposed)
+        return NS_OK;
+
+    mDisposed = PR_TRUE;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLTexture::GetDisposed(PRBool *retval)
+{
+    *retval = mDisposed;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLTexture::GetOwnerContext(nsICanvasRenderingContextGL **retval)
+{
+    nsCOMPtr<nsICanvasRenderingContextInternal> ctx = do_QueryReferent(mOwnerContext);
+    if (ctx) {
+        nsCanvasRenderingContextGLPrivate *priv = (nsCanvasRenderingContextGLPrivate*) ctx.get();
+        *retval = priv->GetSelf();
+    } else {
+        *retval = nsnull;
+    }
+
+    NS_IF_ADDREF(*retval);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLTexture::GetTarget(PRUint32 *aResult)
+{
+    //*aResult = glitz_texture_object_get_target (mGlitzTextureObject);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLTexture::GetWidth(PRUint32 *aWidth)
+{
+    *aWidth = mWidth;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLTexture::GetHeight(PRUint32 *aHeight)
+{
+    *aHeight = mHeight;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLTexture::SetFilter(PRUint32 filterType, PRUint32 filterMode)
+{
+    if (filterType < 0 || filterType > 1 ||
+        filterMode < 0 || filterMode > 1)
+    {
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    //glitz_texture_object_set_filter (mGlitzTextureObject, (glitz_texture_filter_type_t)filterType, (glitz_texture_filter_t)filterMode);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+CanvasGLTexture::SetWrap(PRUint32 wrapType, PRUint32 wrapMode)
+{
+    if (wrapType != GL_TEXTURE_WRAP_S &&
+        wrapType != GL_TEXTURE_WRAP_T)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    if (wrapMode != GL_CLAMP_TO_EDGE &&
+        wrapMode != GL_REPEAT &&
+        wrapMode != GL_MIRRORED_REPEAT)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    //glitz_texture_object_set_wrap (mGlitzTextureObject, (glitz_texture_wrap_type_t)wrapType, (glitz_texture_wrap_t)wrapMode);
+    return NS_OK;
+}
+
+/*
+ * these got removed accidentally in bug 495499.  We make them just return false here and
+ * take the slow path until we get that fixed up.
+ */
+
+#define FOO(_x,_y) JSBool _x (JSContext *cx, JSObject *obj, jsuint offset, jsuint count, _y *dest) { return 0; }
+
+FOO(js_ArrayToJSUint8Buffer, JSUint8);
+FOO(js_ArrayToJSUint16Buffer, JSUint16);
+FOO(js_ArrayToJSUint32Buffer, JSUint32);
+FOO(js_ArrayToJSInt8Buffer, JSInt8);
+FOO(js_ArrayToJSInt16Buffer, JSInt16);
+FOO(js_ArrayToJSInt32Buffer, JSInt32);
+FOO(js_ArrayToJSDoubleBuffer, jsdouble);
+
+
+PRBool
+SimpleBuffer::InitFromJSArray(PRUint32 typeParam,
+                              PRUint32 sizeParam,
+                              JSContext *ctx,
+                              JSObject *arrayObj,
+                              jsuint arrayLen)
+{
+    if (typeParam == GL_SHORT) {
+        Prepare(typeParam, sizeParam, arrayLen);
+        short *ptr = (short*) data;
+
+        if (!js_ArrayToJSInt16Buffer(ctx, arrayObj, 0, arrayLen, ptr)) {
+            for (PRUint32 i = 0; i < arrayLen; i++) {
+                jsval jv;
+                int32 iv;
+                ::JS_GetElement(ctx, arrayObj, i, &jv);
+                ::JS_ValueToECMAInt32(ctx, jv, &iv);
+                *ptr++ = (short) iv;
+            }
+        }
+    } else if (typeParam == GL_FLOAT) {
+        Prepare(typeParam, sizeParam, arrayLen);
+        float *ptr = (float*) data;
+        double *tmpd = new double[arrayLen];
+        if (js_ArrayToJSDoubleBuffer(ctx, arrayObj, 0, arrayLen, tmpd)) {
+            for (PRUint32 i = 0; i < arrayLen; i++)
+                ptr[i] = (float) tmpd[i];
+        } else {
+            for (PRUint32 i = 0; i < arrayLen; i++) {
+                jsval jv;
+                jsdouble dv;
+                ::JS_GetElement(ctx, arrayObj, i, &jv);
+                ::JS_ValueToNumber(ctx, jv, &dv);
+                *ptr++ = (float) dv;
+            }
+        }
+        delete [] tmpd;
+    } else if (typeParam == GL_UNSIGNED_BYTE) {
+        Prepare(typeParam, sizeParam, arrayLen);
+        unsigned char *ptr = (unsigned char*) data;
+        if (!js_ArrayToJSUint8Buffer(ctx, arrayObj, 0, arrayLen, ptr)) {
+            for (PRUint32 i = 0; i < arrayLen; i++) {
+                jsval jv;
+                uint32 iv;
+                ::JS_GetElement(ctx, arrayObj, i, &jv);
+                ::JS_ValueToECMAUint32(ctx, jv, &iv);
+                *ptr++ = (unsigned char) iv;
+            }
+        }
+    } else if (typeParam == GL_UNSIGNED_SHORT) {
+        Prepare(typeParam, sizeParam, arrayLen);
+        PRUint16 *ptr = (PRUint16*) data;
+        if (!js_ArrayToJSUint16Buffer(ctx, arrayObj, 0, arrayLen, ptr)) {
+            for (PRUint32 i = 0; i < arrayLen; i++) {
+                jsval jv;
+                uint32 iv;
+                ::JS_GetElement(ctx, arrayObj, i, &jv);
+                ::JS_ValueToECMAUint32(ctx, jv, &iv);
+                *ptr++ = (unsigned short) iv;
+            }
+        }
+    } else if (typeParam == GL_UNSIGNED_INT) {
+        Prepare(typeParam, sizeParam, arrayLen);
+        PRUint32 *ptr = (PRUint32*) data;
+        if (!js_ArrayToJSUint32Buffer(ctx, arrayObj, 0, arrayLen, ptr)) {
+            for (PRUint32 i = 0; i < arrayLen; i++) {
+                jsval jv;
+                uint32 iv;
+                ::JS_GetElement(ctx, arrayObj, i, &jv);
+                ::JS_ValueToECMAUint32(ctx, jv, &iv);
+                *ptr++ = iv;
+            }
+        }
+    } else if (typeParam == GL_INT) {
+        Prepare(typeParam, sizeParam, arrayLen);
+        PRInt32 *ptr = (PRInt32*) data;
+        if (!js_ArrayToJSInt32Buffer(ctx, arrayObj, 0, arrayLen, ptr)) {
+            for (PRUint32 i = 0; i < arrayLen; i++) {
+                jsval jv;
+                int32 iv;
+                ::JS_GetElement(ctx, arrayObj, i, &jv);
+                ::JS_ValueToECMAInt32(ctx, jv, &iv);
+                *ptr++ = iv;
+            }
+        }
+    } else {
+        return PR_FALSE;
+    }
+
+    return PR_TRUE;
+}
+
+void
+nsCanvasRenderingContextGLPrivate::MakeContextCurrent()
+{
+    mGLPbuffer->MakeContextCurrent();
+}
+
+void
+nsCanvasRenderingContextGLPrivate::LostCurrentContext(void *closure)
+{
+    //nsCanvasRenderingContextGLPrivate* self = (nsCanvasRenderingContextGLPrivate*) closure;
+}
+
+//
+// nsICanvasRenderingContextInternal
+//
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLPrivate::SetCanvasElement(nsICanvasElement* aParentCanvas)
+{
+    nsresult rv;
+
+    if (aParentCanvas == nsnull) {
+        // we get this on shutdown; we should do some more cleanup here,
+        // but instead we just let our destructor do it.
+        return NS_OK;
+    }
+
+    if (!SafeToCreateCanvas3DContext(aParentCanvas))
+        return NS_ERROR_FAILURE;
+
+    // Let's find our prefs
+    nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    mPrefWireframe = PR_FALSE;
+    PRBool forceSoftware = PR_FALSE;
+
+    nsCOMPtr<nsIPrefBranch> prefBranch;
+    rv = prefService->GetBranch("extensions.canvas3d.", getter_AddRefs(prefBranch));
+    if (NS_SUCCEEDED(rv)) {
+        PRBool val;
+        rv = prefBranch->GetBoolPref("wireframe", &val);
+        if (NS_SUCCEEDED(rv))
+            mPrefWireframe = val;
+
+        rv = prefBranch->GetBoolPref("software_render", &val);
+        if (NS_SUCCEEDED(rv))
+            forceSoftware = val;
+    }
+
+    fprintf (stderr, "Wireframe: %d\n", mPrefWireframe);
+
+
+    LogMessage(NS_LITERAL_CSTRING("Canvas 3D: creating PBuffer..."));
+
+    if (!forceSoftware) {
+#ifdef XP_WIN
+        mGLPbuffer = new nsGLPbufferWGL();
+#elif defined(XP_UNIX) && defined(MOZ_X11)
+        mGLPbuffer = new nsGLPbufferGLX();
+#elif defined(XP_MACOSX)
+        mGLPbuffer = new nsGLPbufferCGL();
+#else
+        mGLPbuffer = nsnull;
+#endif
+
+        if (mGLPbuffer && !mGLPbuffer->Init(this))
+            mGLPbuffer = nsnull;
+    }
+
+    if (!mGLPbuffer) {
+        mGLPbuffer = new nsGLPbufferOSMESA();
+        if (!mGLPbuffer->Init(this))
+            mGLPbuffer = nsnull;
+    }
+
+    if (!mGLPbuffer)
+        return NS_ERROR_FAILURE;
+
+    gl = mGLPbuffer->GL();
+
+    if (!ValidateGL()) {
+        // XXX over here we need to destroy mGLPbuffer and create a mesa buffer
+
+        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Couldn't validate OpenGL implementation; is everything needed present?"));
+        return NS_ERROR_FAILURE;
+    }
+
+    mCanvasElement = aParentCanvas;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLPrivate::SetDimensions(PRInt32 width, PRInt32 height)
+{
+    if (mWidth == width && mHeight == height)
+        return NS_OK;
+
+    if (!mGLPbuffer->Resize(width, height)) {
+        LogMessage(NS_LITERAL_CSTRING("mGLPbuffer->Resize failed"));
+        return NS_ERROR_FAILURE;
+    }
+
+    LogMessage(NS_LITERAL_CSTRING("Canvas 3D: ready"));
+
+    mWidth = width;
+    mHeight = height;
+
+    // Make sure that we clear this out, otherwise
+    // we'll end up displaying random memory
+    MakeContextCurrent();
+    gl->fViewport(0, 0, mWidth, mHeight);
+    gl->fClearColor(0, 0, 0, 0);
+    gl->fClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLPrivate::Render(gfxContext *ctx, gfxPattern::GraphicsFilter f)
+{
+    nsresult rv = NS_OK;
+
+    if (!mGLPbuffer)
+        return NS_OK;
+
+    // use GL Drawing if we can get a target GL context; otherwise
+    // go through the fallback path.
+#ifdef HAVE_GL_DRAWING
+    if (mCanvasElement->GLWidgetBeginDrawing()) {
+        glClearColor(0.0, 0.0, 0.0, 0.0);
+        glClear(GL_COLOR_BUFFER_BIT);
+
+        int bwidth = mGLPbuffer->Width();
+        int bheight = mGLPbuffer->Height();
+
+        GLuint tex = 0;
+        glGenTextures(1, &tex);
+        glBindTexture(GL_TEXTURE_RECTANGLE_EXT, tex);
+
+        CGLError err =
+            CGLTexImagePBuffer(CGLGetCurrentContext(),
+                               ((nsGLPbufferCGL*)mGLPbuffer)->GetCGLPbuffer(),
+                               GL_BACK);
+        if (err) {
+            fprintf (stderr, "CGLTexImagePBuffer failed: %d\n", err);
+            glDeleteTextures(1, &tex);
+            return NS_OK;
+        }
+
+        glEnable(GL_TEXTURE_RECTANGLE_EXT);
+
+        glMatrixMode(GL_PROJECTION);
+        glLoadIdentity();
+        //glFrustum(-halfWidth, halfWidth, halfHeight, -halfHeight, 1.0, 100000.0);
+        glOrtho(0, bwidth, bheight, 0, -0.5, 10.0);
+
+        glMatrixMode(GL_MODELVIEW);
+        glLoadIdentity();
+
+        glBegin(GL_QUADS);
+
+        /* Note that the texture needs a y-flip */
+        glTexCoord2f(0.0, bheight);
+        glVertex3f(0.0, 0.0, 0.0);
+
+        glTexCoord2f(bwidth, bheight);
+        glVertex3f(bwidth, 0.0, 0.0);
+
+        glTexCoord2f(bwidth, 0);
+        glVertex3f(bwidth, bheight, 0.0);
+
+        glTexCoord2f(0.0, 0);
+        glVertex3f(0.0, bheight, 0.0);
+
+        glEnd();
+
+        glDisable(GL_TEXTURE_RECTANGLE_EXT);
+        glDeleteTextures(1, &tex);
+
+        mCanvasElement->GLWidgetSwapBuffers();
+        mCanvasElement->GLWidgetEndDrawing();
+    } else
+#endif
+    {
+        nsRefPtr<gfxASurface> surf = mGLPbuffer->ThebesSurface();
+        if (!surf)
+            return NS_OK;
+
+        nsRefPtr<gfxPattern> pat = CanvasGLThebes::CreatePattern(surf);
+        gfxMatrix m;
+        m.Translate(gfxPoint(0.0, mGLPbuffer->Height()));
+        m.Scale(1.0, -1.0);
+        pat->SetMatrix(m);
+
+        // XXX I don't want to use PixelSnapped here, but layout doesn't guarantee
+        // pixel alignment for this stuff!
+        ctx->NewPath();
+        ctx->PixelSnappedRectangleAndSetPattern(gfxRect(0, 0, mWidth, mHeight), pat);
+        ctx->Fill();
+    }
+    return rv;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLPrivate::GetInputStream(const char* aMimeType,
+                                                  const PRUnichar* aEncoderOptions,
+                                                  nsIInputStream **aStream)
+{
+    // XXX disabled for now due to the win32 nsRefPtr situation -- we need
+    // to manage allocations and deletions very carefully, and can't allocate
+    // an object in our dll and have xul.dll call delete on it (which
+    // Release() will do).
+    return NS_ERROR_FAILURE;
+
+#if 0
+    if (!mGLPbuffer ||
+        !mGLPbuffer->ThebesSurface())
+        return NS_ERROR_FAILURE;
+
+    nsresult rv;
+    const char encoderPrefix[] = "@mozilla.org/image/encoder;2?type=";
+    nsAutoArrayPtr<char> conid(new (std::nothrow) char[strlen(encoderPrefix) + strlen(aMimeType) + 1]);
+
+    if (!conid)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    strcpy(conid, encoderPrefix);
+    strcat(conid, aMimeType);
+
+    nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(conid);
+    if (!encoder)
+        return NS_ERROR_FAILURE;
+
+    nsAutoArrayPtr<PRUint8> imageBuffer(new (std::nothrow) PRUint8[mWidth * mHeight * 4]);
+    if (!imageBuffer)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    nsRefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(imageBuffer.get(),
+                                                            gfxIntSize(mWidth, mHeight),
+                                                            mWidth * 4,
+                                                            gfxASurface::ImageFormatARGB32);
+
+    if (!imgsurf || imgsurf->CairoStatus())
+        return NS_ERROR_FAILURE;
+
+    nsRefPtr<gfxContext> ctx = new gfxContext(imgsurf);
+
+    if (!ctx || ctx->HasError())
+        return NS_ERROR_FAILURE;
+
+    nsRefPtr<gfxASurface> surf = mGLPbuffer->ThebesSurface();
+    nsRefPtr<gfxPattern> pat = CanvasGLThebes::CreatePattern(surf);
+    gfxMatrix m;
+    m.Translate(gfxPoint(0.0, mGLPbuffer->Height()));
+    m.Scale(1.0, -1.0);
+    pat->SetMatrix(m);
+
+    // XXX I don't want to use PixelSnapped here, but layout doesn't guarantee
+    // pixel alignment for this stuff!
+    ctx->NewPath();
+    ctx->PixelSnappedRectangleAndSetPattern(gfxRect(0, 0, mWidth, mHeight), pat);
+    ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
+    ctx->Fill();
+
+    rv = encoder->InitFromData(imageBuffer.get(),
+                               mWidth * mHeight * 4, mWidth, mHeight, mWidth * 4,
+                               imgIEncoder::INPUT_FORMAT_HOSTARGB,
+                               nsDependentString(aEncoderOptions));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    return CallQueryInterface(encoder, aStream);
+#endif
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLPrivate::GetThebesSurface(gfxASurface **surface)
+{
+    if (!mGLPbuffer) {
+        *surface = nsnull;
+        return NS_ERROR_NOT_AVAILABLE;
+    }
+
+    *surface = mGLPbuffer->ThebesSurface();
+    NS_IF_ADDREF(*surface);
+    return NS_OK;
+}
+
+nsCanvasRenderingContextGLPrivate::nsCanvasRenderingContextGLPrivate()
+    : mGLPbuffer(nsnull), mWidth(0), mHeight(0), mCanvasElement(nsnull)
+{
+    // grab the xpconnect service
+    if (!gXPConnect) {
+        nsresult rv = CallGetService(nsIXPConnect::GetCID(), &gXPConnect);
+        if (NS_FAILED(rv)) {
+            NS_ERROR("Failed to get XPConnect!");
+            return;
+        }
+    } else {
+        NS_ADDREF(gXPConnect);
+    }
+
+    if (!gJSRuntimeService) {
+        nsresult rv = CallGetService("@mozilla.org/js/xpc/RuntimeService;1",
+                                     &gJSRuntimeService);
+        if (NS_FAILED(rv)) {
+            // uh..
+            NS_ERROR("Failed to get JS RuntimeService!");
+            return;
+        }
+
+        gJSRuntimeService->GetRuntime(&gScriptRuntime);
+        if (!gScriptRuntime) {
+            NS_RELEASE(gJSRuntimeService);
+            gJSRuntimeService = nsnull;
+            NS_ERROR("Unable to get JS runtime from JS runtime service");
+        }
+    } else {
+        NS_ADDREF(gJSRuntimeService);
+    }
+}
+
+nsCanvasRenderingContextGLPrivate::~nsCanvasRenderingContextGLPrivate()
+{
+    delete mGLPbuffer;
+    mGLPbuffer = nsnull;
+    
+    // get rid of the context
+    if (gXPConnect && gXPConnect->Release() == 0)
+        gXPConnect = nsnull;
+    if (gJSRuntimeService && gJSRuntimeService->Release() == 0) {
+        gJSRuntimeService = nsnull;
+        gScriptRuntime = nsnull;
+    }
+}
+
+nsresult
+nsCanvasRenderingContextGLPrivate::DoSwapBuffers()
+{
+    mGLPbuffer->SwapBuffers();
+
+    // then invalidate the region and do a redraw
+    if (!mCanvasElement)
+        return NS_OK;
+
+    mCanvasElement->InvalidateFrame();
+    return NS_OK;
+}
+
+PRBool
+nsCanvasRenderingContextGLPrivate::SafeToCreateCanvas3DContext(nsICanvasElement *canvasElement)
+{
+    nsresult rv;
+
+    // first see if we're a chrome context
+    PRBool is_caller_chrome = PR_FALSE;
+    nsCOMPtr<nsIScriptSecurityManager> ssm =
+        do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    rv = ssm->SubjectPrincipalIsSystem(&is_caller_chrome);
+    if (NS_SUCCEEDED(rv) && is_caller_chrome)
+        return PR_TRUE;
+
+    // not chrome? check pref.
+
+    // first check our global pref
+    nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    PRBool allSites = PR_FALSE;
+    rv = prefService->GetBoolPref("extensions.canvas3d.enabled_for_all_sites", &allSites);
+    if (NS_SUCCEEDED(rv) && allSites) {
+        // the all-sites pref was set, we're good to go
+        return PR_TRUE;
+    }
+
+    // otherwise we'll check content prefs
+
+#ifdef ARGH_NEED_SEPARATE_SERVICE
+    // the content pref service IID changed after 3.1b3, so this will fail for nightly builds.
+    nsCOMPtr<nsIContentPrefService> cpsvc = do_GetService("@mozilla.org/content-pref/service;1", &rv);
+    if (NS_FAILED(rv)) {
+        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Failed to get Content Pref service.  If you are running Firefox 3.1b3, as a temporary fix until 3.5b4 is released, open the Canvas 3D Addon preferences and check the \"Enabled for all sites\" checkbox."));
+        return PR_FALSE;
+    }
+
+    // grab our content URI
+    nsCOMPtr<nsIURI> contentURI;
+
+    nsCOMPtr<nsIPrincipal> principal;
+    rv = ssm->GetSubjectPrincipal(getter_AddRefs(principal));
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    if (!principal) {
+        // seriously? no script executing, but not the system principal?
+        return PR_FALSE;
+    }
+    rv = principal->GetURI(getter_AddRefs(contentURI));
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    // our pref is 'canvas3d.enabled'
+    nsCOMPtr<nsIVariant> val;
+    rv = cpsvc->GetPref(contentURI, NS_LITERAL_STRING("canvas3d.enabled"), getter_AddRefs(val));
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    PRInt32 iv;
+    rv = val->GetAsInt32(&iv);
+    if (NS_SUCCEEDED(rv)) {
+        // 1 means "yes, allowed"
+        if (iv == 1)
+            return PR_TRUE;
+
+        // -1 means "no, don't ask me again"
+        if (iv == -1)
+            return PR_FALSE;
+
+        // otherwise, we'll throw an event and maybe ask the user
+    }
+
+    // grab the document that we can use to create the event
+    nsCOMPtr<nsIDOMNode> node = do_QueryInterface(canvasElement);
+    nsCOMPtr<nsIDOMDocument> domDoc;
+    rv = node->GetOwnerDocument(getter_AddRefs(domDoc));
+
+    /*
+    // figure out where to throw the event.  we just go for the outermost
+    // document.  ideally, I want to throw the event to the <browser> if one exists,
+    // otherwise the topmost document, but that's more work than I want to deal with.
+    nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
+    while (doc->GetParentDocument())
+        doc = doc->GetParentDocument();
+    */
+
+    // set up the event
+    nsCOMPtr<nsIDOMDocumentEvent> docEvent = do_QueryInterface(domDoc);
+    NS_ENSURE_TRUE(docEvent, PR_FALSE);
+
+    nsCOMPtr<nsIDOMEvent> eventBase;
+    rv = docEvent->CreateEvent(NS_LITERAL_STRING("DataContainerEvent"), getter_AddRefs(eventBase));
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    rv = eventBase->InitEvent(NS_LITERAL_STRING("Canvas3DContextRequest"), PR_TRUE, PR_TRUE);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    nsCOMPtr<nsIDOMDataContainerEvent> event = do_QueryInterface(eventBase);
+    nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(eventBase);
+    NS_ENSURE_TRUE(event && privateEvent, PR_FALSE);
+
+    // mark it as trusted, so that it'll bubble upwards into chrome
+    privateEvent->SetTrusted(PR_TRUE);
+
+    // set some extra data on the event
+    nsCOMPtr<nsIContentURIGrouper> grouper = do_GetService("@mozilla.org/content-pref/hostname-grouper;1", &rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    nsAutoString group;
+    rv = grouper->Group(contentURI, group);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    nsCOMPtr<nsIWritableVariant> groupVariant = do_CreateInstance(NS_VARIANT_CONTRACTID);
+    nsCOMPtr<nsIWritableVariant> uriVariant = do_CreateInstance(NS_VARIANT_CONTRACTID);
+
+    groupVariant->SetAsAString(group);
+    uriVariant->SetAsISupports(contentURI);
+
+    rv = event->SetData(NS_LITERAL_STRING("group"), groupVariant);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    rv = event->SetData(NS_LITERAL_STRING("uri"), uriVariant);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    // our target...
+    nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(canvasElement);
+
+    // and go.
+    PRBool defaultActionEnabled;
+    targ->DispatchEvent(event, &defaultActionEnabled);
+#endif
+
+    return PR_FALSE;
+}
+
+gfxImageSurface *
+CanvasGLThebes::CreateImageSurface (const gfxIntSize &isize,
+                                    gfxASurface::gfxImageFormat fmt)
+{
+    /*void *p = NS_Alloc(sizeof(gfxImageSurface));*/
+    return new /*(p)*/ gfxImageSurface (isize, fmt);
+}
+
+gfxContext *
+CanvasGLThebes::CreateContext (gfxASurface *surf)
+{
+    void *p = NS_Alloc(sizeof(gfxContext));
+    return new (p) gfxContext (surf);
+}
+
+gfxPattern *
+CanvasGLThebes::CreatePattern (gfxASurface *surf)
+{
+    /*void *p = NS_Alloc(sizeof(gfxPattern));*/
+    return new /*(p)*/ gfxPattern(surf);
+}
+
+/*
+ * We need this here, because nsAString has a different type name based on whether it's
+ * used internally or externally.  BeginPrinting isn't ever called, but gfxImageSurface
+ * wants to inherit the default definition, and it can't find it.  So instead, we just
+ * stick a stub here to shut the compiler up, because we never call this method.
+ */
+
+#ifdef XP_WIN
+nsresult
+gfxWindowsSurface::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+nsresult
+gfxASurface::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+#endif
+
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/nsCanvasRenderingContextGL.h
@@ -0,0 +1,425 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Vladimir Vukicevic <vladimir@pobox.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _NSCANVASRENDERINGCONTEXTGL_H_
+#define _NSCANVASRENDERINGCONTEXTGL_H_
+
+#ifdef C3D_STANDALONE_BUILD
+#include "c3d-standalone.h"
+#endif
+
+#include "nsICanvasRenderingContextGL.h"
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "prmem.h"
+
+#include "nsStringGlue.h"
+
+#include "nsICanvasRenderingContextGLBuffer.h"
+#include "nsICanvasRenderingContextInternal.h"
+#include "nsIDOMHTMLCanvasElement.h"
+
+#include "nsICanvasGLPrivate.h"
+
+#include "nsIScriptSecurityManager.h"
+#include "nsISecurityCheckedComponent.h"
+
+#include "nsWeakReference.h"
+
+#include "imgIRequest.h"
+#include "imgIContainer.h"
+#include "gfxIImageFrame.h"
+#include "nsIDOMHTMLCanvasElement.h"
+#include "nsICanvasElement.h"
+#include "nsIDOMHTMLImageElement.h"
+#include "nsIImageLoadingContent.h"
+#include "nsIInterfaceRequestorUtils.h"
+#include "nsIImage.h"
+#include "nsDOMError.h"
+#include "nsIJSRuntimeService.h"
+
+#include "nsIServiceManager.h"
+#include "nsIConsoleService.h"
+
+#include "nsDOMError.h"
+
+#include "nsServiceManagerUtils.h"
+
+#include "nsIXPConnect.h"
+#include "jsapi.h"
+
+#include "gfxContext.h"
+
+#include "nsGLPbuffer.h"
+
+extern nsIXPConnect *gXPConnect;
+extern JSRuntime *gScriptRuntime;
+extern nsIJSRuntimeService *gJSRuntimeService;
+
+class nsICanvasRenderingContextGL;
+
+class nsCanvasRenderingContextGLES11;
+class nsCanvasRenderingContextGLWeb20;
+
+class CanvasGLBuffer;
+class CanvasGLTexture;
+
+class nsCanvasRenderingContextGLPrivate :
+    public nsICanvasRenderingContextInternal,
+    public nsSupportsWeakReference
+{
+    friend class nsGLPbuffer;
+    friend class CanvasGLBuffer;
+    friend class CanvasGLTexture;
+
+public:
+    nsCanvasRenderingContextGLPrivate();
+    virtual ~nsCanvasRenderingContextGLPrivate();
+
+    virtual nsICanvasRenderingContextGL *GetSelf() = 0;
+
+    virtual PRBool ValidateGL() { return PR_TRUE; }
+
+    void MakeContextCurrent();
+    static void LostCurrentContext(void *closure);
+
+    // nsICanvasRenderingContextInternal
+    NS_IMETHOD SetCanvasElement(nsICanvasElement* aParentCanvas);
+    NS_IMETHOD SetDimensions(PRInt32 width, PRInt32 height);
+    NS_IMETHOD Render(gfxContext *ctx, gfxPattern::GraphicsFilter f);
+    NS_IMETHOD GetInputStream(const char* aMimeType,
+                              const PRUnichar* aEncoderOptions,
+                              nsIInputStream **aStream);
+    NS_IMETHOD GetThebesSurface(gfxASurface **surface);
+    NS_IMETHOD SetIsOpaque(PRBool b) { return NS_OK; };
+
+protected:
+    PRBool SafeToCreateCanvas3DContext(nsICanvasElement *canvasElement);
+    nsresult DoSwapBuffers();
+
+    // thebes helpers
+    nsresult ImageSurfaceFromElement(nsIDOMElement *imgElt,
+                                     gfxImageSurface **aSurface,
+                                     nsIPrincipal **prinOut,
+                                     PRBool *forceWriteOnlyOut,
+                                     PRBool *surfaceNeedsReleaseInsteadOfDelete);
+
+    void DoDrawImageSecurityCheck(nsIPrincipal* element_uri, PRBool forceWriteOnly);
+
+    GLES20Wrap *gl;
+
+    nsGLPbuffer *mGLPbuffer;
+    PRInt32 mWidth, mHeight;
+    nsICanvasElement* mCanvasElement;
+
+    PRPackedBool mPrefWireframe;
+
+    void LogMessage (const nsCString& errorString) {
+        nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
+        if (!console)
+            return;
+
+        console->LogStringMessage(NS_ConvertUTF8toUTF16(errorString).get());
+        fprintf(stderr, "%s\n", errorString.get());
+    }
+
+    void LogMessagef (const char *fmt, ...) {
+        va_list ap;
+        va_start(ap, fmt);
+        char buf[256];
+
+        nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
+        if (console) {
+            vsnprintf(buf, 256, fmt, ap);
+            console->LogStringMessage(NS_ConvertUTF8toUTF16(nsDependentCString(buf)).get());
+            fprintf(stderr, "%s\n", buf);
+        }
+
+        va_end(ap);
+    }
+
+};
+
+class SimpleBuffer {
+public:
+    SimpleBuffer()
+      : type(GL_FLOAT), data(nsnull), length(0), capacity(0), sizePerVertex(0)
+    { }
+
+    SimpleBuffer(PRUint32 typeParam,
+                 PRUint32 sizeParam,
+                 JSContext *ctx,
+                 JSObject *arrayObj,
+                 jsuint arrayLen)
+      : type(GL_FLOAT), data(nsnull), length(0), capacity(0), sizePerVertex(0)
+    {
+        InitFromJSArray(typeParam, sizeParam, ctx, arrayObj, arrayLen);
+    }
+
+    PRBool InitFromJSArray(PRUint32 typeParam,
+                           PRUint32 sizeParam,
+                           JSContext *ctx,
+                           JSObject *arrayObj,
+                           jsuint arrayLen);
+
+    ~SimpleBuffer() {
+        Release();
+    }
+
+    inline PRBool Valid() {
+        return data != nsnull;
+    }
+
+    inline PRUint32 ElementSize() {
+        if (type == GL_FLOAT) return sizeof(float);
+        if (type == GL_SHORT) return sizeof(short);
+        if (type == GL_UNSIGNED_SHORT) return sizeof(unsigned short);
+        if (type == GL_BYTE) return 1;
+        if (type == GL_UNSIGNED_BYTE) return 1;
+        if (type == GL_INT) return sizeof(int);
+        if (type == GL_UNSIGNED_INT) return sizeof(unsigned int);
+        if (type == GL_DOUBLE) return sizeof(double);
+        return 0;
+    }
+
+    void Clear() {
+        Release();
+    }
+
+    void Set(PRUint32 t, PRUint32 spv, PRUint32 count, void* vals) {
+        Prepare(t, spv, count);
+
+        if (count)
+            memcpy(data, vals, count*ElementSize());
+    }
+
+    void Prepare(PRUint32 t, PRUint32 spv, PRUint32 count) {
+        if (count == 0) {
+            Release();
+        } else {
+            type = t;
+            EnsureCapacity(PR_FALSE, count*ElementSize());
+            length = count;
+            sizePerVertex = spv;
+        }
+    }
+
+    void Release() {
+        if (data)
+            PR_Free(data);
+        length = 0;
+        capacity = 0;
+        data = nsnull;
+    }
+
+    void EnsureCapacity(PRBool preserve, PRUint32 cap) {
+        if (capacity >= cap)
+            return;
+
+        void* newdata = PR_Malloc(cap);
+        if (preserve && length)
+            memcpy(newdata, data, length*ElementSize());
+        PR_Free(data);
+        data = newdata;
+        capacity = cap;
+    }
+
+    PRUint32 type;
+    void* data;
+    PRUint32 length;        // # of elements
+    PRUint32 capacity;      // bytes!
+    PRUint32 sizePerVertex; // OpenGL "size" param; num coordinates per vertex
+};
+
+class CanvasGLTexture :
+    public nsICanvasRenderingContextGLTexture,
+    public nsICanvasGLTexture
+{
+    friend class nsCanvasRenderingContextGLES11;
+    friend class nsCanvasRenderingContextGLWeb20;
+public:
+    CanvasGLTexture(nsCanvasRenderingContextGLPrivate *owner);
+    ~CanvasGLTexture();
+
+    NS_DECL_ISUPPORTS
+
+    NS_DECL_NSICANVASRENDERINGCONTEXTGLTEXTURE
+
+    nsresult Init();
+    nsresult Dispose();
+
+protected:
+    PRBool mDisposed;
+    nsCOMPtr<nsIWeakReference> mOwnerContext;
+
+    GLES20Wrap *gl;
+
+    PRUint32 mWidth;
+    PRUint32 mHeight;
+};
+
+class CanvasGLBuffer :
+    public nsICanvasRenderingContextGLBuffer,
+    public nsISecurityCheckedComponent,
+    public nsICanvasGLBuffer
+{
+    friend class nsCanvasRenderingContextGLES11;
+    friend class nsCanvasRenderingContextGLWeb20;
+public:
+
+    CanvasGLBuffer(nsCanvasRenderingContextGLPrivate *owner);
+    ~CanvasGLBuffer();
+
+    // Init can be called multiple times to reinitialize this
+    // buffer object
+    nsresult Init (PRUint32 usage,
+                   PRUint32 size,
+                   PRUint32 type,
+                   JSContext *ctx,
+                   JSObject *arrayObj,
+                   jsuint arrayLen);
+
+    SimpleBuffer& GetSimpleBuffer() { return mSimpleBuffer; }
+    PRBool UpdateBuffer (PRUint32 offset, SimpleBuffer& sbuffer)
+    {
+        PRUint32 len = GetSimpleBuffer().capacity;
+        PRUint32 sbuflen = sbuffer.capacity;
+        if (offset < 0 || offset > len || sbuflen > len || offset > len - sbuflen)
+            return false;
+        memcpy(((char*)(GetSimpleBuffer().data)) + offset, sbuffer.data, sbuflen);
+        mMaxUShortComputed = false;
+        return true;
+    }
+    GLushort MaxUShortValue()
+    {
+        if (!mMaxUShortComputed) {
+            GLushort *data = (GLushort*)GetSimpleBuffer().data;
+            PRUint32 i, len;
+            GLushort max = 0;
+            len = GetSimpleBuffer().capacity / sizeof(GLushort);
+            for (i=0; i<len; ++i)
+                if (data[i] > max)
+                    max = data[i];
+            mMaxUShort = max;
+            mMaxUShortComputed = true;
+        }
+        return mMaxUShort;
+    }
+
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSICANVASRENDERINGCONTEXTGLBUFFER
+    NS_DECL_NSISECURITYCHECKEDCOMPONENT
+
+    PRUint32 Size() { return mSize; }
+    PRUint32 Length() { return mLength; }
+    PRUint32 Type() { return mType; }
+
+protected:
+    CanvasGLBuffer() { }
+
+    nsCOMPtr<nsIWeakReference> mOwnerContext;
+
+    GLES20Wrap *gl;
+
+    PRBool mDisposed;
+
+    PRUint32 mLength;
+    PRUint32 mSize;
+    PRUint32 mType;
+    PRUint32 mUsage;
+
+    SimpleBuffer mSimpleBuffer;
+    GLuint mBufferID;
+
+    GLushort mMaxUShort;
+    PRBool mMaxUShortComputed;
+};
+
+class CanvasGLThebes {
+public:
+    static gfxImageSurface *CreateImageSurface (const gfxIntSize &isize,
+                                                gfxASurface::gfxImageFormat fmt);
+
+    static gfxContext *CreateContext (gfxASurface *surf);
+
+    static gfxPattern *CreatePattern (gfxASurface *surf);
+};
+
+/* Helper macros for when we're just wrapping a gl method, so that
+ * we can avoid having to type this 500 times.  Note that these MUST
+ * NOT BE USED if we need to check any of the parameters.
+ */
+
+#define GL_SAME_METHOD_0(glname, name)                       \
+NS_IMETHODIMP NSGL_CONTEXT_NAME::name() {       \
+    MakeContextCurrent(); gl->f##glname(); return NS_OK;        \
+}
+
+#define GL_SAME_METHOD_1(glname, name, t1)                            \
+NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1) {           \
+    MakeContextCurrent(); gl->f##glname(a1); return NS_OK;               \
+}
+
+#define GL_SAME_METHOD_2(glname, name, t1, t2)                          \
+NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2) {      \
+    MakeContextCurrent(); gl->f##glname(a1,a2); return NS_OK;              \
+}
+
+#define GL_SAME_METHOD_3(glname, name, t1, t2, t3)                        \
+NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3) { \
+    MakeContextCurrent(); gl->f##glname(a1,a2,a3); return NS_OK;             \
+}
+
+#define GL_SAME_METHOD_4(glname, name, t1, t2, t3, t4)                           \
+NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
+    MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4); return NS_OK;                 \
+}
+
+#define GL_SAME_METHOD_5(glname, name, t1, t2, t3, t4, t5)                              \
+NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) { \
+    MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4,a5); return NS_OK;                     \
+}
+
+#define GL_SAME_METHOD_6(glname, name, t1, t2, t3, t4, t5, t6)                                 \
+NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) { \
+    MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4,a5,a6); return NS_OK;                         \
+}
+
+#endif /* _NSCANVASRENDERINGCONTEXTGL_H_ */
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/nsCanvasRenderingContextGLWeb20.cpp
@@ -0,0 +1,2832 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2006
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Vladimir Vukicevic <vladimir@pobox.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "prmem.h"
+#include "prlog.h"
+
+#include "nsIRenderingContext.h"
+
+#include "nsTArray.h"
+
+#define NSGL_CONTEXT_NAME nsCanvasRenderingContextGLWeb20
+
+#include "nsCanvasRenderingContextGL.h"
+#include "nsICanvasRenderingContextGLBuffer.h"
+#include "nsICanvasRenderingContextGLWeb20.h"
+#include "nsICanvasRenderingContextInternal.h"
+#include "nsIDOMHTMLCanvasElement.h"
+#include "nsIView.h"
+#include "nsIViewManager.h"
+
+#include "nsIDocument.h"
+
+#include "nsTransform2D.h"
+
+#include "nsIScriptSecurityManager.h"
+#include "nsISecurityCheckedComponent.h"
+
+#include "nsWeakReference.h"
+
+#include "nsIInterfaceRequestorUtils.h"
+#include "nsIImage.h"
+#include "nsDOMError.h"
+#include "nsIJSRuntimeService.h"
+
+#include "nsIClassInfoImpl.h"
+
+#include "nsServiceManagerUtils.h"
+
+#include "nsLayoutUtils.h"
+
+#include "nsDOMError.h"
+
+#include "nsIXPConnect.h"
+#include "jsapi.h"
+
+#include "CanvasUtils.h"
+#include "NativeJSContext.h"
+
+#ifdef XP_WIN
+#include <windows.h>
+#endif
+
+#include <GL/gl.h>
+
+using namespace mozilla;
+
+#ifndef GL_MAX_RENDERBUFFER_SIZE
+#define GL_MAX_RENDERBUFFER_SIZE      0x84E8
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET 0x8CD4
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_MAX_COLOR_ATTACHMENTS      0x8CDF
+#define GL_COLOR_ATTACHMENT0          0x8CE0
+#define GL_COLOR_ATTACHMENT1          0x8CE1
+#define GL_COLOR_ATTACHMENT2          0x8CE2
+#define GL_COLOR_ATTACHMENT3          0x8CE3
+#define GL_COLOR_ATTACHMENT4          0x8CE4
+#define GL_COLOR_ATTACHMENT5          0x8CE5
+#define GL_COLOR_ATTACHMENT6          0x8CE6
+#define GL_COLOR_ATTACHMENT7          0x8CE7
+#define GL_COLOR_ATTACHMENT8          0x8CE8
+#define GL_COLOR_ATTACHMENT9          0x8CE9
+#define GL_COLOR_ATTACHMENT10         0x8CEA
+#define GL_COLOR_ATTACHMENT11         0x8CEB
+#define GL_COLOR_ATTACHMENT12         0x8CEC
+#define GL_COLOR_ATTACHMENT13         0x8CED
+#define GL_COLOR_ATTACHMENT14         0x8CEE
+#define GL_COLOR_ATTACHMENT15         0x8CEF
+#define GL_DEPTH_ATTACHMENT           0x8D00
+#define GL_STENCIL_ATTACHMENT         0x8D20
+#define GL_FRAMEBUFFER_BINDING        0x8CA6
+#define GL_RENDERBUFFER_BINDING       0x8CA7
+#endif
+
+#ifndef GL_VERTEX_PROGRAM_POINT_SIZE
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#endif
+
+// we're hoping that something is setting us up the remap
+
+#include "gfxImageSurface.h"
+#include "gfxContext.h"
+#include "gfxPlatform.h"
+
+#ifdef PR_LOGGING
+PRLogModuleInfo* gGLES20Log = nsnull;
+#endif
+
+class nsCanvasRenderingContextGLWeb20 :
+    public nsICanvasRenderingContextGLWeb20,
+    public nsCanvasRenderingContextGLPrivate
+{
+public:
+    nsCanvasRenderingContextGLWeb20();
+    virtual ~nsCanvasRenderingContextGLWeb20();
+
+    NS_DECL_ISUPPORTS
+
+    NS_DECL_NSICANVASRENDERINGCONTEXTGL
+
+    NS_DECL_NSICANVASRENDERINGCONTEXTGLWEB20
+
+    // nsICanvasRenderingContextPrivate
+    virtual nsICanvasRenderingContextGL *GetSelf() { return this; }
+    virtual PRBool ValidateGL();
+
+protected:
+    nsresult TexImageElementBase(nsIDOMHTMLElement *imageOrCanvas,
+                                 gfxImageSurface **imageOut);
+
+    PRBool ValidateBuffers(PRUint32 count);
+
+    nsTArray<nsRefPtr<CanvasGLBuffer> > mAttribBuffers;
+    nsTArray<nsRefPtr<CanvasGLBuffer> > mBuffers;
+};
+
+
+// nsCanvasRenderingContextGLWeb20
+
+NS_IMPL_ADDREF(nsCanvasRenderingContextGLWeb20)
+NS_IMPL_RELEASE(nsCanvasRenderingContextGLWeb20)
+
+NS_INTERFACE_MAP_BEGIN(nsCanvasRenderingContextGLWeb20)
+  NS_INTERFACE_MAP_ENTRY(nsICanvasRenderingContextGL)
+  NS_INTERFACE_MAP_ENTRY(nsICanvasRenderingContextGLWeb20)
+  NS_INTERFACE_MAP_ENTRY(nsICanvasRenderingContextInternal)
+  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasRenderingContextGL)
+  NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CanvasRenderingContextGLWeb20)
+NS_INTERFACE_MAP_END
+
+static PRBool BaseTypeAndSizeFromUniformType(GLenum uType, GLenum *baseType, GLint *unitSize);
+
+nsresult
+NS_NewCanvasRenderingContextGLWeb20(nsICanvasRenderingContextGLWeb20** aResult)
+{
+    nsICanvasRenderingContextGLWeb20* ctx = new nsCanvasRenderingContextGLWeb20();
+    if (!ctx)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    NS_ADDREF(*aResult = ctx);
+    return NS_OK;
+}
+
+nsCanvasRenderingContextGLWeb20::nsCanvasRenderingContextGLWeb20()
+{
+}
+
+nsCanvasRenderingContextGLWeb20::~nsCanvasRenderingContextGLWeb20()
+{
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetCanvas(nsIDOMHTMLCanvasElement **_retval)
+{
+    if (mCanvasElement == nsnull) {
+        *_retval = nsnull;
+        return NS_OK;
+    }
+
+    return CallQueryInterface(mCanvasElement, _retval);
+}
+
+/* void activeTexture (in PRUint32 texture); */
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::ActiveTexture(PRUint32 texture)
+{
+    // XXX query number of textures available
+    if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0+32)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    MakeContextCurrent();
+    gl->fActiveTexture(texture);
+    return NS_OK;
+}
+
+GL_SAME_METHOD_2(AttachShader, AttachShader, PRUint32, PRUint32)
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::BindAttribLocation(PRUint32 program, PRUint32 location, const char *name)
+{
+    if (!name)
+        return NS_ERROR_INVALID_ARG;
+
+    MakeContextCurrent();
+    gl->fBindAttribLocation(program, location, name);
+    return NS_OK;
+}
+
+GL_SAME_METHOD_2(BindBuffer, BindBuffer, PRUint32, PRUint32)
+
+GL_SAME_METHOD_2(BindFramebuffer, BindFramebuffer, PRUint32, PRUint32)
+
+GL_SAME_METHOD_2(BindRenderbuffer, BindRenderbuffer, PRUint32, PRUint32)
+
+GL_SAME_METHOD_2(BindTexture, BindTexture, PRUint32, PRUint32)
+
+GL_SAME_METHOD_4(BlendColor, BlendColor, float, float, float, float)
+
+GL_SAME_METHOD_1(BlendEquation, BlendEquation, PRUint32)
+
+GL_SAME_METHOD_2(BlendEquationSeparate, BlendEquationSeparate, PRUint32, PRUint32)
+
+GL_SAME_METHOD_2(BlendFunc, BlendFunc, PRUint32, PRUint32)
+
+GL_SAME_METHOD_4(BlendFuncSeparate, BlendFuncSeparate, PRUint32, PRUint32, PRUint32, PRUint32)
+
+/* target, array, type, usage */
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::BufferData()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 4)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    nsresult rv;
+
+    JSObject *arrayObj;
+    jsuint arrayLen;
+    jsuint target;
+    jsuint type;
+    jsuint usage;
+    if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uouu", &target, &arrayObj, &type, &usage) ||
+        arrayObj == NULL ||
+        !::JS_IsArrayObject(js.ctx, arrayObj) ||
+        !::JS_GetArrayLength(js.ctx, arrayObj, &arrayLen))
+    {
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    if (target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) {
+        LogMessagef(("bufferData: invalid target"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    if (target == GL_ELEMENT_ARRAY_BUFFER && type != GL_UNSIGNED_SHORT) {
+        LogMessagef(("bufferData: invalid type for element array"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    switch (usage) {
+        case GL_STATIC_DRAW:
+        case GL_DYNAMIC_DRAW:
+        case GL_STREAM_DRAW:
+            break;
+        default:
+            LogMessagef(("bufferData: invalid usage"));
+            return NS_ERROR_INVALID_ARG;
+    }
+
+    MakeContextCurrent();
+    GLint binding = 0;
+    GLenum binding_target = GL_ARRAY_BUFFER_BINDING;
+    if (target == GL_ELEMENT_ARRAY_BUFFER)
+        binding_target = GL_ELEMENT_ARRAY_BUFFER_BINDING;
+    gl->fGetIntegerv(binding_target, &binding);
+    if (binding <= 0) {
+        LogMessagef(("bufferData: no buffer bound"));
+        return NS_ERROR_FAILURE;
+    }
+
+    nsRefPtr<CanvasGLBuffer> newBuffer;
+    newBuffer = new CanvasGLBuffer(this);
+    if (!newBuffer)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    rv = newBuffer->Init (usage, 1, type, js.ctx, arrayObj, arrayLen);
+    if (NS_FAILED(rv))
+        return rv;
+
+    if (!mBuffers.SetCapacity(binding+1))
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    mBuffers[binding] = newBuffer;
+
+    gl->fBufferData(target,
+        newBuffer->GetSimpleBuffer().capacity,
+        newBuffer->GetSimpleBuffer().data, usage);
+
+    return NS_OK;
+}
+
+/* target, offset, array, type */
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::BufferSubData()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 4)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    JSObject *arrayObj;
+    jsuint arrayLen;
+    jsuint target;
+    jsuint offset;
+    jsuint type;
+    if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uuou", &target, &offset, &arrayObj, &type) ||
+        arrayObj == NULL ||
+        !::JS_IsArrayObject(js.ctx, arrayObj) ||
+        !::JS_GetArrayLength(js.ctx, arrayObj, &arrayLen))
+    {
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    if (target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) {
+        LogMessagef(("bufferSubData: invalid target"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    if (target == GL_ELEMENT_ARRAY_BUFFER && type != GL_UNSIGNED_SHORT) {
+        LogMessagef(("bufferSubData: invalid type for element array"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    MakeContextCurrent();
+    GLint binding = 0;
+    GLenum binding_target = GL_ARRAY_BUFFER_BINDING;
+    if (target == GL_ELEMENT_ARRAY_BUFFER)
+        binding_target = GL_ELEMENT_ARRAY_BUFFER_BINDING;
+    gl->fGetIntegerv(binding_target, &binding);
+    if (binding <= 0) {
+        LogMessagef(("bufferSubData: no buffer bound"));
+        return NS_ERROR_FAILURE;
+    }
+
+    if ((GLushort)binding >= mBuffers.Length() || !mBuffers[binding]) {
+        LogMessagef(("bufferSubData: no mBuffers[binding]"));
+        return NS_ERROR_FAILURE;
+    }
+
+    SimpleBuffer sbuffer(type, 1, js.ctx, arrayObj, arrayLen);
+    if (!sbuffer.Valid())
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    if (!mBuffers[binding]->UpdateBuffer(offset, sbuffer)) {
+        LogMessagef(("bufferSubData: trying to write out of bounds"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    gl->fBufferSubData(target, offset, sbuffer.capacity, sbuffer.data);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::CheckFramebufferStatus(PRUint32 target, PRUint32 *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fCheckFramebufferStatus(target);
+    return NS_OK;
+}
+
+GL_SAME_METHOD_1(Clear, Clear, PRUint32)
+
+GL_SAME_METHOD_4(ClearColor, ClearColor, float, float, float, float)
+
+GL_SAME_METHOD_1(ClearDepth, ClearDepth, float)
+
+GL_SAME_METHOD_1(ClearStencil, ClearStencil, PRInt32)
+
+GL_SAME_METHOD_4(ColorMask, ColorMask, PRBool, PRBool, PRBool, PRBool)
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::CopyTexImage2D(PRUint32 target,
+                                                PRInt32 level,
+                                                PRUint32 internalformat,
+                                                PRInt32 x,
+                                                PRInt32 y,
+                                                PRUint32 width,
+                                                PRUint32 height,
+                                                PRInt32 border)
+{
+    switch (target) {
+        case GL_TEXTURE_2D:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("copyTexImage2D: unsupported target"));
+            return NS_ERROR_INVALID_ARG;
+    }
+
+    switch (internalformat) {
+        case GL_RGB:
+        case GL_RGBA:
+        case GL_ALPHA:
+        case GL_LUMINANCE:
+        case GL_LUMINANCE_ALPHA:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("copyTexImage2D: internal format not supported"));
+            return NS_ERROR_INVALID_ARG;
+    }
+
+    if (border != 0) {
+        LogMessage(NS_LITERAL_CSTRING("copyTexImage2D: border != 0"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    if (!CanvasUtils::CheckSaneSubrectSize(x,y,width, height, mWidth, mHeight)) {
+        LogMessage(NS_LITERAL_CSTRING("copyTexImage2D: copied rectangle out of bounds"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    MakeContextCurrent();
+    gl->fCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::CopyTexSubImage2D(PRUint32 target,
+                                                   PRInt32 level,
+                                                   PRInt32 xoffset,
+                                                   PRInt32 yoffset,
+                                                   PRInt32 x,
+                                                   PRInt32 y,
+                                                   PRUint32 width,
+                                                   PRUint32 height)
+{
+    switch (target) {
+        case GL_TEXTURE_2D:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("copyTexSubImage2D: unsupported target"));
+            return NS_ERROR_INVALID_ARG;
+    }
+
+    if (!CanvasUtils::CheckSaneSubrectSize(x,y,width, height, mWidth, mHeight)) {
+        LogMessage(NS_LITERAL_CSTRING("copyTexSubImage2D: copied rectangle out of bounds"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    MakeContextCurrent();
+    gl->fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+
+    return NS_OK;
+}
+
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::CreateProgram(PRUint32 *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fCreateProgram();
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::CreateShader(PRUint32 type, PRUint32 *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fCreateShader(type);
+    return NS_OK;
+}
+
+GL_SAME_METHOD_1(CullFace, CullFace, PRUint32)
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::DeleteBuffers()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 1)
+        return NS_ERROR_INVALID_ARG;
+
+    JSObject *arrayObj;
+    jsuint arrayLen;
+    if (!NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[0], &arrayObj, &arrayLen))
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    if (arrayLen <= 0)
+        return NS_ERROR_INVALID_ARG;
+
+    SimpleBuffer sbuffer(GL_UNSIGNED_INT, 1, js.ctx, arrayObj, arrayLen);
+    if (!sbuffer.Valid())
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    PRUint32 i;
+    GLuint id;
+    PRUint32 len = mBuffers.Length();
+    PRBool doResize = PR_FALSE;
+    for (i=0; i<arrayLen; ++i) {
+        id = ((GLuint*)sbuffer.data)[i];
+        if (id < len) {
+            mBuffers[id] = NULL;
+            if (id == len-1)
+                doResize = PR_TRUE;
+        }
+    }
+    if (doResize) {
+        // find last non-null index
+        for (i=len-1; i>0; --i)
+            if (mBuffers[i]) break;
+
+        // shrink mBuffers to fit contents
+        if (mBuffers.Length() > i+1)
+            mBuffers.SetLength(i+1);
+    }
+
+    MakeContextCurrent();
+    gl->fDeleteBuffers(arrayLen, (GLuint*) sbuffer.data);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::DeleteFramebuffers()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 1)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    JSObject *arrayObj;
+    jsuint arrayLen;
+    if (!NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[0], &arrayObj, &arrayLen))
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    if (arrayLen == 0)
+        return NS_OK;
+
+    SimpleBuffer sbuffer(GL_UNSIGNED_INT, 1, js.ctx, arrayObj, arrayLen);
+    if (!sbuffer.Valid())
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    MakeContextCurrent();
+    gl->fDeleteFramebuffers(arrayLen, (GLuint*) sbuffer.data);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::DeleteRenderbuffers()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 1)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    JSObject *arrayObj;
+    jsuint arrayLen;
+    if (!NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[0], &arrayObj, &arrayLen))
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    if (arrayLen == 0)
+        return NS_OK;
+
+    SimpleBuffer sbuffer(GL_UNSIGNED_INT, 1, js.ctx, arrayObj, arrayLen);;
+    if (!sbuffer.Valid())
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    MakeContextCurrent();
+    gl->fDeleteRenderbuffers(arrayLen, (GLuint*) sbuffer.data);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::DeleteTextures()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 1)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    JSObject *arrayObj;
+    jsuint arrayLen;
+    if (!NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[0], &arrayObj, &arrayLen))
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    if (arrayLen == 0)
+        return NS_OK;
+
+    SimpleBuffer sbuffer(GL_UNSIGNED_INT, 1, js.ctx, arrayObj, arrayLen);
+    if (!sbuffer.Valid())
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    MakeContextCurrent();
+    gl->fDeleteTextures(arrayLen, (GLuint*) sbuffer.data);
+
+    return NS_OK;
+}
+
+GL_SAME_METHOD_1(DeleteProgram, DeleteProgram, PRUint32)
+
+GL_SAME_METHOD_1(DeleteShader, DeleteShader, PRUint32)
+
+GL_SAME_METHOD_2(DetachShader, DetachShader, PRUint32, PRUint32)
+
+GL_SAME_METHOD_1(DepthFunc, DepthFunc, PRUint32)
+
+GL_SAME_METHOD_1(DepthMask, DepthMask, PRBool)
+
+GL_SAME_METHOD_2(DepthRange, DepthRange, float, float)
+
+GL_SAME_METHOD_1(Disable, Disable, PRUint32)
+
+GL_SAME_METHOD_1(DisableVertexAttribArray, DisableVertexAttribArray, PRUint32)
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::DrawArrays(PRUint32 mode, PRUint32 offset, PRUint32 count)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    switch (mode) {
+        case GL_TRIANGLES:
+        case GL_TRIANGLE_STRIP:
+        case GL_TRIANGLE_FAN:
+        case GL_POINTS:
+        case GL_LINE_STRIP:
+        case GL_LINE_LOOP:
+        case GL_LINES:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("drawArrays: invalid mode"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    if (offset+count < offset || offset+count < count) {
+        LogMessage(NS_LITERAL_CSTRING("drawArrays: overflow in offset+count"));
+        return NS_ERROR_INVALID_ARG;
+    }
+
+    if (!ValidateBuffers(offset+count))
+        return NS_ERROR_INVALID_ARG;
+
+    MakeContextCurrent();
+    gl->fDrawArrays(mode, offset, count);
+    return NS_OK;
+}
+
+// DrawElements
+/*in PRUint32 mode, in PRUint32 count, in PRUint32 type, in PRUint32[] indices*/
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::DrawElements()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 4)
+        return NS_ERROR_INVALID_ARG;
+
+    JSObject *arrayObj = NULL;
+    jsuint arrayLen = 0;
+    jsuint mode, count, type;
+    jsuint bufferOffset;
+
+    if (!::JS_ValueToECMAUint32(js.ctx, js.argv[0], &mode) ||
+        !::JS_ValueToECMAUint32(js.ctx, js.argv[1], &count) ||
+        !::JS_ValueToECMAUint32(js.ctx, js.argv[2], &type))
+    {
+        LogMessagef(("drawElements: invalid arguments"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    switch (mode) {
+        case GL_TRIANGLES:
+        case GL_TRIANGLE_STRIP:
+        case GL_TRIANGLE_FAN:
+        case GL_POINTS:
+        case GL_LINE_STRIP:
+        case GL_LINE_LOOP:
+        case GL_LINES:
+            break;
+        default:
+            LogMessagef(("drawElements: invalid mode"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    switch (type) {
+        case GL_UNSIGNED_SHORT:
+            break;
+        default:
+            LogMessagef(("drawElements: type must be UNSIGNED_SHORT"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    MakeContextCurrent();
+
+    if (NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[3], &arrayObj, &arrayLen)) {
+        // We were given an actual array
+        if (count > arrayLen) {
+            LogMessagef(("drawElements: count > arrayLen"));
+            return NS_ERROR_INVALID_ARG;
+        }
+
+        SimpleBuffer sbuffer(type, 1, js.ctx, arrayObj, arrayLen);
+        if (!sbuffer.Valid())
+            return NS_ERROR_FAILURE;
+
+        // calculate the biggest index present in the index array, for validation
+        GLushort max = 0;
+        for (jsuint i = 0; i < arrayLen; ++i) {
+            GLushort d = ((GLushort*)sbuffer.data)[i];
+            if (d > max)
+                max = d;
+        }
+
+        if (!ValidateBuffers(max))
+            return NS_ERROR_INVALID_ARG;
+
+        gl->fDrawElements(mode, count, type, sbuffer.data);
+    } else {
+        // We were given an integer offset into the currently bound VBO
+        GLint array_buf = 0;
+        gl->fGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &array_buf);
+
+        if (array_buf <= 0 ||
+            !::JS_ValueToECMAUint32(js.ctx, js.argv[3], &bufferOffset))
+        {
+            LogMessagef(("drawElements: invalid buffer argument"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+        }
+
+        int sz = 2;
+        GLint len = 0;
+        if ((GLushort)array_buf >= mBuffers.Length() || !mBuffers[array_buf]) {
+            LogMessagef(("drawElements: no mBuffers[array_buf]"));
+            return NS_ERROR_INVALID_ARG;
+        }
+
+        gl->fGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SIZE, &len);
+        if (len < 0 || (bufferOffset+count)*sz > (GLuint)len) {
+            LogMessagef(("drawElements: bufferOffset+count > buffer size"));
+            return NS_ERROR_INVALID_ARG;
+        }
+
+        GLushort max = mBuffers[array_buf]->MaxUShortValue();
+
+        if (!ValidateBuffers(max))
+            return NS_ERROR_INVALID_ARG;
+
+        gl->fDrawElements(mode, count, type, (GLvoid*)bufferOffset);
+    }
+
+    return NS_OK;
+}
+
+GL_SAME_METHOD_1(Enable, Enable, PRUint32)
+
+GL_SAME_METHOD_1(EnableVertexAttribArray, EnableVertexAttribArray, PRUint32)
+
+GL_SAME_METHOD_4(FramebufferRenderbuffer, FramebufferRenderbuffer, PRUint32, PRUint32, PRUint32, PRUint32)
+
+GL_SAME_METHOD_5(FramebufferTexture2D, FramebufferTexture2D, PRUint32, PRUint32, PRUint32, PRUint32, PRInt32)
+
+GL_SAME_METHOD_0(Flush, Flush)
+
+GL_SAME_METHOD_0(Finish, Finish)
+
+GL_SAME_METHOD_1(FrontFace, FrontFace, PRUint32)
+
+GL_SAME_METHOD_1(GenerateMipmap, GenerateMipmap, PRUint32)
+
+// returns an object: { size: ..., type: ..., name: ... }
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetActiveAttrib(PRUint32 program, PRUint32 index)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    GLint len = 0;
+    gl->fGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &len);
+    if (len == 0)
+        return NS_ERROR_FAILURE;
+
+    nsAutoArrayPtr<char> name(new char[len+1]);
+    PRInt32 attrsize = 0;
+    PRUint32 attrtype = 0;
+
+    gl->fGetActiveAttrib(program, index, len+1, &len, (GLint*) &attrsize, (GLuint*) &attrtype, name);
+    if (attrsize == 0 || attrtype == 0)
+        return NS_ERROR_FAILURE;
+
+    JSObjectHelper retobj(&js);
+    retobj.DefineProperty("size", attrsize);
+    retobj.DefineProperty("type", attrtype);
+    retobj.DefineProperty("name", name, len);
+
+    js.SetRetVal(retobj);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetActiveUniform(PRUint32 program, PRUint32 index)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    GLint len = 0;
+    gl->fGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len);
+    if (len == 0)
+        return NS_ERROR_FAILURE;
+
+    nsAutoArrayPtr<char> name(new char[len+1]);
+    PRInt32 attrsize = 0;
+    PRUint32 attrtype = 0;
+
+    gl->fGetActiveUniform(program, index, len+1, &len, (GLint*) &attrsize, (GLenum*) &attrtype, name);
+    if (attrsize == 0 || attrtype == 0)
+        return NS_ERROR_FAILURE;
+
+    JSObjectHelper retobj(&js);
+    retobj.DefineProperty("size", attrsize);
+    retobj.DefineProperty("type", attrtype);
+    retobj.DefineProperty("name", name, len);
+
+    js.SetRetVal(retobj.Object());
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetAttachedShaders(PRUint32 program)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    GLint count = 0;
+    gl->fGetProgramiv(program, GL_ATTACHED_SHADERS, &count);
+    if (count == 0) {
+        JSObject *empty = JS_NewArrayObject(js.ctx, 0, NULL);
+        js.SetRetVal(empty);
+        return NS_OK;
+    }
+
+    nsAutoArrayPtr<PRUint32> shaders(new PRUint32[count]);
+
+    gl->fGetAttachedShaders(program, count, NULL, (GLuint*) shaders.get());
+
+    JSObject *obj = NativeJSContext::ArrayToJSArray(js.ctx, shaders, count);
+
+    js.AddGCRoot(obj, "GetAttachedShaders");
+    js.SetRetVal(obj);
+    js.ReleaseGCRoot(obj);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetAttribLocation(PRUint32 program,
+                                                   const char *name,
+                                                   PRInt32 *retval)
+{
+    if (!name) return NS_ERROR_INVALID_ARG;
+    MakeContextCurrent();
+    *retval = gl->fGetAttribLocation(program, name);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetParameter(PRUint32 pname)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    switch (pname) {
+        //
+        // String params
+        //
+
+        // XXX do we want to fake these?  Could be a problem to reveal this to web content
+        case GL_VENDOR:
+        case GL_RENDERER:
+        case GL_VERSION:
+        case GL_SHADING_LANGUAGE_VERSION:
+        //case GL_EXTENSIONS:  // Not going to expose this
+
+            break;
+
+        //
+        // Single-value params
+        //
+
+// int
+        case GL_ARRAY_BUFFER_BINDING:
+        case GL_ELEMENT_ARRAY_BUFFER_BINDING: // XXX really?
+        case GL_CULL_FACE_MODE:
+        case GL_FRONT_FACE:
+        case GL_TEXTURE_BINDING_2D:
+        case GL_TEXTURE_BINDING_CUBE_MAP:
+        case GL_ACTIVE_TEXTURE:
+        case GL_STENCIL_WRITEMASK:
+        case GL_STENCIL_BACK_WRITEMASK:
+        case GL_DEPTH_CLEAR_VALUE:
+        case GL_STENCIL_CLEAR_VALUE:
+        case GL_STENCIL_FUNC:
+        case GL_STENCIL_VALUE_MASK:
+        case GL_STENCIL_REF:
+        case GL_STENCIL_FAIL:
+        case GL_STENCIL_PASS_DEPTH_FAIL:
+        case GL_STENCIL_PASS_DEPTH_PASS:
+        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_DEPTH_FUNC:
+        case GL_BLEND_SRC_RGB:
+        case GL_BLEND_SRC_ALPHA:
+        case GL_BLEND_DST_RGB:
+        case GL_BLEND_DST_ALPHA:
+        case GL_BLEND_EQUATION_RGB:
+        case GL_BLEND_EQUATION_ALPHA:
+        //case GL_UNPACK_ALIGNMENT: // not supported
+        //case GL_PACK_ALIGNMENT: // not supported
+        case GL_CURRENT_PROGRAM:
+        case GL_GENERATE_MIPMAP_HINT:
+        case GL_SUBPIXEL_BITS:
+        case GL_MAX_TEXTURE_SIZE:
+        case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
+        case GL_MAX_ELEMENTS_INDICES:
+        case GL_MAX_ELEMENTS_VERTICES:
+        case GL_SAMPLE_BUFFERS:
+        case GL_SAMPLES:
+        //case GL_COMPRESSED_TEXTURE_FORMATS:
+        //case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
+        //case GL_SHADER_BINARY_FORMATS:
+        //case GL_NUM_SHADER_BINARY_FORMATS:
+        case GL_MAX_VERTEX_ATTRIBS:
+        case GL_MAX_VERTEX_UNIFORM_COMPONENTS:
+        case GL_MAX_VARYING_FLOATS:
+        case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
+        case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
+        case GL_MAX_TEXTURE_IMAGE_UNITS:
+        case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
+        case GL_MAX_RENDERBUFFER_SIZE:
+        case GL_RED_BITS:
+        case GL_GREEN_BITS:
+        case GL_BLUE_BITS:
+        case GL_ALPHA_BITS:
+        case GL_DEPTH_BITS:
+        case GL_STENCIL_BITS:
+        //case GL_IMPLEMENTATION_COLOR_READ_TYPE:
+        //case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
+        case GL_RENDERBUFFER_BINDING:
+        case GL_FRAMEBUFFER_BINDING:
+        {
+            PRInt32 iv = 0;
+            gl->fGetIntegerv(pname, (GLint*) &iv);
+            js.SetRetVal(iv);
+        }
+            break;
+
+// float
+        case GL_LINE_WIDTH:
+        case GL_POLYGON_OFFSET_FACTOR:
+        case GL_POLYGON_OFFSET_UNITS:
+        case GL_SAMPLE_COVERAGE_VALUE:
+        {
+            float fv = 0;
+            gl->fGetFloatv(pname, &fv);
+            js.SetRetVal((double) fv);
+        }
+            break;
+// bool
+        case GL_SAMPLE_COVERAGE_INVERT:
+        case GL_COLOR_WRITEMASK:
+        case GL_DEPTH_WRITEMASK:
+        ////case GL_SHADER_COMPILER: // pretty much must be true 
+        {
+            GLboolean bv = 0;
+            gl->fGetBooleanv(pname, &bv);
+            js.SetBoolRetVal(bv);
+        }
+            break;
+
+        //
+        // Complex values
+        //
+        case GL_DEPTH_RANGE: // 2 floats
+        case GL_ALIASED_POINT_SIZE_RANGE: // 2 floats
+        case GL_ALIASED_LINE_WIDTH_RANGE: // 2 floats
+        {
+            float fv[2] = { 0 };
+            gl->fGetFloatv(pname, &fv[0]);
+            js.SetRetVal(fv, 2);
+        }
+            break;
+        
+        case GL_COLOR_CLEAR_VALUE: // 4 floats
+        case GL_BLEND_COLOR: // 4 floats
+        {
+            float fv[4] = { 0 };
+            gl->fGetFloatv(pname, &fv[0]);
+            js.SetRetVal(fv, 4);
+        }
+            break;
+
+        case GL_MAX_VIEWPORT_DIMS: // 2 ints
+        {
+            PRInt32 iv[2] = { 0 };
+            gl->fGetIntegerv(pname, (GLint*) &iv[0]);
+            js.SetRetVal(iv, 2);
+        }
+            break;
+
+        case GL_SCISSOR_BOX: // 4 ints
+        case GL_VIEWPORT: // 4 ints
+        {
+            PRInt32 iv[4] = { 0 };
+            gl->fGetIntegerv(pname, (GLint*) &iv[0]);
+            js.SetRetVal(iv, 4);
+        }
+            break;
+
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetBufferParameter(PRUint32 target, PRUint32 pname)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    switch (pname) {
+        case GL_BUFFER_SIZE:
+        case GL_BUFFER_USAGE:
+        case GL_BUFFER_ACCESS:
+        case GL_BUFFER_MAPPED:
+        {
+            PRInt32 iv = 0;
+            gl->fGetBufferParameteriv(target, pname, (GLint*) &iv);
+            js.SetRetVal(iv);
+        }
+            break;
+
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetFramebufferAttachmentParameter(PRUint32 target, PRUint32 attachment, PRUint32 pname)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    switch (attachment) {
+        case GL_COLOR_ATTACHMENT0:
+        case GL_DEPTH_ATTACHMENT:
+        case GL_STENCIL_ATTACHMENT:
+            break;
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+    }
+
+    switch (pname) {
+        case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+        case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+        case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
+        case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
+        {
+            PRInt32 iv = 0;
+            gl->fGetFramebufferAttachmentParameteriv(target, attachment, pname, (GLint*) &iv);
+            js.SetRetVal(iv);
+        }
+            break;
+
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetRenderbufferParameter(PRUint32 target, PRUint32 pname)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    switch (pname) {
+        case GL_RENDERBUFFER_WIDTH_EXT:
+        case GL_RENDERBUFFER_HEIGHT_EXT:
+        case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT:
+        case GL_RENDERBUFFER_RED_SIZE_EXT:
+        case GL_RENDERBUFFER_GREEN_SIZE_EXT:
+        case GL_RENDERBUFFER_BLUE_SIZE_EXT:
+        case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
+        case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
+        case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
+        {
+            PRInt32 iv = 0;
+            gl->fGetRenderbufferParameteriv(target, pname, (GLint*) &iv);
+            js.SetRetVal(iv);
+        }
+            break;
+
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GenBuffers(PRUint32 n)
+{
+    if (n == 0) return NS_OK;
+    if (n > 0xffffu) return NS_ERROR_INVALID_ARG;
+
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    nsAutoTArray<PRUint32, 16> ids;
+    ids.SetCapacity(n);
+
+    MakeContextCurrent();
+    gl->fGenBuffers(n, (GLuint*) ids.Elements());
+
+    js.SetRetVal(ids.Elements(), n);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GenTextures(PRUint32 n)
+{
+    if (n == 0) return NS_OK;
+    if (n > 0xffffu) return NS_ERROR_INVALID_ARG;
+
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    nsAutoTArray<PRUint32, 16> ids;
+    ids.SetCapacity(n);
+
+    MakeContextCurrent();
+    gl->fGenTextures(n, (GLuint*) ids.Elements());
+
+    js.SetRetVal(ids.Elements(), n);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetError(PRUint32 *_retval)
+{
+    MakeContextCurrent();
+    *_retval = gl->fGetError();
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetProgramParameter(PRUint32 program, PRUint32 pname)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    switch (pname) {
+        case GL_CURRENT_PROGRAM:
+        case GL_DELETE_STATUS:
+        case GL_LINK_STATUS:
+        case GL_VALIDATE_STATUS:
+        case GL_ATTACHED_SHADERS:
+        case GL_INFO_LOG_LENGTH:
+        case GL_ACTIVE_UNIFORMS:
+        case GL_ACTIVE_UNIFORM_MAX_LENGTH:
+        case GL_ACTIVE_ATTRIBUTES:
+        case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
+        {
+            PRInt32 iv = 0;
+            gl->fGetProgramiv(program, pname, (GLint*) &iv);
+            js.SetRetVal(iv);
+        }
+            break;
+
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetProgramInfoLog(PRUint32 program, char **retval)
+{
+    MakeContextCurrent();
+
+    PRInt32 k = -1;
+    gl->fGetProgramiv(program, GL_INFO_LOG_LENGTH, (GLint*) &k);
+    if (k == -1)
+        return NS_ERROR_FAILURE;
+
+    if (k == 0) {
+        *retval = nsnull;
+        return NS_OK;
+    }
+
+    char *s = (char *) PR_Malloc(k);
+    if (!s)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    gl->fGetProgramInfoLog(program, k, (GLint*) &k, s);
+
+    *retval = s;
+    return NS_OK;
+}
+
+/* void texParameter (); */
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::TexParameter()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 3)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    jsuint targetVal;
+    jsuint pnameVal;
+    if (!::JS_ValueToECMAUint32(js.ctx, js.argv[0], &targetVal) ||
+        !::JS_ValueToECMAUint32(js.ctx, js.argv[1], &pnameVal))
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    if (targetVal != GL_TEXTURE_2D &&
+        targetVal != GL_TEXTURE_CUBE_MAP)
+    {
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    MakeContextCurrent();
+    switch (pnameVal) {
+        case GL_TEXTURE_MIN_FILTER: {
+            jsuint ival;
+            if (!::JS_ValueToECMAUint32(js.ctx, js.argv[2], &ival) ||
+                (ival != GL_NEAREST &&
+                 ival != GL_LINEAR &&
+                 ival != GL_NEAREST_MIPMAP_NEAREST &&
+                 ival != GL_LINEAR_MIPMAP_NEAREST &&
+                 ival != GL_NEAREST_MIPMAP_LINEAR &&
+                 ival != GL_LINEAR_MIPMAP_LINEAR))
+                return NS_ERROR_DOM_SYNTAX_ERR;
+            gl->fTexParameteri (targetVal, pnameVal, ival);
+        }
+            break;
+        case GL_TEXTURE_MAG_FILTER: {
+            jsuint ival;
+            if (!::JS_ValueToECMAUint32(js.ctx, js.argv[2], &ival) ||
+                (ival != GL_NEAREST &&
+                 ival != GL_LINEAR))
+                return NS_ERROR_DOM_SYNTAX_ERR;
+            gl->fTexParameteri (targetVal, pnameVal, ival);
+        }
+            break;
+        case GL_TEXTURE_WRAP_S:
+        case GL_TEXTURE_WRAP_T: {
+            jsuint ival;
+            if (!::JS_ValueToECMAUint32(js.ctx, js.argv[2], &ival) ||
+                (ival != GL_CLAMP &&
+                 ival != GL_CLAMP_TO_EDGE &&
+                 ival != GL_REPEAT))
+                return NS_ERROR_DOM_SYNTAX_ERR;
+            gl->fTexParameteri (targetVal, pnameVal, ival);
+        }
+            break;
+        case GL_GENERATE_MIPMAP: {
+            jsuint ival;
+            if (js.argv[2] == JSVAL_TRUE)
+                ival = 1;
+            else if (js.argv[2] == JSVAL_FALSE)
+                ival = 0;
+            else if (!::JS_ValueToECMAUint32(js.ctx, js.argv[2], &ival) ||
+                     (ival != 0 && ival != 1))
+                return NS_ERROR_DOM_SYNTAX_ERR;
+            gl->fTexParameteri (targetVal, pnameVal, ival);
+        }
+            break;
+        case GL_TEXTURE_MAX_ANISOTROPY_EXT: {
+#if 0
+            if (GLEW_EXT_texture_filter_anisotropic) {
+                jsdouble dval;
+                if (!::JS_ValueToNumber(js.ctx, js.argv[2], &dval))
+                    return NS_ERROR_DOM_SYNTAX_ERR;
+                gl->fTexParameterf (targetVal, pnameVal, (float) dval);
+            } else {
+                return NS_ERROR_NOT_IMPLEMENTED;
+            }
+#else
+            return NS_ERROR_NOT_IMPLEMENTED;
+#endif
+        }
+            break;
+        default:
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    return NS_OK;
+}
+
+/* void getTexParameter (); */
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetTexParameter(PRUint32 target, PRUint32 pname)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    switch (pname) {
+        case GL_TEXTURE_MIN_FILTER:
+        case GL_TEXTURE_MAG_FILTER:
+        case GL_TEXTURE_WRAP_S:
+        case GL_TEXTURE_WRAP_T:
+        {
+            PRInt32 iv = 0;
+            gl->fGetTexParameteriv(target, pname, (GLint*) &iv);
+            js.SetRetVal(iv);
+        }
+            break;
+
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetUniform(PRUint32 program, PRUint32 location)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    GLint uArraySize = 0;
+    GLenum uType = 0;
+
+    fprintf (stderr, "GetUniform: program: %d location: %d\n", program, location);
+    gl->fGetActiveUniform(program, location, 0, NULL, &uArraySize, &uType, NULL);
+    if (uArraySize == 0)
+        return NS_ERROR_FAILURE;
+
+    // glGetUniform needs to be called for each element of an array separately, so we don't
+    // have to deal with uArraySize at all.
+
+    GLenum baseType;
+    GLint unitSize;
+    if (!BaseTypeAndSizeFromUniformType(uType, &baseType, &unitSize))
+        return NS_ERROR_FAILURE;
+
+    // this should never happen
+    if (unitSize > 16)
+        return NS_ERROR_FAILURE;
+
+    if (baseType == GL_FLOAT) {
+        GLfloat fv[16];
+        gl->fGetUniformfv(program, location, fv);
+        js.SetRetVal(fv, unitSize);
+    } else if (baseType == GL_INT) {
+        GLint iv[16];
+        gl->fGetUniformiv(program, location, iv);
+        js.SetRetVal((PRInt32*)iv, unitSize);
+    } else {
+        js.SetRetValAsJSVal(JSVAL_NULL);
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetUniformLocation(PRUint32 program, const char *name, PRInt32 *retval)
+{
+    if (!name)
+        return NS_ERROR_INVALID_ARG;
+
+    MakeContextCurrent();
+    *retval = gl->fGetUniformLocation(program, name);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetVertexAttrib(PRUint32 index, PRUint32 pname)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    switch (pname) {
+        // int
+        case GL_VERTEX_ATTRIB_ARRAY_SIZE:
+        case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
+        case GL_VERTEX_ATTRIB_ARRAY_TYPE:
+        case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
+        case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
+        case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
+        {
+            PRInt32 iv = 0;
+            gl->fGetVertexAttribiv(index, pname, (GLint*) &iv);
+            js.SetRetVal(iv);
+        }
+            break;
+
+        case GL_CURRENT_VERTEX_ATTRIB:
+        {
+            GLfloat fv[4] = { 0 };
+            gl->fGetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, &fv[0]);
+            js.SetRetVal(fv, 4);
+        }
+            break;
+
+        // not supported; doesn't make sense to return a pointer unless we have some kind of buffer object abstraction
+        case GL_VERTEX_ATTRIB_ARRAY_POINTER:
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::Hint(PRUint32 target, PRUint32 mode)
+{
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::IsBuffer(PRUint32 k, PRBool *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fIsBuffer(k);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::IsFramebuffer(PRUint32 k, PRBool *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fIsFramebuffer(k);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::IsEnabled(PRUint32 k, PRBool *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fIsEnabled(k);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::IsProgram(PRUint32 k, PRBool *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fIsProgram(k);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::IsRenderbuffer(PRUint32 k, PRBool *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fIsRenderbuffer(k);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::IsShader(PRUint32 k, PRBool *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fIsShader(k);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::IsTexture(PRUint32 k, PRBool *retval)
+{
+    MakeContextCurrent();
+    *retval = gl->fIsTexture(k);
+    return NS_OK;
+}
+
+GL_SAME_METHOD_1(LineWidth, LineWidth, float)
+
+GL_SAME_METHOD_1(LinkProgram, LinkProgram, PRUint32)
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::PixelStore(PRUint32 pname, PRInt32 param)
+{
+    if (pname != GL_PACK_ALIGNMENT &&
+        pname != GL_UNPACK_ALIGNMENT)
+        return NS_ERROR_INVALID_ARG;
+
+    MakeContextCurrent();
+    gl->fPixelStorei(pname, param);
+
+    return NS_OK;
+}
+
+GL_SAME_METHOD_2(PolygonOffset, PolygonOffset, float, float)
+
+PRBool
+IsCallerTrustedForRead()
+{
+  // FIXME this is a copy of nsContentUtils::IsCallerTrustedForRead
+  // Figure out how to #include "nsContentUtils.h" and use that instead.
+
+  // The secman really should handle UniversalXPConnect case, since that
+  // should include UniversalBrowserRead... doesn't right now, though.
+  PRBool hasCap;
+  nsIScriptSecurityManager *sSecurityManager;
+  nsresult rv = CallGetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID,
+                               &sSecurityManager);
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(sSecurityManager->IsCapabilityEnabled("UniversalBrowserRead", &hasCap)))
+    return PR_FALSE;
+  if (hasCap)
+    return PR_TRUE;
+
+  if (NS_FAILED(sSecurityManager->IsCapabilityEnabled("UniversalXPConnect",
+                                                      &hasCap)))
+    return PR_FALSE;
+  return hasCap;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::ReadPixels(PRUint32 x, PRUint32 y, PRUint32 width, PRUint32 height, PRUint32 format, PRUint32 type)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (mCanvasElement->IsWriteOnly() && !IsCallerTrustedForRead()) {
+        LogMessage(NS_LITERAL_CSTRING("readPixels: Not allowed"));
+        return NS_ERROR_DOM_SECURITY_ERR;
+    }
+
+    MakeContextCurrent();
+
+    if (!CanvasUtils::CheckSaneSubrectSize(x,y,width,height, mWidth, mHeight)) {
+        LogMessage(NS_LITERAL_CSTRING("readPixels: rectangle outside canvas"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    PRUint32 size = 0;
+    switch (format) {
+      case GL_ALPHA:
+        size = 1;
+        break;
+      case GL_RGB:
+        size = 3;
+        break;
+      case GL_RGBA:
+        size = 4;
+        break;
+      default:
+        LogMessage(NS_LITERAL_CSTRING("readPixels: unsupported pixel format"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+    switch (type) {
+//         case GL_UNSIGNED_SHORT_4_4_4_4:
+//         case GL_UNSIGNED_SHORT_5_5_5_1:
+//         case GL_UNSIGNED_SHORT_5_6_5:
+      case GL_UNSIGNED_BYTE:
+        break;
+      default:
+        LogMessage(NS_LITERAL_CSTRING("readPixels: unsupported pixel type"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    PRUint32 len = width*height*size;
+
+    nsAutoArrayPtr<PRUint8> data(new PRUint8[len]);
+    gl->fReadPixels((GLint)x, (GLint)y, width, height, format, type, (GLvoid *)data.get());
+
+    nsAutoArrayPtr<jsval> jsvector(new jsval[len]);
+    for (PRUint32 i = 0; i < len; i++)
+        jsvector[i] = INT_TO_JSVAL(data[i]);
+
+    JSObject *dataArray = JS_NewArrayObject(js.ctx, len, jsvector);
+    if (!dataArray)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    JSObjectHelper retobj(&js);
+    retobj.DefineProperty("width", width);
+    retobj.DefineProperty("height", height);
+    retobj.DefineProperty("data", dataArray);
+
+    js.SetRetVal(retobj);
+
+    return NS_OK;
+}
+
+GL_SAME_METHOD_4(RenderbufferStorage, RenderbufferStorage, PRUint32, PRUint32, PRUint32, PRUint32)
+
+GL_SAME_METHOD_2(SampleCoverage, SampleCoverage, float, PRBool)
+
+GL_SAME_METHOD_4(Scissor, Scissor, PRInt32, PRInt32, PRInt32, PRInt32)
+
+GL_SAME_METHOD_3(StencilFunc, StencilFunc, PRUint32, PRInt32, PRUint32)
+
+GL_SAME_METHOD_4(StencilFuncSeparate, StencilFuncSeparate, PRUint32, PRUint32, PRInt32, PRUint32)
+
+GL_SAME_METHOD_1(StencilMask, StencilMask, PRUint32)
+
+GL_SAME_METHOD_2(StencilMaskSeparate, StencilMaskSeparate, PRUint32, PRUint32)
+
+GL_SAME_METHOD_3(StencilOp, StencilOp, PRUint32, PRUint32, PRUint32)
+
+GL_SAME_METHOD_4(StencilOpSeparate, StencilOpSeparate, PRUint32, PRUint32, PRUint32, PRUint32)
+
+nsresult
+nsCanvasRenderingContextGLWeb20::TexImageElementBase(nsIDOMHTMLElement *imageOrCanvas,
+                                                     gfxImageSurface **imageOut)
+{
+    nsresult rv;
+
+    gfxImageSurface *surf = nsnull;
+
+    nsLayoutUtils::SurfaceFromElementResult res =
+        nsLayoutUtils::SurfaceFromElement(imageOrCanvas,
+                                          nsLayoutUtils::SFE_WANT_NEW_SURFACE | nsLayoutUtils::SFE_WANT_IMAGE_SURFACE);
+    if (!res.mSurface)
+        return rv;
+
+    CanvasUtils::DoDrawImageSecurityCheck(mCanvasElement, res.mPrincipal, res.mIsWriteOnly);
+
+    if (res.mSurface->GetType() != gfxASurface::SurfaceTypeImage) {
+        // SurfaceFromElement lied!
+        return NS_ERROR_FAILURE;
+    }
+
+    surf = static_cast<gfxImageSurface*>(res.mSurface.get());
+
+    PRInt32 width, height;
+    width = res.mSize.width;
+    height = res.mSize.height;
+
+    if (width <= 0 || height <= 0)
+        return NS_ERROR_FAILURE;
+
+    if (surf->Format() == gfxASurface::ImageFormatARGB32) {
+        PRUint8* src = surf->Data();
+        PRUint8* dst = surf->Data();
+
+        // this wants some SSE love
+
+        for (int j = 0; j < height; j++) {
+            src = surf->Data() + j * surf->Stride();
+            // note that dst's stride is always tightly packed
+            for (int i = 0; i < width; i++) {
+#ifdef IS_LITTLE_ENDIAN
+                PRUint8 b = *src++;
+                PRUint8 g = *src++;
+                PRUint8 r = *src++;
+                PRUint8 a = *src++;
+#else
+                PRUint8 a = *src++;
+                PRUint8 r = *src++;
+                PRUint8 g = *src++;
+                PRUint8 b = *src++;
+#endif
+                // Convert to non-premultiplied color
+                if (a != 0) {
+                    r = (r * 255) / a;
+                    g = (g * 255) / a;
+                    b = (b * 255) / a;
+                }
+
+                *dst++ = r;
+                *dst++ = g;
+                *dst++ = b;
+                *dst++ = a;
+            }
+        }
+    } else if (surf->Format() == gfxASurface::ImageFormatRGB24) {
+        PRUint8* src = surf->Data();
+        PRUint8* dst = surf->Data();
+
+        // this wants some SSE love
+
+        for (int j = 0; j < height; j++) {
+            src = surf->Data() + j * surf->Stride();
+            // note that dst's stride is always tightly packed
+            for (int i = 0; i < width; i++) {
+#ifdef IS_LITTLE_ENDIAN
+                PRUint8 b = *src++;
+                PRUint8 g = *src++;
+                PRUint8 r = *src++;
+                src++;
+#else
+                src++;
+                PRUint8 r = *src++;
+                PRUint8 g = *src++;
+                PRUint8 b = *src++;
+#endif
+
+                *dst++ = r;
+                *dst++ = g;
+                *dst++ = b;
+                *dst++ = 255;
+            }
+        }
+    } else {
+        return NS_ERROR_FAILURE;
+    }
+
+    res.mSurface.forget();
+    *imageOut = surf;
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::TexSubImage2DHTML(PRUint32 target, PRUint32 level, PRInt32 x, PRInt32 y, nsIDOMHTMLElement *imageOrCanvas)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    switch (target) {
+        case GL_TEXTURE_2D:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texImage2DHTML: unsupported target"));
+            return NS_ERROR_INVALID_ARG;
+    }
+
+    nsRefPtr<gfxImageSurface> isurf;
+    nsresult rv;
+
+    rv = TexImageElementBase(imageOrCanvas,
+                             getter_AddRefs(isurf));
+    if (NS_FAILED(rv))
+        return rv;
+
+    MakeContextCurrent();
+
+    gl->fTexSubImage2D(target, level, x, y, isurf->Width(), isurf->Height(), GL_RGBA, GL_UNSIGNED_BYTE, isurf->Data());
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::TexImage2DHTML(PRUint32 target, PRUint32 level, nsIDOMHTMLElement *imageOrCanvas)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    switch (target) {
+        case GL_TEXTURE_2D:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texImage2DHTML: unsupported target"));
+            return NS_ERROR_INVALID_ARG;
+    }
+
+    nsRefPtr<gfxImageSurface> isurf;
+    nsresult rv;
+
+    rv = TexImageElementBase(imageOrCanvas,
+                             getter_AddRefs(isurf));
+    if (NS_FAILED(rv))
+        return rv;
+        
+    MakeContextCurrent();
+
+    gl->fTexImage2D(target, level, GL_RGBA, isurf->Width(), isurf->Height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, isurf->Data());
+
+    return NS_OK;
+}
+
+GL_SAME_METHOD_2(Uniform1i, Uniform1i, PRUint32, PRInt32)
+GL_SAME_METHOD_3(Uniform2i, Uniform2i, PRUint32, PRInt32, PRInt32)
+GL_SAME_METHOD_4(Uniform3i, Uniform3i, PRUint32, PRInt32, PRInt32, PRInt32)
+GL_SAME_METHOD_5(Uniform4i, Uniform4i, PRUint32, PRInt32, PRInt32, PRInt32, PRInt32)
+
+GL_SAME_METHOD_2(Uniform1f, Uniform1f, PRUint32, float)
+GL_SAME_METHOD_3(Uniform2f, Uniform2f, PRUint32, float, float)
+GL_SAME_METHOD_4(Uniform3f, Uniform3f, PRUint32, float, float, float)
+GL_SAME_METHOD_5(Uniform4f, Uniform4f, PRUint32, float, float, float, float)
+
+// one uint arg followed by an array of c elements of glTypeConst.
+#define GL_SIMPLE_ARRAY_METHOD(glname, name, c, glTypeConst, ptrType)   \
+NS_IMETHODIMP                                                           \
+NSGL_CONTEXT_NAME::name()                                               \
+{                                                                       \
+    NativeJSContext js;                                                 \
+    if (NS_FAILED(js.error))                                            \
+        return js.error;                                                \
+    jsuint index;                                                       \
+    JSObject *arrayObj;                                                 \
+    jsuint arrayLen;                                                    \
+    if (js.argc != 2 ||                                                 \
+        !::JS_ValueToECMAUint32(js.ctx, js.argv[0], &index) ||          \
+        !NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[1], &arrayObj, &arrayLen)) \
+        return NS_ERROR_INVALID_ARG;                                    \
+    if (arrayLen % c != 0) {                                            \
+        LogMessage(NS_LITERAL_CSTRING(#name ": array length not divisible by " #c)); \
+        return NS_ERROR_INVALID_ARG;                                    \
+    }                                                                   \
+    SimpleBuffer sbuffer(glTypeConst, c, js.ctx, arrayObj, arrayLen);   \
+    if (!sbuffer.Valid())                                               \
+        return NS_ERROR_FAILURE;                                        \
+    MakeContextCurrent();                                               \
+    gl->f##glname(index, arrayLen / c, ( ptrType *)sbuffer.data);       \
+    return NS_OK;                                                       \
+}
+
+#define GL_SIMPLE_ARRAY_METHOD_NO_COUNT(glname, name, c, glTypeConst, ptrType) \
+NS_IMETHODIMP                                                           \
+NSGL_CONTEXT_NAME::name()                                               \
+{                                                                       \
+    NativeJSContext js;                                                 \
+    if (NS_FAILED(js.error))                                            \
+        return js.error;                                                \
+    jsuint index;                                                       \
+    JSObject *arrayObj;                                                 \
+    jsuint arrayLen;                                                    \
+    if (js.argc != 2 ||                                                 \
+        !::JS_ValueToECMAUint32(js.ctx, js.argv[0], &index) ||          \
+        !NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[1], &arrayObj, &arrayLen)) \
+        return NS_ERROR_INVALID_ARG;                                    \
+    if (arrayLen != c) {                                                \
+        LogMessage(NS_LITERAL_CSTRING(#name ": array wrong size, expected " #c)); \
+        return NS_ERROR_INVALID_ARG;                                    \
+    }                                                                   \
+    SimpleBuffer sbuffer(glTypeConst, c, js.ctx, arrayObj, arrayLen);   \
+    if (!sbuffer.Valid())                                               \
+        return NS_ERROR_FAILURE;                                        \
+    MakeContextCurrent();                                               \
+    gl->f##glname(index, ( ptrType *)sbuffer.data);                     \
+    return NS_OK;                                                       \
+}
+
+#define GL_SIMPLE_MATRIX_METHOD(glname, name, c, glTypeConst, ptrType)  \
+NS_IMETHODIMP                                                           \
+NSGL_CONTEXT_NAME::name()                                               \
+{                                                                       \
+    NativeJSContext js;                                                 \
+    if (NS_FAILED(js.error))                                            \
+        return js.error;                                                \
+    jsuint index;                                                       \
+    JSObject *arrayObj;                                                 \
+    jsuint arrayLen;                                                    \
+    if (js.argc != 2 ||                                                 \
+        !::JS_ValueToECMAUint32(js.ctx, js.argv[0], &index) ||          \
+        !NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[1], &arrayObj, &arrayLen)) \
+        return NS_ERROR_INVALID_ARG;                                    \
+    if (arrayLen != c) {                                                \
+        LogMessage(NS_LITERAL_CSTRING(#name ": array wrong size, expected " #c)); \
+        return NS_ERROR_INVALID_ARG;                                    \
+    }                                                                   \
+    SimpleBuffer sbuffer(glTypeConst, c, js.ctx, arrayObj, arrayLen);   \
+    if (!sbuffer.Valid())                                               \
+        return NS_ERROR_FAILURE;                                        \
+    MakeContextCurrent();                                               \
+    gl->f##glname(index, arrayLen / c, GL_FALSE, ( ptrType *)sbuffer.data); \
+    return NS_OK;                                                       \
+}
+
+GL_SIMPLE_ARRAY_METHOD(Uniform1iv, Uniform1iv, 1, GL_INT, GLint)
+GL_SIMPLE_ARRAY_METHOD(Uniform2iv, Uniform2iv, 2, GL_INT, GLint)
+GL_SIMPLE_ARRAY_METHOD(Uniform3iv, Uniform3iv, 3, GL_INT, GLint)
+GL_SIMPLE_ARRAY_METHOD(Uniform4iv, Uniform4iv, 4, GL_INT, GLint)
+
+GL_SIMPLE_ARRAY_METHOD(Uniform1fv, Uniform1fv, 1, GL_FLOAT, GLfloat)
+GL_SIMPLE_ARRAY_METHOD(Uniform2fv, Uniform2fv, 2, GL_FLOAT, GLfloat)
+GL_SIMPLE_ARRAY_METHOD(Uniform3fv, Uniform3fv, 3, GL_FLOAT, GLfloat)
+GL_SIMPLE_ARRAY_METHOD(Uniform4fv, Uniform4fv, 4, GL_FLOAT, GLfloat)
+
+GL_SIMPLE_MATRIX_METHOD(UniformMatrix2fv, UniformMatrix2fv, 4, GL_FLOAT, GLfloat)
+GL_SIMPLE_MATRIX_METHOD(UniformMatrix3fv, UniformMatrix3fv, 9, GL_FLOAT, GLfloat)
+GL_SIMPLE_MATRIX_METHOD(UniformMatrix4fv, UniformMatrix4fv, 16, GL_FLOAT, GLfloat)
+
+GL_SAME_METHOD_1(UseProgram, UseProgram, PRUint32)
+
+GL_SAME_METHOD_1(ValidateProgram, ValidateProgram, PRUint32)
+
+GL_SAME_METHOD_2(VertexAttrib1f, VertexAttrib1f, PRUint32, float)
+GL_SAME_METHOD_3(VertexAttrib2f, VertexAttrib2f, PRUint32, float, float)
+GL_SAME_METHOD_4(VertexAttrib3f, VertexAttrib3f, PRUint32, float, float, float)
+GL_SAME_METHOD_5(VertexAttrib4f, VertexAttrib4f, PRUint32, float, float, float, float)
+
+GL_SIMPLE_ARRAY_METHOD_NO_COUNT(VertexAttrib1fv, VertexAttrib1fv, 1, GL_FLOAT, GLfloat)
+GL_SIMPLE_ARRAY_METHOD_NO_COUNT(VertexAttrib2fv, VertexAttrib2fv, 2, GL_FLOAT, GLfloat)
+GL_SIMPLE_ARRAY_METHOD_NO_COUNT(VertexAttrib3fv, VertexAttrib3fv, 3, GL_FLOAT, GLfloat)
+GL_SIMPLE_ARRAY_METHOD_NO_COUNT(VertexAttrib4fv, VertexAttrib4fv, 4, GL_FLOAT, GLfloat)
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GenFramebuffers(PRUint32 n)
+{
+    if (n == 0) return NS_OK;
+    if (n > 0xffffu) return NS_ERROR_INVALID_ARG;
+
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    nsAutoTArray<PRUint32, 16> ids;
+    ids.SetCapacity(n);
+
+    MakeContextCurrent();
+    gl->fGenFramebuffers(n, (GLuint*) ids.Elements());
+
+    js.SetRetVal(ids.Elements(), n);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GenRenderbuffers(PRUint32 n)
+{
+    if (n == 0) return NS_OK;
+    if (n > 0xffffu) return NS_ERROR_INVALID_ARG;
+
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    nsAutoTArray<PRUint32, 16> ids;
+    ids.SetCapacity(n);
+
+    MakeContextCurrent();
+    gl->fGenRenderbuffers(n, (GLuint*) ids.Elements());
+
+    js.SetRetVal(ids.Elements(), n);
+
+    return NS_OK;
+}
+
+GL_SAME_METHOD_4(Viewport, Viewport, PRInt32, PRInt32, PRInt32, PRInt32)
+
+GL_SAME_METHOD_1(CompileShader, CompileShader, PRUint32)
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetShaderParameter(PRUint32 shader, PRUint32 pname)
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    MakeContextCurrent();
+
+    switch (pname) {
+        case GL_SHADER_TYPE:
+        case GL_DELETE_STATUS:
+        case GL_COMPILE_STATUS:
+        case GL_INFO_LOG_LENGTH:
+        case GL_SHADER_SOURCE_LENGTH:
+        {
+            PRInt32 iv = 0;
+            gl->fGetShaderiv(shader, pname, (GLint*) &iv);
+            js.SetRetVal(iv);
+        }
+            break;
+
+        default:
+            return NS_ERROR_NOT_IMPLEMENTED;
+    }
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetShaderInfoLog(PRUint32 shader, char **retval)
+{
+    MakeContextCurrent();
+
+    PRInt32 k = -1;
+    gl->fGetShaderiv(shader, GL_INFO_LOG_LENGTH, (GLint*) &k);
+    if (k == -1)
+        return NS_ERROR_FAILURE;
+
+    if (k == 0) {
+        *retval = nsnull;
+        return NS_OK;
+    }
+
+    char *s = (char *) PR_Malloc(k);
+    if (!s)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    gl->fGetShaderInfoLog(shader, k, (GLint*) &k, s);
+
+    *retval = s;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetShaderSource(PRUint32 shader, char **retval)
+{
+    MakeContextCurrent();
+
+    GLint slen = -1;
+    gl->fGetShaderiv (shader, GL_SHADER_SOURCE_LENGTH, &slen);
+    if (slen == -1)
+        return NS_ERROR_FAILURE;
+
+    if (slen == 0) {
+        *retval = nsnull;
+        return NS_OK;
+    }
+
+    char *src = (char *) nsMemory::Alloc(slen + 1);
+
+    gl->fGetShaderSource (shader, slen, NULL, src);
+
+    *retval = src;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::ShaderSource(PRUint32 shader, const char *source)
+{
+    if (!source)
+        return NS_ERROR_INVALID_ARG;
+
+    MakeContextCurrent();
+
+    gl->fShaderSource(shader, 1, &source, NULL);
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::SwapBuffers()
+{
+    return DoSwapBuffers();
+}
+
+/*in PRUint32 index, in PRInt32 size, in PRUint32 type, in PRBool normalized, in PRUint32 stride, in Object[] array*/
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::VertexAttribPointer()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    nsRefPtr<CanvasGLBuffer> newBuffer;
+    nsresult rv;
+
+    if (js.argc != 6)
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    jsuint vertexAttribIndex;
+    jsuint sizeParam;
+    jsuint typeParam;
+    JSBool normalizedParam;
+    jsuint strideParam;
+    if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uuubu",
+                               &vertexAttribIndex, &sizeParam, &typeParam,
+                               &normalizedParam, &strideParam))
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    if (vertexAttribIndex >= mAttribBuffers.Length())
+        return NS_ERROR_INVALID_ARG;
+
+    if (typeParam != GL_SHORT && typeParam != GL_FLOAT) {
+        LogMessage(NS_LITERAL_CSTRING("vertexAttribPointer: invalid element type"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    if (sizeParam < 1 || sizeParam > 4) {
+        LogMessage(NS_LITERAL_CSTRING("vertexAttribPointer: invalid element size"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    if (strideParam != 0) {
+        LogMessage(NS_LITERAL_CSTRING("vertexAttribPointer: stride must be 0 for now"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    MakeContextCurrent();
+
+    GLint array_buf = 0;
+    gl->fGetIntegerv(GL_ARRAY_BUFFER_BINDING, &array_buf);
+
+    // Are we being given a literal array, or are we being asked
+    // to use the currently bound VBO?  If we're being asked to use a VBO,
+    // then the 6th arg is an offset and not an array.
+    JSObject *arrayObj;
+    jsuint arrayLen;
+    if (NativeJSContext::JSValToJSArrayAndLength(js.ctx, js.argv[5], &arrayObj, &arrayLen)) {
+        // if we were given an array, we must not have a buffer binding
+        if (array_buf != 0) {
+            LogMessage(NS_LITERAL_CSTRING("vertexAttribPointer: called with array arg while ARRAY_BUFFER_BINDING != 0!"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+        }
+
+        newBuffer = new CanvasGLBuffer(this);
+        if (!newBuffer)
+            return NS_ERROR_OUT_OF_MEMORY;
+
+        rv = newBuffer->Init (GL_STATIC_DRAW, sizeParam, typeParam, js.ctx, arrayObj, arrayLen);
+        if (NS_FAILED(rv))
+            return rv;
+
+        mAttribBuffers[vertexAttribIndex] = newBuffer;
+
+        gl->fVertexAttribPointer(vertexAttribIndex,
+                                 newBuffer->GetSimpleBuffer().sizePerVertex,
+                                 newBuffer->GetSimpleBuffer().type,
+                                 normalizedParam ? GL_TRUE : GL_FALSE,
+                                 strideParam,
+                                 newBuffer->GetSimpleBuffer().data);
+    } else {
+        // grab the buffer offset
+        jsuint bufferOffset;
+        if (!::JS_ValueToECMAUint32(js.ctx, js.argv[3], &bufferOffset))
+            return NS_ERROR_INVALID_ARG;
+
+        int sz = (typeParam == GL_SHORT ? 2 : 4);
+
+        GLint len = 0;
+        gl->fGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &len);
+
+        if (len < 0 || bufferOffset*sz > (GLuint)len) {
+            LogMessage(NS_LITERAL_CSTRING("vertexAttribPointer: offset out of buffer bounds"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+        }
+
+        mAttribBuffers[vertexAttribIndex] = NULL;
+
+        gl->fVertexAttribPointer(vertexAttribIndex,
+                                 sizeParam,
+                                 typeParam,
+                                 normalizedParam ? GL_TRUE : GL_FALSE,
+                                 strideParam,
+                                 (GLvoid*)(bufferOffset*sz));
+    }
+
+    return NS_OK;
+}
+
+PRBool
+nsCanvasRenderingContextGLWeb20::ValidateGL()
+{
+    // make sure that the opengl stuff that we need is supported
+    GLint val = 0;
+    gl->fGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &val);
+    fprintf (stderr, "-- %d vertex buffers\n", (int)val);
+    mAttribBuffers.SetLength(val);
+    mBuffers.SetLength(256);
+
+    // gl_PointSize is always available in ES2 GLSL
+    gl->fEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
+
+    return PR_TRUE;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::TexSubImage2D()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 9) {
+        LogMessage(NS_LITERAL_CSTRING("texSubImage2D: expected 9 arguments"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    jsuint argTarget, argLevel, argX, argY, argWidth, argHeight, argFormat, argType;
+    JSObject *argPixelsObj;
+    jsuint argPixelsLen;
+    if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uuuuuuuuo",
+                               &argTarget, &argLevel, &argX, &argY,
+                               &argWidth, &argHeight, &argFormat, &argType,
+                               &argPixelsObj) ||
+        JSVAL_IS_NULL(argPixelsObj) ||
+        !::JS_IsArrayObject(js.ctx, argPixelsObj) ||
+        !::JS_GetArrayLength(js.ctx, argPixelsObj, &argPixelsLen))
+    {
+        LogMessage(NS_LITERAL_CSTRING("texSubImage2D: argument error"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    switch (argTarget) {
+        case GL_TEXTURE_2D:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texSubImage2D: unsupported target"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    PRUint32 bufferType, bufferSize;
+    switch (argFormat) {
+        case GL_RED:
+        case GL_GREEN:
+        case GL_BLUE:
+        case GL_ALPHA:
+        case GL_LUMINANCE:
+            bufferSize = 1;
+            break;
+        case GL_LUMINANCE_ALPHA:
+            bufferSize = 2;
+            break;
+        case GL_RGB:
+            bufferSize = 3;
+            break;
+        case GL_RGBA:
+            bufferSize = 4;
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texSubImage2D: pixel format not supported"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    switch (argType) {
+        case GL_SHORT:
+        case GL_UNSIGNED_SHORT:
+        case GL_BYTE:
+        case GL_UNSIGNED_BYTE:
+        case GL_INT:
+        case GL_UNSIGNED_INT:
+        case GL_FLOAT:
+            bufferType = argType;
+            break;
+        case GL_UNSIGNED_SHORT_4_4_4_4:
+        case GL_UNSIGNED_SHORT_5_5_5_1:
+        case GL_UNSIGNED_SHORT_5_6_5:
+            bufferType = GL_UNSIGNED_SHORT;
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texSubImage2D: pixel packing not supported"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    // make sure the size is valid
+    PRInt32 tmp = argWidth * argHeight;
+    if (tmp && tmp / argHeight != argWidth) {
+        LogMessage(NS_LITERAL_CSTRING("texSubImage2D: too large width or height"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    tmp = tmp * bufferSize;
+    if (tmp && tmp / bufferSize != (argWidth * argHeight)) {
+        LogMessage(NS_LITERAL_CSTRING("texSubImage2D: too large width or height (after multiplying with pixel size)"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    if ((PRUint32) tmp > argPixelsLen) {
+        LogMessage(NS_LITERAL_CSTRING("texSubImage2D: array dimensions too small for width, height and pixel format"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    SimpleBuffer sbuffer(bufferType, bufferSize, js.ctx, argPixelsObj, argPixelsLen);
+    if (!sbuffer.Valid())
+        return NS_ERROR_FAILURE;
+
+    MakeContextCurrent();
+    gl->fTexSubImage2D (argTarget, argLevel, argX, argY, argWidth, argHeight, argFormat, argType, (void *) sbuffer.data);
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::TexImage2D()
+{
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 9) {
+        LogMessage(NS_LITERAL_CSTRING("texImage2D: expected 9 arguments"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    jsuint argTarget, argLevel, argInternalFormat, argWidth, argHeight, argBorder, argFormat, argType;
+    JSObject *argPixelsObj;
+    jsuint argPixelsLen;
+    if (!::JS_ConvertArguments(js.ctx, js.argc, js.argv, "uuuuuuuuo",
+                               &argTarget, &argLevel, &argInternalFormat, &argWidth,
+                               &argHeight, &argBorder, &argFormat, &argType,
+                               &argPixelsObj) ||
+        (argPixelsObj != NULL && !JSVAL_IS_NULL(argPixelsObj) && (
+        !::JS_IsArrayObject(js.ctx, argPixelsObj) ||
+        !::JS_GetArrayLength(js.ctx, argPixelsObj, &argPixelsLen))))
+    {
+        LogMessage(NS_LITERAL_CSTRING("texImage2D: argument error"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    if (argWidth == 0 || argHeight == 0) {
+        LogMessage(NS_LITERAL_CSTRING("texImage2D: width or height is zero"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    switch (argTarget) {
+        case GL_TEXTURE_2D:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texImage2D: unsupported target"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    if (argBorder != 0) {
+        LogMessage(NS_LITERAL_CSTRING("texImage2D: non-zero border given"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    switch (argInternalFormat) {
+        case GL_RGB:
+        case GL_RGBA:
+        case GL_ALPHA:
+        case GL_LUMINANCE:
+        case GL_LUMINANCE_ALPHA:
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texImage2D: internal format not supported"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    PRUint32 bufferType, bufferSize;
+    switch (argFormat) {
+        case GL_RED:
+        case GL_GREEN:
+        case GL_BLUE:
+        case GL_ALPHA:
+        case GL_LUMINANCE:
+            bufferSize = 1;
+            break;
+        case GL_LUMINANCE_ALPHA:
+            bufferSize = 2;
+            break;
+        case GL_RGB:
+            bufferSize = 3;
+            break;
+        case GL_RGBA:
+            bufferSize = 4;
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texImage2D: pixel format not supported"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    switch (argType) {
+        case GL_SHORT:
+        case GL_UNSIGNED_SHORT:
+        case GL_BYTE:
+        case GL_UNSIGNED_BYTE:
+        case GL_INT:
+        case GL_UNSIGNED_INT:
+        case GL_FLOAT:
+            bufferType = argType;
+            break;
+        case GL_UNSIGNED_SHORT_4_4_4_4:
+        case GL_UNSIGNED_SHORT_5_5_5_1:
+        case GL_UNSIGNED_SHORT_5_6_5:
+            bufferType = GL_UNSIGNED_SHORT;
+            break;
+        default:
+            LogMessage(NS_LITERAL_CSTRING("texImage2D: pixel packing not supported"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    // make sure the size is valid
+    PRInt32 tmp = argWidth * argHeight;
+    if (tmp && tmp / argHeight != argWidth) {
+        LogMessage(NS_LITERAL_CSTRING("texImage2D: too large width or height"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    tmp = tmp * bufferSize;
+    if (tmp && tmp / bufferSize != (argWidth * argHeight)) {
+        LogMessage(NS_LITERAL_CSTRING("texImage2D: too large width or height (after multiplying with pixel size)"));
+        return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+
+    // XXX handle GL_UNPACK_ALIGNMENT !
+
+    if (argPixelsObj == NULL || JSVAL_IS_NULL(argPixelsObj)) {
+      MakeContextCurrent();
+      gl->fTexImage2D (argTarget, argLevel, argInternalFormat, argWidth, argHeight, argBorder, argFormat, argType, NULL);
+    } else {
+        if ((PRUint32) tmp > argPixelsLen) {
+            LogMessage(NS_LITERAL_CSTRING("texImage2D: array dimensions too small for width, height and pixel format"));
+            return NS_ERROR_DOM_SYNTAX_ERR;
+        }
+
+        SimpleBuffer sbuffer(bufferType, bufferSize, js.ctx, argPixelsObj, argPixelsLen);
+        if (!sbuffer.Valid())
+            return NS_ERROR_FAILURE;
+
+        MakeContextCurrent();
+        gl->fTexImage2D (argTarget, argLevel, argInternalFormat, argWidth, argHeight, argBorder, argFormat, argType, (void *) sbuffer.data);
+    }
+    return NS_OK;
+}
+
+PRBool
+nsCanvasRenderingContextGLWeb20::ValidateBuffers(PRUint32 count)
+{
+    GLint len = 0;
+    GLint enabled = 0, size = 4, type = GL_FLOAT, binding = 0;
+    PRBool someEnabled = PR_FALSE;
+    GLint currentProgram = -1;
+    GLint numAttributes = -1;
+
+    MakeContextCurrent();
+
+    gl->fGetIntegerv(GL_CURRENT_PROGRAM, &currentProgram);
+    if (currentProgram == -1) {
+        // what?
+        LogMessagef("glGetIntegerv GL_CURRENT_PROGRAM failed: 0x%08x", (uint) gl->fGetError());
+        return PR_FALSE;
+    }
+
+    gl->fGetProgramiv(currentProgram, GL_ACTIVE_ATTRIBUTES, &numAttributes);
+    if (numAttributes == -1) {
+        // what?
+        LogMessagef("glGetProgramiv GL_ACTIVE_ATTRIBUTES failed: 0x%08x", (uint) gl->fGetError());
+        return PR_FALSE;
+    }
+
+    // is this valid?
+    if (numAttributes > (GLint) mAttribBuffers.Length()) {
+        // what?
+        LogMessagef("GL_ACTIVE_ATTRIBUTES > GL_MAX_VERTEX_ATTRIBS");
+        return PR_FALSE;
+    }
+    PRUint32 maxAttribs = numAttributes;
+
+    for (PRUint32 i = 0; i < maxAttribs; ++i) {
+        GLsizei nameBufSz = 256;
+        GLchar nameBuf[256];
+        GLint vaSize;
+        GLenum vaType;
+        GLint attribLoc = -1;
+
+        gl->fGetActiveAttrib(currentProgram, i, nameBufSz, &nameBufSz, &vaSize, &vaType, nameBuf);
+        attribLoc = gl->fGetAttribLocation(currentProgram, nameBuf);
+
+        if (attribLoc == -1) {
+            LogMessagef(("Couldn't find an active attrib by name?"));
+            return PR_FALSE;
+        }
+
+        enabled = 0;
+        gl->fGetVertexAttribiv(attribLoc, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
+
+        if (enabled) {
+            binding = 0;
+            gl->fGetVertexAttribiv(attribLoc, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &binding);
+
+            // figure out element size and type
+            size = -1;
+            type = GL_FLOAT;
+
+            // Note that the VERTEX_ATTRIB_ARRAY_{SIZE,TYPE} don't matter,
+            // just what the type is of the buffer since GL will convert/expand.
+
+            if (binding) {
+                if (binding < 0 || binding >= (GLint) mBuffers.Length() || !mBuffers[binding]) {
+                    LogMessagef(("ValidateBuffers: invalid buffer bound"));
+                    return PR_FALSE;
+                }
+                len = mBuffers[binding]->GetSimpleBuffer().capacity;
+                size = -1;
+                gl->fGetVertexAttribiv(attribLoc, GL_VERTEX_ATTRIB_ARRAY_SIZE, &size);
+                if (size <= 0) {
+                    LogMessagef(("ValidateBuffers: invalid VertexAttribPointer size"));
+                    return PR_FALSE;
+                }
+                type = mBuffers[binding]->Type();
+            } else {
+                if (!mAttribBuffers[attribLoc]) {
+                    LogMessagef(("ValidateBuffers: invalid VertexAttribPointer"));
+                    return PR_FALSE;
+                }
+                len = mAttribBuffers[attribLoc]->GetSimpleBuffer().capacity;
+                size = mAttribBuffers[attribLoc]->Size();
+                type = mAttribBuffers[attribLoc]->Type();
+            }
+
+            switch (type) {
+                case GL_FLOAT:
+                    size *= 4;
+                    break;
+                case GL_SHORT:
+                case GL_UNSIGNED_SHORT:
+                // case GL_FIXED:
+                    size *= 2;
+                    break;
+                case GL_UNSIGNED_BYTE:
+                case GL_BYTE:
+                    break;
+                default:
+                    LogMessagef("ValidateBuffers: bad GL_VERTEX_ATTRIB_ARRAY_TYPE %d", type);
+                    return PR_FALSE;
+            }
+
+            if (len <= 0 || size <= 0 || count > (PRUint32)(len / size)) {
+                LogMessagef(("ValidateBuffers: trying to draw out of bounds"));
+                return PR_FALSE;
+            }
+
+            someEnabled = PR_TRUE;
+        }
+    }
+
+    if (!someEnabled) {
+        LogMessagef(("ValidateBuffers: no vertex attribs enabled"));
+        return PR_FALSE;
+    }
+
+    return PR_TRUE;
+}
+
+PRBool
+BaseTypeAndSizeFromUniformType(GLenum uType, GLenum *baseType, GLint *unitSize)
+{
+        switch (uType) {
+        case GL_INT:
+        case GL_INT_VEC2:
+        case GL_INT_VEC3:
+        case GL_INT_VEC4:
+        case GL_SAMPLER_2D:
+        case GL_SAMPLER_CUBE:
+            *baseType = GL_INT;
+            break;
+        case GL_FLOAT:
+        case GL_FLOAT_VEC2:
+        case GL_FLOAT_VEC3:
+        case GL_FLOAT_VEC4:
+        case GL_FLOAT_MAT2:
+        case GL_FLOAT_MAT3:
+        case GL_FLOAT_MAT4:
+            *baseType = GL_FLOAT;
+            break;
+        case GL_BOOL:
+        case GL_BOOL_VEC2:
+        case GL_BOOL_VEC3:
+        case GL_BOOL_VEC4:
+            *baseType = GL_INT; // pretend these are int
+            break;
+        default:
+            return PR_FALSE;
+    }
+
+    switch (uType) {
+        case GL_INT:
+        case GL_FLOAT:
+        case GL_BOOL:
+        case GL_SAMPLER_2D:
+        case GL_SAMPLER_CUBE:
+            *unitSize = 1;
+            break;
+        case GL_INT_VEC2:
+        case GL_FLOAT_VEC2:
+        case GL_BOOL_VEC2:
+            *unitSize = 2;
+            break;
+        case GL_INT_VEC3:
+        case GL_FLOAT_VEC3:
+        case GL_BOOL_VEC3:
+            *unitSize = 3;
+            break;
+        case GL_INT_VEC4:
+        case GL_FLOAT_VEC4:
+        case GL_BOOL_VEC4:
+            *unitSize = 4;
+            break;
+        case GL_FLOAT_MAT2:
+            *unitSize = 4;
+            break;
+        case GL_FLOAT_MAT3:
+            *unitSize = 9;
+            break;
+        case GL_FLOAT_MAT4:
+            *unitSize = 16;
+            break;
+        default:
+            return PR_FALSE;
+    }
+
+    return PR_TRUE;
+}
+
+// ImageData getImageData (in float x, in float y, in float width, in float height);
+NS_IMETHODIMP
+nsCanvasRenderingContextGLWeb20::GetImageData(PRUint32 x, PRUint32 y, PRUint32 w, PRUint32 h)
+{
+    // disabled due to win32 linkage issues with thebes symbols and NS_RELEASE
+    return NS_ERROR_FAILURE;
+
+#if 0
+    NativeJSContext js;
+    if (NS_FAILED(js.error))
+        return js.error;
+
+    if (js.argc != 4) return NS_ERROR_INVALID_ARG;
+    
+    if (!mGLPbuffer ||
+        !mGLPbuffer->ThebesSurface())
+        return NS_ERROR_FAILURE;
+
+    if (!mCanvasElement)
+        return NS_ERROR_FAILURE;
+
+    if (mCanvasElement->IsWriteOnly() && !IsCallerTrustedForRead()) {
+        // XXX ERRMSG we need to report an error to developers here! (bug 329026)
+        return NS_ERROR_DOM_SECURITY_ERR;
+    }
+
+    JSContext *ctx = js.ctx;
+
+    if (!CanvasUtils::CheckSaneSubrectSize (x, y, w, h, mWidth, mHeight))
+        return NS_ERROR_DOM_SYNTAX_ERR;
+
+    nsAutoArrayPtr<PRUint8> surfaceData (new (std::nothrow) PRUint8[w * h * 4]);
+    int surfaceDataStride = w*4;
+    int surfaceDataOffset = 0;
+
+    if (!surfaceData)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    nsRefPtr<gfxImageSurface> tmpsurf = new gfxImageSurface(surfaceData,
+                                                            gfxIntSize(w, h),
+                                                            w * 4,
+                                                            gfxASurface::ImageFormatARGB32);
+    if (!tmpsurf || tmpsurf->CairoStatus())
+        return NS_ERROR_FAILURE;
+
+    nsRefPtr<gfxContext> tmpctx = new gfxContext(tmpsurf);
+
+    if (!tmpctx || tmpctx->HasError())
+        return NS_ERROR_FAILURE;
+
+    nsRefPtr<gfxASurface> surf = mGLPbuffer->ThebesSurface();
+    nsRefPtr<gfxPattern> pat = CanvasGLThebes::CreatePattern(surf);
+    gfxMatrix m;
+    m.Translate(gfxPoint(x, mGLPbuffer->Height()-y));
+    m.Scale(1.0, -1.0);
+    pat->SetMatrix(m);
+
+    // XXX I don't want to use PixelSnapped here, but layout doesn't guarantee
+    // pixel alignment for this stuff!
+    tmpctx->NewPath();
+    tmpctx->PixelSnappedRectangleAndSetPattern(gfxRect(0, 0, w, h), pat);
+    tmpctx->SetOperator(gfxContext::OPERATOR_SOURCE);
+    tmpctx->Fill();
+
+    tmpctx = nsnull;
+    tmpsurf = nsnull;
+
+    PRUint32 len = w * h * 4;
+    if (len > (((PRUint32)0xfff00000)/sizeof(jsval)))
+        return NS_ERROR_INVALID_ARG;
+
+    nsAutoArrayPtr<jsval> jsvector(new (std::nothrow) jsval[w * h * 4]);
+    if (!jsvector)
+        return NS_ERROR_OUT_OF_MEMORY;
+    jsval *dest = jsvector.get();
+    PRUint8 *row;
+    for (PRUint32 j = 0; j < h; j++) {
+        row = surfaceData + surfaceDataOffset + (surfaceDataStride * j);
+        for (PRUint32 i = 0; i < w; i++) {
+            // XXX Is there some useful swizzle MMX we can use here?
+            // I guess we have to INT_TO_JSVAL still
+#ifdef IS_LITTLE_ENDIAN
+            PRUint8 b = *row++;
+            PRUint8 g = *row++;
+            PRUint8 r = *row++;
+            PRUint8 a = *row++;
+#else
+            PRUint8 a = *row++;
+            PRUint8 r = *row++;
+            PRUint8 g = *row++;
+            PRUint8 b = *row++;
+#endif
+            // Convert to non-premultiplied color
+            if (a != 0) {
+                r = (r * 255) / a;
+                g = (g * 255) / a;
+                b = (b * 255) / a;
+            }
+
+            *dest++ = INT_TO_JSVAL(r);
+            *dest++ = INT_TO_JSVAL(g);
+            *dest++ = INT_TO_JSVAL(b);
+            *dest++ = INT_TO_JSVAL(a);
+        }
+    }
+
+    JSObject *dataArray = JS_NewArrayObject(ctx, w*h*4, jsvector);
+    if (!dataArray)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    JSObjectHelper retobj(&js);
+    retobj.DefineProperty("width", w);
+    retobj.DefineProperty("height", h);
+    retobj.DefineProperty("data", dataArray);
+
+    js.SetRetVal(retobj);
+
+    return NS_OK;
+#endif
+}
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/nsGLPbuffer.cpp
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Vladimir Vukicevic <vladimir@pobox.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdarg.h>
+
+#include "nsCanvasRenderingContextGL.h"
+
+#include "nsGLPbuffer.h"
+
+#if 0
+#include <xmmintrin.h>
+#endif
+
+void *nsGLPbuffer::sCurrentContextToken = nsnull;
+
+void
+nsGLPbuffer::LogMessage (const nsCString& errorString)
+{
+    if (mPriv)
+        mPriv->LogMessage(errorString);
+    else
+        fprintf(stderr, "nsGLPbuffer: %s\n", errorString.get());
+}
+
+void
+nsGLPbuffer::LogMessagef (const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    char buf[256];
+
+    vsnprintf(buf, 256, fmt, ap);
+
+    if (mPriv)
+        mPriv->LogMessage(nsDependentCString(buf));
+    else
+        fprintf(stderr, "nsGLPbuffer: %s\n", buf);
+
+    va_end(ap);
+}
+
+static void
+premultiply_slow(unsigned char *src, unsigned int len)
+{
+    int a,t;
+    for (unsigned int i=0; i<len; i+=4) {
+        a = src[i+3];
+        t = src[i]*a+0x80;
+        src[i] = ((t>>8) + t) >> 8;
+        t = src[i+1]*a+0x80;
+        src[i+1] = ((t>>8) + t) >> 8;
+        t = src[i+2]*a+0x80;
+        src[i+2] = ((t>>8) + t) >> 8;
+    }
+}
+
+#if 0
+static void
+premultiply_sse2(__m128i* block, __m128i* block_end)
+{
+    __m128i xmm0080, xmm0101, xmmAlpha, data, dataLo, dataHi, alphaLo, alphaHi;
+    while (block < block_end) {
+        xmm0080 = _mm_set1_epi16(0x0080);
+        xmm0101 = _mm_set1_epi16(0x0101);
+        xmmAlpha = _mm_set_epi32(0x00ff0000, 0x00000000, 0x00ff0000, 0x00000000);
+
+        data = _mm_loadu_si128(block);
+        dataLo = _mm_unpacklo_epi8 (data, _mm_setzero_si128 ());
+        dataHi = _mm_unpackhi_epi8 (data, _mm_setzero_si128 ());
+
+        alphaLo = _mm_shufflelo_epi16 (dataLo, _MM_SHUFFLE(3, 3, 3, 3));
+        alphaHi = _mm_shufflelo_epi16 (dataHi, _MM_SHUFFLE(3, 3, 3, 3));
+        alphaLo = _mm_shufflehi_epi16 (alphaLo, _MM_SHUFFLE(3, 3, 3, 3));
+        alphaHi = _mm_shufflehi_epi16 (alphaHi, _MM_SHUFFLE(3, 3, 3, 3));
+
+        alphaLo = _mm_or_si128(alphaLo, xmmAlpha);
+        alphaHi = _mm_or_si128(alphaHi, xmmAlpha);
+
+        dataLo = _mm_shufflelo_epi16 (dataLo, _MM_SHUFFLE(3, 2, 1, 0));
+        dataLo = _mm_shufflehi_epi16 (dataLo, _MM_SHUFFLE(3, 2, 1, 0));
+        dataHi = _mm_shufflelo_epi16 (dataHi, _MM_SHUFFLE(3, 2, 1, 0));
+        dataHi = _mm_shufflehi_epi16 (dataHi, _MM_SHUFFLE(3, 2, 1, 0));
+
+        dataLo = _mm_mullo_epi16(dataLo, alphaLo);
+        dataHi = _mm_mullo_epi16(dataHi, alphaHi);
+
+        dataLo = _mm_adds_epu16(dataLo, xmm0080);
+        dataHi = _mm_adds_epu16(dataHi, xmm0080);
+
+        dataLo = _mm_mulhi_epu16(dataLo, xmm0101);
+        dataHi = _mm_mulhi_epu16(dataHi, xmm0101);
+
+        data = _mm_packus_epi16 (dataLo, dataHi);
+        _mm_storeu_si128(block, data);
+
+        ++block;
+    }
+}
+#endif
+
+void
+nsGLPbuffer::Premultiply(unsigned char *src, unsigned int len)
+{
+#if 0
+    if (can_sse2) {
+        premultiply_sse2((__m128i*)src, (__m128i*)(src+len));
+        return;
+    }
+#endif
+
+    premultiply_slow(src, len);
+}
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/nsGLPbuffer.h
@@ -0,0 +1,218 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Vladimir Vukicevic <vladimir@pobox.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef NSGLPBUFFER_H_
+#define NSGLPBUFFER_H_
+
+#ifdef C3D_STANDALONE_BUILD
+#include "c3d-standalone.h"
+#endif
+
+#include "nsStringGlue.h"
+
+#include "gfxASurface.h"
+#include "gfxImageSurface.h"
+
+#ifdef XP_WIN
+#include "gfxWindowsSurface.h"
+#endif
+
+#if defined(XP_UNIX) && defined(MOZ_X11)
+#include "GL/glx.h"
+#endif
+
+#ifdef XP_MACOSX
+#include "gfxQuartzImageSurface.h"
+#include <OpenGL/CGLTypes.h>
+#endif
+
+#include "glwrap.h"
+
+class nsCanvasRenderingContextGLPrivate;
+
+class nsGLPbuffer {
+public:
+    nsGLPbuffer() : mWidth(0), mHeight(0), mPriv(0) { }
+    virtual ~nsGLPbuffer() { }
+
+    virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv) = 0;
+    virtual PRBool Resize(PRInt32 width, PRInt32 height) = 0;
+    virtual void Destroy() = 0;
+
+    virtual void MakeContextCurrent() = 0;
+    virtual void SwapBuffers() = 0;
+
+    virtual gfxASurface* ThebesSurface() = 0;
+
+    PRInt32 Width() { return mWidth; }
+    PRInt32 Height() { return mHeight; }
+
+    GLES20Wrap *GL() { return &mGLWrap; }
+
+protected:
+    PRInt32 mWidth, mHeight;
+
+    GLES20Wrap mGLWrap;
+
+    static void *sCurrentContextToken;
+    nsCanvasRenderingContextGLPrivate *mPriv;
+
+    void Premultiply(unsigned char *src, unsigned int len);
+
+    void LogMessage (const nsCString& errorString);
+    void LogMessagef (const char *fmt, ...);
+};
+
+class nsGLPbufferOSMESA :
+    public nsGLPbuffer
+{
+public:
+    nsGLPbufferOSMESA();
+    virtual ~nsGLPbufferOSMESA();
+
+    virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv);
+    virtual PRBool Resize(PRInt32 width, PRInt32 height);
+    virtual void Destroy();
+
+    virtual void MakeContextCurrent();
+    virtual void SwapBuffers();
+
+    virtual gfxASurface* ThebesSurface();
+
+protected:
+    nsRefPtr<gfxImageSurface> mThebesSurface;
+    PrivateOSMesaContext mMesaContext;
+};
+
+#ifdef XP_MACOSX
+class nsGLPbufferCGL :
+    public nsGLPbuffer
+{
+public:
+    nsGLPbufferCGL();
+    virtual ~nsGLPbufferCGL();
+
+    virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv);
+    virtual PRBool Resize(PRInt32 width, PRInt32 height);
+    virtual void Destroy();
+
+    virtual void MakeContextCurrent();
+    virtual void SwapBuffers();
+
+    virtual gfxASurface* ThebesSurface();
+
+    CGLPixelFormatObj GetCGLPixelFormat() { return mPixelFormat; }
+    CGLContextObj GetCGLContext() { return mContext; }
+    CGLPBufferObj GetCGLPbuffer() { return mPbuffer; }
+
+protected:
+    CGLPixelFormatObj mPixelFormat;
+    CGLContextObj mContext;
+    CGLPBufferObj mPbuffer;
+
+    PRBool mImageNeedsUpdate;
+    nsRefPtr<gfxImageSurface> mThebesSurface;
+    nsRefPtr<gfxQuartzImageSurface> mQuartzSurface;
+
+    typedef void (GLAPIENTRY * PFNGLFLUSHPROC) (void);
+    PFNGLFLUSHPROC fFlush;
+};
+#endif
+
+#if defined(XP_UNIX) && defined(MOZ_X11)
+class nsGLPbufferGLX :
+    public nsGLPbuffer
+{
+public:
+    nsGLPbufferGLX();
+    virtual ~nsGLPbufferGLX();
+
+    virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv);
+    virtual PRBool Resize(PRInt32 width, PRInt32 height);
+    virtual void Destroy();
+
+    virtual void MakeContextCurrent();
+    virtual void SwapBuffers();
+
+    virtual gfxASurface* ThebesSurface();
+
+protected:
+    nsRefPtr<gfxImageSurface> mThebesSurface;
+
+    Display     *mDisplay;
+    GLXFBConfig mFBConfig;
+    GLXPbuffer mPbuffer;
+    GLXContext mPbufferContext;
+};
+#endif
+
+#ifdef XP_WIN
+class nsGLPbufferWGL :
+    public nsGLPbuffer
+{
+public:
+    nsGLPbufferWGL();
+    virtual ~nsGLPbufferWGL();
+
+    virtual PRBool Init(nsCanvasRenderingContextGLPrivate *priv);
+    virtual PRBool Resize(PRInt32 width, PRInt32 height);
+    virtual void Destroy();
+
+    virtual void MakeContextCurrent();
+    virtual void SwapBuffers();
+
+    virtual gfxASurface* ThebesSurface();
+
+protected:
+    // this is the crap that we need to get the gl entry points
+    HWND mGlewWindow;
+    HDC mGlewDC;
+    HANDLE mGlewWglContext;
+
+    // and this is the actual stuff that we need to render
+    HANDLE mPbuffer;
+    HDC mPbufferDC;
+    HANDLE mPbufferContext;
+
+    nsRefPtr<gfxImageSurface> mThebesSurface;
+    nsRefPtr<gfxWindowsSurface> mWindowsSurface;
+};
+#endif
+
+
+#endif /* NSGLPBUFFER_H_ */
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/nsGLPbufferCGL.cpp
@@ -0,0 +1,249 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Mozilla Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Vladimir Vukicevic <vladimir@pobox.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <OpenGL/OpenGL.h>
+
+#include "nsICanvasRenderingContextGL.h"
+
+#include "nsIPrefService.h"
+
+#include "nsGLPbuffer.h"
+#include "nsCanvasRenderingContextGL.h"
+
+#include "gfxContext.h"
+
+static PRUint32 gActiveBuffers = 0;
+
+nsGLPbufferCGL::nsGLPbufferCGL()
+    : mContext(nsnull), mPbuffer(nsnull), fFlush(nsnull)
+{
+    gActiveBuffers++;
+    fprintf (stderr, "nsGLPbuffer: gActiveBuffers: %d\n", gActiveBuffers);
+}
+
+PRBool
+nsGLPbufferCGL::Init(nsCanvasRenderingContextGLPrivate *priv)
+{
+    mPriv = priv;
+    nsresult rv;
+
+    nsCOMPtr<nsIPrefService> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    nsCOMPtr<nsIPrefBranch> prefBranch;
+    rv = prefService->GetBranch("extensions.canvas3d.", getter_AddRefs(prefBranch));
+    NS_ENSURE_SUCCESS(rv, PR_FALSE);
+
+    PRInt32 prefAntialiasing;
+    rv = prefBranch->GetIntPref("antialiasing", &prefAntialiasing);
+    if (NS_FAILED(rv))
+        prefAntialiasing = 0;
+    
+    CGLPixelFormatAttribute attrib[] = {
+        kCGLPFAAccelerated,
+        kCGLPFAMinimumPolicy,
+        kCGLPFAPBuffer,
+        kCGLPFAColorSize, (CGLPixelFormatAttribute) 24,
+        kCGLPFAAlphaSize, (CGLPixelFormatAttribute) 8,
+        kCGLPFADepthSize, (CGLPixelFormatAttribute) 8,
+        (CGLPixelFormatAttribute) 0
+    };
+
+#if 0
+    if (false && prefAntialiasing > 0) {
+        attrib[12] = AGL_SAMPLE_BUFFERS_ARB;
+        attrib[13] = 1;
+
+        attrib[14] = AGL_SAMPLES_ARB;
+        attrib[15] = 1 << prefAntialiasing;
+    }
+#endif
+
+    CGLError err;
+
+    GLint npix;
+    err = CGLChoosePixelFormat(attrib, &mPixelFormat, &npix);
+    if (err) {
+        fprintf (stderr, "CGLChoosePixelFormat failed: %d\n", err);
+        return PR_FALSE;
+    }
+
+    // we need a context for glewInit
+    Resize(2, 2);
+    MakeContextCurrent();
+
+    if (!mGLWrap.OpenLibrary("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib")) {
+        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: Failed to open LibGL.dylib (tried system OpenGL.framework)"));
+        return PR_FALSE;
+    }
+
+    if (!mGLWrap.Init(GLES20Wrap::TRY_NATIVE_GL)) {
+        LogMessage(NS_LITERAL_CSTRING("Canvas 3D: GLWrap init failed"));
+        return PR_FALSE;
+    }
+
+    fFlush = (PFNGLFLUSHPROC) mGLWrap.LookupSymbol("glFlush", true);
+
+    return PR_TRUE;
+}
+
+PRBool
+nsGLPbufferCGL::Resize(PRInt32 width, PRInt32 height)
+{
+    if (mWidth == width &&
+        mHeight == height)
+    {
+        return PR_TRUE;
+    }
+
+    Destroy();
+
+    mThebesSurface = nsnull;
+    mQuartzSurface = nsnull;
+        
+    CGLError err;
+
+    err = CGLCreateContext(mPixelFormat, NULL, &mContext);
+    if (err) {
+        fprintf (stderr, "CGLCreateContext failed: %d\n", err);
+        return PR_FALSE;
+    }
+
+    err = CGLCreatePBuffer(width, height, GL_TEXTURE_RECTANGLE_EXT, GL_RGBA, 0, &mPbuffer);
+    if (err) {
+        fprintf (stderr, "CGLCreatePBuffer failed: %d\n", err);
+        return PR_FALSE;
+    }
+
+    GLint screen;
+    err = CGLGetVirtualScreen(mContext, &screen);
+    if (err) {
+        fprintf (stderr, "CGLGetVirtualScreen failed: %d\n", err);
+        return PR_FALSE;
+    }
+
+    err = CGLSetPBuffer(mContext, mPbuffer, 0, 0, screen);
+    if (err) {
+        fprintf (stderr, "CGLSetPBuffer failed: %d\n", err);
+        return PR_FALSE;
+    }
+
+    mWidth = width;
+    mHeight = height;
+
+    return PR_TRUE;
+}
+
+void
+nsGLPbufferCGL::Destroy()
+{
+    sCurrentContextToken = nsnull;
+    mThebesSurface = nsnull;
+
+    if (mContext) {
+        CGLDestroyContext(mContext);
+        mContext = nsnull;
+    }
+    if (mPbuffer) {
+        CGLDestroyPBuffer(mPbuffer);
+        mPbuffer = nsnull;
+    }
+}
+
+nsGLPbufferCGL::~nsGLPbufferCGL()
+{
+    Destroy();
+
+    if (mPixelFormat) {
+        CGLDestroyPixelFormat(mPixelFormat);
+        mPixelFormat = nsnull;
+    }
+
+    gActiveBuffers--;
+    fprintf (stderr, "nsGLPbuffer: gActiveBuffers: %d\n", gActiveBuffers);
+    fflush (stderr);
+}
+
+void
+nsGLPbufferCGL::MakeContextCurrent()
+{
+    CGLError err = CGLSetCurrentContext (mContext);
+    if (err) {
+        fprintf (stderr, "CGLSetCurrentContext failed: %d\n", err);
+    }
+}
+
+void
+nsGLPbufferCGL::SwapBuffers()
+{
+    MakeContextCurrent();
+
+    // oddly, CGLFlushDrawable() doesn't seem to work, even though it should be calling
+    // glFlush first.
+    if (fFlush)
+        fFlush();
+
+    mImageNeedsUpdate = PR_TRUE;
+}
+
+gfxASurface*
+nsGLPbufferCGL::ThebesSurface()
+{
+    if (!mThebesSurface) {
+        mThebesSurface = CanvasGLThebes::CreateImageSurface(gfxIntSize(mWidth, mHeight), gfxASurface::ImageFormatARGB32);
+        if (mThebesSurface->CairoStatus() != 0) {
+            fprintf (stderr, "image surface failed\n");
+            return nsnull;
+        }
+
+        mQuartzSurface = new gfxQuartzImageSurface(mThebesSurface);
+
+        mImageNeedsUpdate = PR_TRUE;
+    }
+
+    if (mImageNeedsUpdate) {
+        MakeContextCurrent();
+        mGLWrap.fReadPixels (0, 0, mWidth, mHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, mThebesSurface->Data());
+
+        mQuartzSurface->Flush();
+
+        mImageNeedsUpdate = PR_FALSE;
+    }
+
+    return mQuartzSurface;
+}
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/nsGLPbufferGLX.cpp
@@ -0,0 +1,338 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at